MLIR  19.0.0git
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mlir::SourceMgrDiagnosticHandler Class Reference

This class is a utility diagnostic handler for use with llvm::SourceMgr. More...

#include "mlir/IR/Diagnostics.h"

+ Inheritance diagram for mlir::SourceMgrDiagnosticHandler:

Public Types

using ShouldShowLocFn = llvm::unique_function< bool(Location)>
 This type represents a functor used to filter out locations when printing a diagnostic. More...
 

Public Member Functions

 SourceMgrDiagnosticHandler (llvm::SourceMgr &mgr, MLIRContext *ctx, raw_ostream &os, ShouldShowLocFn &&shouldShowLocFn={})
 
 SourceMgrDiagnosticHandler (llvm::SourceMgr &mgr, MLIRContext *ctx, ShouldShowLocFn &&shouldShowLocFn={})
 
 ~SourceMgrDiagnosticHandler ()
 
void emitDiagnostic (Location loc, Twine message, DiagnosticSeverity kind, bool displaySourceLine=true)
 Emit the given diagnostic information with the held source manager. More...
 
- Public Member Functions inherited from mlir::ScopedDiagnosticHandler
 ScopedDiagnosticHandler (MLIRContext *ctx)
 
template<typename FuncTy >
 ScopedDiagnosticHandler (MLIRContext *ctx, FuncTy &&handler)
 
 ~ScopedDiagnosticHandler ()
 

Protected Member Functions

void emitDiagnostic (Diagnostic &diag)
 Emit the given diagnostic with the held source manager. More...
 
const llvm::MemoryBuffer * getBufferForFile (StringRef filename)
 Get a memory buffer for the given file, or nullptr if no file is available. More...
 
- Protected Member Functions inherited from mlir::ScopedDiagnosticHandler
template<typename FuncTy >
void setHandler (FuncTy &&handler)
 Set the handler to manage via RAII. More...
 

Protected Attributes

llvm::SourceMgr & mgr
 The source manager that we are wrapping. More...
 
raw_ostream & os
 The output stream to use when printing diagnostics. More...
 
ShouldShowLocFn shouldShowLocFn
 A functor used when determining if a location for a diagnostic should be shown. More...
 

Detailed Description

This class is a utility diagnostic handler for use with llvm::SourceMgr.

Definition at line 553 of file Diagnostics.h.

Member Typedef Documentation

◆ ShouldShowLocFn

using mlir::SourceMgrDiagnosticHandler::ShouldShowLocFn = llvm::unique_function<bool(Location)>

This type represents a functor used to filter out locations when printing a diagnostic.

It should return true if the provided location is okay to display, false otherwise. If all locations in a diagnostic are filtered out, the first location is used as the sole location. When deciding whether or not to filter a location, this function should not recurse into any nested location. This recursion is handled automatically by the caller.

Definition at line 562 of file Diagnostics.h.

Constructor & Destructor Documentation

◆ SourceMgrDiagnosticHandler() [1/2]

SourceMgrDiagnosticHandler::SourceMgrDiagnosticHandler ( llvm::SourceMgr &  mgr,
MLIRContext ctx,
raw_ostream &  os,
ShouldShowLocFn &&  shouldShowLocFn = {} 
)

◆ SourceMgrDiagnosticHandler() [2/2]

SourceMgrDiagnosticHandler::SourceMgrDiagnosticHandler ( llvm::SourceMgr &  mgr,
MLIRContext ctx,
ShouldShowLocFn &&  shouldShowLocFn = {} 
)

Definition at line 434 of file Diagnostics.cpp.

◆ ~SourceMgrDiagnosticHandler()

SourceMgrDiagnosticHandler::~SourceMgrDiagnosticHandler ( )
default

Member Function Documentation

◆ emitDiagnostic() [1/2]

void SourceMgrDiagnosticHandler::emitDiagnostic ( Diagnostic diag)
protected

Emit the given diagnostic with the held source manager.

Definition at line 477 of file Diagnostics.cpp.

References diag(), emitDiagnostic(), getCallSiteLoc(), and mlir::Note.

◆ emitDiagnostic() [2/2]

void SourceMgrDiagnosticHandler::emitDiagnostic ( Location  loc,
Twine  message,
DiagnosticSeverity  kind,
bool  displaySourceLine = true 
)

Emit the given diagnostic information with the held source manager.

Definition at line 441 of file Diagnostics.cpp.

Referenced by emitDiagnostic(), and SourceMgrDiagnosticHandler().

◆ getBufferForFile()

const llvm::MemoryBuffer * SourceMgrDiagnosticHandler::getBufferForFile ( StringRef  filename)
protected

Get a memory buffer for the given file, or nullptr if no file is available.

Get a memory buffer for the given file, or nullptr if one is not found.

Definition at line 524 of file Diagnostics.cpp.

References mgr.

Member Data Documentation

◆ mgr

llvm::SourceMgr& mlir::SourceMgrDiagnosticHandler::mgr
protected

◆ os

raw_ostream& mlir::SourceMgrDiagnosticHandler::os
protected

The output stream to use when printing diagnostics.

Definition at line 587 of file Diagnostics.h.

Referenced by mlir::SourceMgrDiagnosticVerifierHandler::verify().

◆ shouldShowLocFn

ShouldShowLocFn mlir::SourceMgrDiagnosticHandler::shouldShowLocFn
protected

A functor used when determining if a location for a diagnostic should be shown.

If null, all locations should be shown.

Definition at line 591 of file Diagnostics.h.


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