29 switch (
unwrap(diagnostic).getSeverity()) {
39 llvm_unreachable(
"unhandled diagnostic severity");
45 return static_cast<intptr_t
>(llvm::size(
unwrap(diagnostic).getNotes()));
51 return wrap(*std::next(
unwrap(diagnostic).getNotes().begin(), pos));
58 void (*deleteUserData)(
void *)) {
59 assert(handler &&
"unexpected null diagnostic handler");
60 if (deleteUserData ==
nullptr)
63 unwrap(context)->getDiagEngine().registerHandler(
65 ownedUserData = std::unique_ptr<
void, decltype(deleteUserData)>(
66 userData, deleteUserData)](
Diagnostic &diagnostic) {
67 return unwrap(handler(
wrap(diagnostic), ownedUserData.get()));
74 unwrap(context)->getDiagEngine().eraseHandler(
MlirDiagnosticSeverity mlirDiagnosticGetSeverity(MlirDiagnostic diagnostic)
Returns the severity of the diagnostic.
static void deleteUserDataNoop(void *userData)
intptr_t mlirDiagnosticGetNumNotes(MlirDiagnostic diagnostic)
Returns the number of notes attached to the diagnostic.
void mlirEmitError(MlirLocation location, const char *message)
Emits an error at the given location through the diagnostics engine.
MlirLocation mlirDiagnosticGetLocation(MlirDiagnostic diagnostic)
Returns the location at which the diagnostic is reported.
void mlirDiagnosticPrint(MlirDiagnostic diagnostic, MlirStringCallback callback, void *userData)
Prints a diagnostic using the provided callback.
MlirDiagnostic mlirDiagnosticGetNote(MlirDiagnostic diagnostic, intptr_t pos)
Returns pos-th note attached to the diagnostic.
void mlirContextDetachDiagnosticHandler(MlirContext context, MlirDiagnosticHandlerID id)
Detaches an attached diagnostic handler from the context given its identifier.
MlirDiagnosticHandlerID mlirContextAttachDiagnosticHandler(MlirContext context, MlirDiagnosticHandler handler, void *userData, void(*deleteUserData)(void *))
Attaches the diagnostic handler to the context.
uint64_t HandlerID
A handle to a specific registered handler object.
This class contains all of the information necessary to report a diagnostic to the DiagnosticEngine.
void print(raw_ostream &os) const
Outputs this diagnostic to a stream.
A simple raw ostream subclass that forwards write_impl calls to the user-supplied callback together w...
MlirDiagnosticSeverity
Severity of a diagnostic.
MlirLogicalResult(* MlirDiagnosticHandler)(MlirDiagnostic, void *userData)
Diagnostic handler type.
uint64_t MlirDiagnosticHandlerID
Opaque identifier of a diagnostic handler, useful to detach a handler.
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
void(* MlirStringCallback)(MlirStringRef, void *)
A callback for returning string references.
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
An opaque reference to a diagnostic, always owned by the diagnostics engine (context).