MLIR  19.0.0git
Classes | Typedefs | Enumerations | Functions
Diagnostics.h File Reference
#include "mlir-c/IR.h"
#include "mlir-c/Support.h"

Go to the source code of this file.

Classes

struct  MlirDiagnostic
 An opaque reference to a diagnostic, always owned by the diagnostics engine (context). More...
 

Typedefs

typedef struct MlirDiagnostic MlirDiagnostic
 
typedef enum MlirDiagnosticSeverity MlirDiagnosticSeverity
 
typedef uint64_t MlirDiagnosticHandlerID
 Opaque identifier of a diagnostic handler, useful to detach a handler. More...
 
typedef MlirLogicalResult(* MlirDiagnosticHandler) (MlirDiagnostic, void *userData)
 Diagnostic handler type. More...
 

Enumerations

enum  MlirDiagnosticSeverity { MlirDiagnosticError , MlirDiagnosticWarning , MlirDiagnosticNote , MlirDiagnosticRemark }
 Severity of a diagnostic. More...
 

Functions

MLIR_CAPI_EXPORTED void mlirDiagnosticPrint (MlirDiagnostic diagnostic, MlirStringCallback callback, void *userData)
 Prints a diagnostic using the provided callback. More...
 
MLIR_CAPI_EXPORTED MlirLocation mlirDiagnosticGetLocation (MlirDiagnostic diagnostic)
 Returns the location at which the diagnostic is reported. More...
 
MLIR_CAPI_EXPORTED MlirDiagnosticSeverity mlirDiagnosticGetSeverity (MlirDiagnostic diagnostic)
 Returns the severity of the diagnostic. More...
 
MLIR_CAPI_EXPORTED intptr_t mlirDiagnosticGetNumNotes (MlirDiagnostic diagnostic)
 Returns the number of notes attached to the diagnostic. More...
 
MLIR_CAPI_EXPORTED MlirDiagnostic mlirDiagnosticGetNote (MlirDiagnostic diagnostic, intptr_t pos)
 Returns pos-th note attached to the diagnostic. More...
 
MLIR_CAPI_EXPORTED MlirDiagnosticHandlerID mlirContextAttachDiagnosticHandler (MlirContext context, MlirDiagnosticHandler handler, void *userData, void(*deleteUserData)(void *))
 Attaches the diagnostic handler to the context. More...
 
MLIR_CAPI_EXPORTED void mlirContextDetachDiagnosticHandler (MlirContext context, MlirDiagnosticHandlerID id)
 Detaches an attached diagnostic handler from the context given its identifier. More...
 
MLIR_CAPI_EXPORTED void mlirEmitError (MlirLocation location, const char *message)
 Emits an error at the given location through the diagnostics engine. More...
 

Typedef Documentation

◆ MlirDiagnostic

Definition at line 1 of file Diagnostics.h.

◆ MlirDiagnosticHandler

typedef MlirLogicalResult(* MlirDiagnosticHandler) (MlirDiagnostic, void *userData)

Diagnostic handler type.

Accepts a reference to a diagnostic, which is only guaranteed to be live during the call. The handler is passed the userData that was provided when the handler was attached to a context. If the handler processed the diagnostic completely, it is expected to return success. Otherwise, it is expected to return failure to indicate that other handlers should attempt to process the diagnostic.

Definition at line 49 of file Diagnostics.h.

◆ MlirDiagnosticHandlerID

typedef uint64_t MlirDiagnosticHandlerID

Opaque identifier of a diagnostic handler, useful to detach a handler.

Definition at line 41 of file Diagnostics.h.

◆ MlirDiagnosticSeverity

Definition at line 1 of file Diagnostics.h.

Enumeration Type Documentation

◆ MlirDiagnosticSeverity

Severity of a diagnostic.

Enumerator
MlirDiagnosticError 
MlirDiagnosticWarning 
MlirDiagnosticNote 
MlirDiagnosticRemark 

Definition at line 32 of file Diagnostics.h.

Function Documentation

◆ mlirContextAttachDiagnosticHandler()

MLIR_CAPI_EXPORTED MlirDiagnosticHandlerID mlirContextAttachDiagnosticHandler ( MlirContext  context,
MlirDiagnosticHandler  handler,
void *  userData,
void(*)(void *)  deleteUserData 
)

Attaches the diagnostic handler to the context.

Handlers are invoked in the reverse order of attachment until one of them processes the diagnostic completely. When a handler is invoked it is passed the userData that was provided when it was attached. If non-NULL, deleteUserData is called once the system no longer needs to call the handler (for instance after the handler is detached or the context is destroyed). Returns an identifier that can be used to detach the handler.

Definition at line 56 of file Diagnostics.cpp.

References deleteUserDataNoop(), unwrap(), and wrap().

Referenced by mlir::python::PyMlirContext::attachDiagnosticHandler(), and mlir::python::CollectDiagnosticsToStringScope::CollectDiagnosticsToStringScope().

◆ mlirContextDetachDiagnosticHandler()

MLIR_CAPI_EXPORTED void mlirContextDetachDiagnosticHandler ( MlirContext  context,
MlirDiagnosticHandlerID  id 
)

Detaches an attached diagnostic handler from the context given its identifier.

Definition at line 72 of file Diagnostics.cpp.

References unwrap().

Referenced by mlir::python::PyDiagnosticHandler::detach(), mlir::python::CollectDiagnosticsToStringScope::~CollectDiagnosticsToStringScope(), and mlir::python::PyMlirContext::ErrorCapture::~ErrorCapture().

◆ mlirDiagnosticGetLocation()

MLIR_CAPI_EXPORTED MlirLocation mlirDiagnosticGetLocation ( MlirDiagnostic  diagnostic)

Returns the location at which the diagnostic is reported.

Definition at line 24 of file Diagnostics.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::PyDiagnostic::getLocation().

◆ mlirDiagnosticGetNote()

MLIR_CAPI_EXPORTED MlirDiagnostic mlirDiagnosticGetNote ( MlirDiagnostic  diagnostic,
intptr_t  pos 
)

Returns pos-th note attached to the diagnostic.

Expects pos to be a valid zero-based index into the list of notes.

Definition at line 50 of file Diagnostics.cpp.

References unwrap(), and wrap().

Referenced by mlir::python::PyDiagnostic::getNotes().

◆ mlirDiagnosticGetNumNotes()

MLIR_CAPI_EXPORTED intptr_t mlirDiagnosticGetNumNotes ( MlirDiagnostic  diagnostic)

Returns the number of notes attached to the diagnostic.

Definition at line 44 of file Diagnostics.cpp.

References unwrap().

Referenced by mlir::python::PyDiagnostic::getNotes().

◆ mlirDiagnosticGetSeverity()

MLIR_CAPI_EXPORTED MlirDiagnosticSeverity mlirDiagnosticGetSeverity ( MlirDiagnostic  diagnostic)

◆ mlirDiagnosticPrint()

MLIR_CAPI_EXPORTED void mlirDiagnosticPrint ( MlirDiagnostic  diagnostic,
MlirStringCallback  callback,
void *  userData 
)

Prints a diagnostic using the provided callback.

Definition at line 18 of file Diagnostics.cpp.

References mlir::Diagnostic::print(), and unwrap().

Referenced by mlir::python::PyDiagnostic::getMessage().

◆ mlirEmitError()

MLIR_CAPI_EXPORTED void mlirEmitError ( MlirLocation  location,
const char *  message 
)

Emits an error at the given location through the diagnostics engine.

Used for testing purposes.

Definition at line 78 of file Diagnostics.cpp.

References mlir::emitError(), and unwrap().