|
MLIR 22.0.0git
|
Represents a diagnostic handler attached to the context. More...
#include "mlir/Bindings/Python/IRCore.h"
Public Member Functions | |
| PyDiagnosticHandler (MlirContext context, nanobind::object callback) | |
| ~PyDiagnosticHandler () | |
| bool | isAttached () |
| bool | getHadError () |
| void | detach () |
| Detaches the handler. Does nothing if not attached. | |
| nanobind::object | contextEnter () |
| void | contextExit (const nanobind::object &excType, const nanobind::object &excVal, const nanobind::object &excTb) |
Friends | |
| class | PyMlirContext |
Represents a diagnostic handler attached to the context.
The handler's callback will be invoked with PyDiagnostic instances until the detach() method is called or the context is destroyed. A diagnostic handler can be the subject of a with block, which will detach it when the block exits.
Since diagnostic handlers can call back into Python code which can do unsafe things (i.e. recursively emitting diagnostics, raising exceptions, etc), this is generally not deemed to be a great user-level API. Users should generally use some form of DiagnosticCollector. If the handler raises any exceptions, they will just be emitted to stderr and dropped.
The unique usage of this class means that its lifetime management is different from most other parts of the API. Instances are always created in an attached state and can transition to a detached state by either: a) The context being destroyed and unregistering all handlers. b) An explicit call to detach(). The object may remain live from a Python perspective for an arbitrary time after detachment, but there is nothing the user can do with it (since there is no way to attach an existing handler object).
| mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyDiagnosticHandler::PyDiagnosticHandler | ( | MlirContext | context, |
| nanobind::object | callback ) |
Definition at line 738 of file IRCore.cpp.
|
default |
|
inline |
Definition at line 418 of file IRCore.h.
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().
|
inline |
Definition at line 419 of file IRCore.h.
References detach().
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().
| void mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::PyDiagnosticHandler::detach | ( | ) |
Detaches the handler. Does nothing if not attached.
Definition at line 744 of file IRCore.cpp.
Referenced by contextExit(), and mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().
|
inline |
Definition at line 413 of file IRCore.h.
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().
|
inline |
Definition at line 412 of file IRCore.h.
Referenced by mlir::python::MLIR_BINDINGS_PYTHON_DOMAIN::populateIRCore().
|
friend |