MLIR 22.0.0git
mlir::DiagnosticEngine Class Reference

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.
using HandlerID = uint64_t
 A handle to a specific registered handler object.

Public Member Functions

 ~DiagnosticEngine ()
HandlerID registerHandler (HandlerTy handler)
 Register a new handler for diagnostics to the engine.
template<typename FuncTy, typename RetT = decltype(std::declval<FuncTy>()( std::declval<Diagnostic &>()))>
std::enable_if_t< std::is_same< RetT, void >::value, HandlerIDregisterHandler (FuncTy &&handler)
 Set the diagnostic handler with a function that returns void.
void eraseHandler (HandlerID id)
 Erase the registered diagnostic handler with the given identifier.
InFlightDiagnostic emit (Location loc, DiagnosticSeverity severity)
 Create a new inflight diagnostic with the given location and severity.
void emit (Diagnostic &&diag)
 Emit a diagnostic using the registered issue handler if present, or with the default behavior if not.

Friends

class MLIRContextImpl

Detailed Description

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 416 of file Diagnostics.h.

Member Typedef Documentation

◆ HandlerID

A handle to a specific registered handler object.

Definition at line 436 of file Diagnostics.h.

◆ HandlerTy

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 433 of file Diagnostics.h.

Constructor & Destructor Documentation

◆ ~DiagnosticEngine()

DiagnosticEngine::~DiagnosticEngine ( )
default

Member Function Documentation

◆ emit() [1/2]

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 300 of file Diagnostics.cpp.

References diag(), and mlir::Note.

◆ emit() [2/2]

InFlightDiagnostic mlir::DiagnosticEngine::emit ( Location loc,
DiagnosticSeverity severity )
inline

Create a new inflight diagnostic with the given location and severity.

Definition at line 462 of file Diagnostics.h.

References mlir::Note.

◆ eraseHandler()

void DiagnosticEngine::eraseHandler ( HandlerID id)

Erase the registered diagnostic handler with the given identifier.

Definition at line 293 of file Diagnostics.cpp.

◆ registerHandler() [1/2]

template<typename FuncTy, typename RetT = decltype(std::declval<FuncTy>()( std::declval<Diagnostic &>()))>
std::enable_if_t< std::is_same< RetT, void >::value, HandlerID > mlir::DiagnosticEngine::registerHandler ( FuncTy && handler)
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 451 of file Diagnostics.h.

References diag(), registerHandler(), and success().

◆ registerHandler() [2/2]

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 285 of file Diagnostics.cpp.

Referenced by registerHandler().

◆ MLIRContextImpl

friend class MLIRContextImpl
friend

Definition at line 474 of file Diagnostics.h.

References MLIRContextImpl.

Referenced by MLIRContextImpl.


The documentation for this class was generated from the following files: