MLIR
20.0.0git
|
This class is the main interface for diagnostics. More...
#include "mlir/IR/Diagnostics.h"
Public Types | |
using | HandlerTy = llvm::unique_function< LogicalResult(Diagnostic &)> |
The handler type for MLIR diagnostics. More... | |
using | HandlerID = uint64_t |
A handle to a specific registered handler object. More... | |
Public Member Functions | |
~DiagnosticEngine () | |
HandlerID | registerHandler (HandlerTy handler) |
Register a new handler for diagnostics to the engine. More... | |
template<typename FuncTy , typename RetT = decltype(std::declval<FuncTy>()( std::declval<Diagnostic &>()))> | |
std::enable_if_t< std::is_same< RetT, void >::value, HandlerID > | registerHandler (FuncTy &&handler) |
Set the diagnostic handler with a function that returns void. More... | |
void | eraseHandler (HandlerID id) |
Erase the registered diagnostic handler with the given identifier. More... | |
InFlightDiagnostic | emit (Location loc, DiagnosticSeverity severity) |
Create a new inflight diagnostic with the given location and severity. More... | |
void | emit (Diagnostic &&diag) |
Emit a diagnostic using the registered issue handler if present, or with the default behavior if not. More... | |
Friends | |
class | MLIRContextImpl |
This class is the main interface for diagnostics.
The DiagnosticEngine manages the registration of diagnostic handlers as well as the core API for diagnostic emission. This class should not be constructed directly, but instead interfaced with via an MLIRContext instance.
Definition at line 414 of file Diagnostics.h.
using mlir::DiagnosticEngine::HandlerID = uint64_t |
A handle to a specific registered handler object.
Definition at line 434 of file Diagnostics.h.
using mlir::DiagnosticEngine::HandlerTy = llvm::unique_function<LogicalResult(Diagnostic &)> |
The handler type for MLIR diagnostics.
This function takes a diagnostic as input, and returns success if the handler has fully processed this diagnostic. Returns failure otherwise.
Definition at line 431 of file Diagnostics.h.
|
default |
void DiagnosticEngine::emit | ( | Diagnostic && | diag | ) |
Emit a diagnostic using the registered issue handler if present, or with the default behavior if not.
The diagnostic instance is consumed in the process.
Definition at line 296 of file Diagnostics.cpp.
References diag(), and mlir::Note.
|
inline |
Create a new inflight diagnostic with the given location and severity.
Definition at line 460 of file Diagnostics.h.
References mlir::Note.
Referenced by mlir::InFlightDiagnostic::report().
void DiagnosticEngine::eraseHandler | ( | HandlerID | id | ) |
Erase the registered diagnostic handler with the given identifier.
Definition at line 289 of file Diagnostics.cpp.
Referenced by mlir::ScopedDiagnosticHandler::setHandler(), and mlir::detail::ParallelDiagnosticHandlerImpl::~ParallelDiagnosticHandlerImpl().
|
inline |
Set the diagnostic handler with a function that returns void.
This is a convenient wrapper for handlers that always completely process the given diagnostic.
Definition at line 449 of file Diagnostics.h.
References diag(), and registerHandler().
auto DiagnosticEngine::registerHandler | ( | HandlerTy | handler | ) |
Register a new handler for diagnostics to the engine.
Diagnostics are process by handlers in stack-like order, meaning that the last added handlers will process diagnostics first. This function returns a unique identifier for the registered handler, which can be used to unregister this handler at a later time.
This function returns a unique identifier for the registered handler, which can be used to unregister this handler at a later time.
Definition at line 281 of file Diagnostics.cpp.
Referenced by mlir::detail::ParallelDiagnosticHandlerImpl::ParallelDiagnosticHandlerImpl(), and registerHandler().
|
friend |
Definition at line 472 of file Diagnostics.h.