MLIR  20.0.0git
Classes | Namespaces | Functions
Diagnostics.cpp File Reference
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/Types.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>

Go to the source code of this file.

Classes

struct  mlir::detail::DiagnosticEngineImpl
 
struct  mlir::detail::SourceMgrDiagnosticHandlerImpl
 
struct  mlir::detail::ExpectedDiag
 This class represents an expected output diagnostic. More...
 
struct  mlir::detail::SourceMgrDiagnosticVerifierHandlerImpl
 
struct  mlir::detail::ParallelDiagnosticHandlerImpl
 
struct  mlir::detail::ParallelDiagnosticHandlerImpl::ThreadDiagnostic
 

Namespaces

 mlir
 Include the generated interface declarations.
 
 mlir::detail
 AttrTypeReplacer.
 

Functions

static StringRef twineToStrRef (const Twine &val, std::vector< std::unique_ptr< char[]>> &strings)
 Convert a Twine to a StringRef. More...
 
static OpPrintingFlags adjustPrintingFlags (OpPrintingFlags flags, DiagnosticSeverity severity)
 Adjusts operation printing flags used in diagnostics for the given severity level. More...
 
static InFlightDiagnostic emitDiag (Location location, DiagnosticSeverity severity, const Twine &message)
 Helper function used to emit a diagnostic with an optionally empty twine message. More...
 
static std::optional< CallSiteLoc > getCallSiteLoc (Location loc)
 Return a processable CallSiteLoc from the given location. More...
 
static llvm::SourceMgr::DiagKind getDiagKind (DiagnosticSeverity kind)
 Given a diagnostic kind, returns the LLVM DiagKind. More...
 
static StringRef getDiagKindStr (DiagnosticSeverity kind)
 Given a diagnostic kind, return a human readable string for it. More...
 

Function Documentation

◆ adjustPrintingFlags()

static OpPrintingFlags adjustPrintingFlags ( OpPrintingFlags  flags,
DiagnosticSeverity  severity 
)
static

Adjusts operation printing flags used in diagnostics for the given severity level.

Definition at line 127 of file Diagnostics.cpp.

References mlir::OpPrintingFlags::elideLargeElementsAttrs(), mlir::Error, mlir::OpPrintingFlags::printGenericOpForm(), and mlir::OpPrintingFlags::useLocalScope().

Referenced by mlir::Diagnostic::operator<<().

◆ emitDiag()

static InFlightDiagnostic emitDiag ( Location  location,
DiagnosticSeverity  severity,
const Twine &  message 
)
static

Helper function used to emit a diagnostic with an optionally empty twine message.

If the message is empty, then it is not inserted into the diagnostic.

Definition at line 306 of file Diagnostics.cpp.

References diag(), mlir::Attribute::getContext(), mlir::MLIRContext::getDiagEngine(), and mlir::MLIRContext::shouldPrintStackTraceOnDiagnostic().

Referenced by mlir::transform::detail::checkApplyToOne(), mlir::emitError(), mlir::emitRemark(), and mlir::emitWarning().

◆ getCallSiteLoc()

static std::optional<CallSiteLoc> getCallSiteLoc ( Location  loc)
static

Return a processable CallSiteLoc from the given location.

Definition at line 394 of file Diagnostics.cpp.

Referenced by mlir::SourceMgrDiagnosticHandler::emitDiagnostic().

◆ getDiagKind()

static llvm::SourceMgr::DiagKind getDiagKind ( DiagnosticSeverity  kind)
static

Given a diagnostic kind, returns the LLVM DiagKind.

Definition at line 411 of file Diagnostics.cpp.

◆ getDiagKindStr()

static StringRef getDiagKindStr ( DiagnosticSeverity  kind)
static

Given a diagnostic kind, return a human readable string for it.

Definition at line 686 of file Diagnostics.cpp.

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

◆ twineToStrRef()

static StringRef twineToStrRef ( const Twine &  val,
std::vector< std::unique_ptr< char[]>> &  strings 
)
static

Convert a Twine to a StringRef.

Memory used for generating the StringRef is stored in 'strings'.

Definition at line 87 of file Diagnostics.cpp.

Referenced by mlir::Diagnostic::operator<<().