diff --git a/mlir/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h --- a/mlir/include/mlir-c/IR.h +++ b/mlir/include/mlir-c/IR.h @@ -148,6 +148,11 @@ unsigned line, unsigned col); +/** Creates an File/Line/Column location owned by the given context using an + * MlirStringRef for the filename. */ +MLIR_CAPI_EXPORTED MlirLocation mlirLocationFileStringRefLineColGet( + MlirContext context, MlirStringRef filename, unsigned line, unsigned col); + /// Creates a location with unknown position owned by the given context. MLIR_CAPI_EXPORTED MlirLocation mlirLocationUnknownGet(MlirContext context); diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp --- a/mlir/lib/CAPI/IR/IR.cpp +++ b/mlir/lib/CAPI/IR/IR.cpp @@ -114,6 +114,13 @@ return wrap(FileLineColLoc::get(filename, line, col, unwrap(context))); } +MlirLocation mlirLocationFileStringRefLineColGet(MlirContext context, + MlirStringRef filename, + unsigned line, unsigned col) { + return wrap( + FileLineColLoc::get(unwrap(filename), line, col, unwrap(context))); +} + MlirLocation mlirLocationUnknownGet(MlirContext context) { return wrap(UnknownLoc::get(unwrap(context))); }