9 #ifndef MLIR_BINDINGS_PYTHON_DIAGNOSTICS_H
10 #define MLIR_BINDINGS_PYTHON_DIAGNOSTICS_H
14 #include "llvm/Support/raw_ostream.h"
33 assert(message.empty() &&
"unchecked error message");
38 std::string newMessage;
39 std::swap(message, newMessage);
46 *
static_cast<llvm::raw_string_ostream *
>(data)
47 << std::string_view(message.
data, message.
length);
50 *
static_cast<llvm::raw_string_ostream *
>(data) <<
"at ";
52 *
static_cast<llvm::raw_string_ostream *
>(data) <<
": ";
55 *
static_cast<llvm::raw_string_ostream *
>(data) <<
"\n";
66 llvm::raw_string_ostream messageStream{message};
static std::string diag(const llvm::Value &value)
RAII scope intercepting all diagnostics into a string.
std::string takeMessage()
~CollectDiagnosticsToStringScope()
CollectDiagnosticsToStringScope(MlirContext ctx)
MLIR_CAPI_EXPORTED intptr_t mlirDiagnosticGetNumNotes(MlirDiagnostic diagnostic)
Returns the number of notes attached to the diagnostic.
MLIR_CAPI_EXPORTED void mlirDiagnosticPrint(MlirDiagnostic diagnostic, MlirStringCallback callback, void *userData)
Prints a diagnostic using the provided callback.
MLIR_CAPI_EXPORTED MlirDiagnostic mlirDiagnosticGetNote(MlirDiagnostic diagnostic, intptr_t pos)
Returns pos-th note attached to the diagnostic.
MLIR_CAPI_EXPORTED MlirDiagnosticHandlerID mlirContextAttachDiagnosticHandler(MlirContext context, MlirDiagnosticHandler handler, void *userData, void(*deleteUserData)(void *))
Attaches the diagnostic handler to the context.
MLIR_CAPI_EXPORTED void mlirContextDetachDiagnosticHandler(MlirContext context, MlirDiagnosticHandlerID id)
Detaches an attached diagnostic handler from the context given its identifier.
uint64_t MlirDiagnosticHandlerID
Opaque identifier of a diagnostic handler, useful to detach a handler.
MLIR_CAPI_EXPORTED MlirLocation mlirDiagnosticGetLocation(MlirDiagnostic diagnostic)
Returns the location at which the diagnostic is reported.
MLIR_CAPI_EXPORTED void mlirLocationPrint(MlirLocation location, MlirStringCallback callback, void *userData)
Prints a location by sending chunks of the string representation and forwarding userData tocallback`.
static MlirLogicalResult mlirLogicalResultSuccess(void)
Creates a logical result representing a success.
Include the generated interface declarations.
An opaque reference to a diagnostic, always owned by the diagnostics engine (context).
A logical result value, essentially a boolean with named states.
A pointer to a sized fragment of a string, not necessarily null-terminated.
const char * data
Pointer to the first symbol.
size_t length
Length of the fragment.