Numerous MLIR functions return instances of `StringRef` to refer to a non-owning fragment of a string (usually owned by the context). This is a relatively simple class that is defined in LLVM. Provide a simple wrapper in the MLIR C API that contains the pointer and length of the string fragment and use it for Standard attribute functions that return StringRef instead of the previous, callback-based mechanism. Reviewed By: stellaraccident Differential Revision: https://reviews.llvm.org/D87677
16 lines
533 B
C++
16 lines
533 B
C++
//===- Support.cpp - Helpers for C interface to MLIR API ------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir-c/Support.h"
|
|
|
|
#include <cstring>
|
|
|
|
MlirStringRef mlirStringRefCreateFromCString(const char *str) {
|
|
return mlirStringRefCreate(str, strlen(str));
|
|
}
|