MLIR_CAPI_EXPORTED MlirLocation mlirLocationCallSiteGet(MlirLocation callee,
MlirLocation caller);
+/// Creates a name location owned by the given context. Providing null location
+/// for childLoc is allowed and if childLoc is null location, then the behavior
+/// is the same as having unknown child location.
+MLIR_CAPI_EXPORTED MlirLocation mlirLocationNameGet(MlirContext context,
+ MlirStringRef name,
+ MlirLocation childLoc);
+
/// Creates a location with unknown position owned by the given context.
MLIR_CAPI_EXPORTED MlirLocation mlirLocationUnknownGet(MlirContext context);
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Dialect.h"
+#include "mlir/IR/Location.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/Types.h"
#include "mlir/IR/Verifier.h"
return wrap(Location(CallSiteLoc::get(unwrap(callee), unwrap(caller))));
}
+MlirLocation mlirLocationNameGet(MlirContext context, MlirStringRef name,
+ MlirLocation childLoc) {
+ if (mlirLocationIsNull(childLoc))
+ return wrap(
+ Location(NameLoc::get(Identifier::get(unwrap(name), unwrap(context)))));
+ return wrap(Location(NameLoc::get(
+ Identifier::get(unwrap(name), unwrap(context)), unwrap(childLoc))));
+}
+
MlirLocation mlirLocationUnknownGet(MlirContext context) {
return wrap(Location(UnknownLoc::get(unwrap(context))));
}
#include "mlir-c/Dialect/Standard.h"
#include "mlir-c/IntegerSet.h"
#include "mlir-c/Registration.h"
+#include "mlir-c/Support.h"
#include <assert.h>
#include <inttypes.h>
ctx, mlirStringRefCreateFromCString("other-file.c"), 2, 3),
fileLineColLoc);
mlirEmitError(callSiteLoc, "test diagnostics");
+ MlirLocation null = {0};
+ MlirLocation nameLoc =
+ mlirLocationNameGet(ctx, mlirStringRefCreateFromCString("named"), null);
+ mlirEmitError(nameLoc, "test diagnostics");
mlirContextDetachDiagnosticHandler(ctx, id);
mlirEmitError(unknownLoc, "more test diagnostics");
// CHECK-LABEL: @test_diagnostics
// CHECK: test diagnostics
// CHECK: loc(callsite("other-file.c":2:3 at "file.c":1:2))
// CHECK: >> end of diagnostic (userData: 42)
+ // CHECK: processing diagnostic (userData: 42) <<
+ // CHECK: test diagnostics
+ // CHECK: loc("named")
+ // CHECK: >> end of diagnostic (userData: 42)
// CHECK: deleting user data (userData: 42)
// CHECK-NOT: processing diagnostic
// CHECK: more test diagnostics