For creating a fused loc using array of locations and metadata.
Differential Revision: https://reviews.llvm.org/D110022
MLIR_CAPI_EXPORTED MlirLocation mlirLocationCallSiteGet(MlirLocation callee,
MlirLocation caller);
+/// Creates a fused location with an array of locations and metadata.
+MLIR_CAPI_EXPORTED MlirLocation
+mlirLocationFusedGet(MlirContext ctx, intptr_t nLocations,
+ MlirLocation const *locations, MlirAttribute metadata);
+
/// 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.
return wrap(Location(CallSiteLoc::get(unwrap(callee), unwrap(caller))));
}
+MlirLocation mlirLocationFusedGet(MlirContext ctx, intptr_t nLocations,
+ MlirLocation const *locations,
+ MlirAttribute metadata) {
+ SmallVector<Location, 4> locs;
+ ArrayRef<Location> unwrappedLocs = unwrapList(nLocations, locations, locs);
+ return wrap(FusedLoc::get(unwrappedLocs, unwrap(metadata), unwrap(ctx)));
+}
+
MlirLocation mlirLocationNameGet(MlirContext context, MlirStringRef name,
MlirLocation childLoc) {
if (mlirLocationIsNull(childLoc))
MlirLocation nameLoc =
mlirLocationNameGet(ctx, mlirStringRefCreateFromCString("named"), null);
mlirEmitError(nameLoc, "test diagnostics");
+ MlirLocation locs[2] = {nameLoc, callSiteLoc};
+ MlirAttribute nullAttr = {0};
+ MlirLocation fusedLoc = mlirLocationFusedGet(ctx, 2, locs, nullAttr);
+ mlirEmitError(fusedLoc, "test diagnostics");
mlirContextDetachDiagnosticHandler(ctx, id);
mlirEmitError(unknownLoc, "more test diagnostics");
// CHECK-LABEL: @test_diagnostics
// CHECK: test diagnostics
// CHECK: loc("named")
// CHECK: >> end of diagnostic (userData: 42)
+ // CHECK: processing diagnostic (userData: 42) <<
+ // CHECK: test diagnostics
+ // CHECK: loc(fused["named", callsite("other-file.c":2:3 at "file.c":1:2)])
// CHECK: deleting user data (userData: 42)
// CHECK-NOT: processing diagnostic
// CHECK: more test diagnostics