diff options
| author | Nikhil Kalra <nkalra@apple.com> | 2025-03-10 15:59:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-10 15:59:47 -0700 |
| commit | b15ccd436aef320802635984f336fcfe5b69ff0b (patch) | |
| tree | 2f4586cfa33a6f0cd66a2db74f17130f2e64bbd3 /mlir/test/python/lib/PythonTestCAPI.cpp | |
| parent | 9b066f0b57fdf341e55f754fa35d49e1b35b1af3 (diff) | |
[mlir] Better Python diagnostics (#128581)
Updated the Python diagnostics handler to emit notes (in addition to
errors) into the output stream so that users have more context as to
where in the IR the error is occurring.
Diffstat (limited to 'mlir/test/python/lib/PythonTestCAPI.cpp')
| -rw-r--r-- | mlir/test/python/lib/PythonTestCAPI.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mlir/test/python/lib/PythonTestCAPI.cpp b/mlir/test/python/lib/PythonTestCAPI.cpp index cb7d7677714f..ee6a5ae2d9c3 100644 --- a/mlir/test/python/lib/PythonTestCAPI.cpp +++ b/mlir/test/python/lib/PythonTestCAPI.cpp @@ -11,6 +11,8 @@ #include "mlir-c/BuiltinTypes.h" #include "mlir/CAPI/Registration.h" #include "mlir/CAPI/Wrap.h" +#include "mlir/IR/Diagnostics.h" +#include "mlir/IR/Location.h" MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(PythonTest, python_test, python_test::PythonTestDialect) @@ -42,3 +44,9 @@ MlirTypeID mlirPythonTestTestTypeGetTypeID(void) { bool mlirTypeIsAPythonTestTestTensorValue(MlirValue value) { return mlirTypeIsATensor(wrap(unwrap(value).getType())); } + +void mlirPythonTestEmitDiagnosticWithNote(MlirContext ctx) { + auto diag = + mlir::emitError(unwrap(mlirLocationUnknownGet(ctx)), "created error"); + diag.attachNote() << "attached note"; +} |
