MLIR  20.0.0git
Public Types | Public Member Functions | Friends | List of all members
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. 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, HandlerIDregisterHandler (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
 

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

Member Typedef Documentation

◆ HandlerID

A handle to a specific registered handler object.

Definition at line 434 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 431 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 296 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 460 of file Diagnostics.h.

References mlir::Note.

Referenced by mlir::InFlightDiagnostic::report().

◆ eraseHandler()

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().

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

References diag(), and registerHandler().

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

Referenced by mlir::detail::ParallelDiagnosticHandlerImpl::ParallelDiagnosticHandlerImpl(), and registerHandler().

Friends And Related Function Documentation

◆ MLIRContextImpl

friend class MLIRContextImpl
friend

Definition at line 472 of file Diagnostics.h.


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