MLIR 22.0.0git
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

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

Functions

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

Function Documentation

◆ adjustPrintingFlags()

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::appendOp(), and mlir::Diagnostic::operator<<().

◆ emitDiag()

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

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

Return a processable CallSiteLoc from the given location.

Definition at line 398 of file Diagnostics.cpp.

References getCallSiteLoc().

Referenced by mlir::SourceMgrDiagnosticHandler::emitDiagnostic(), and getCallSiteLoc().

◆ getDiagKind()

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

Given a diagnostic kind, returns the LLVM DiagKind.

Definition at line 415 of file Diagnostics.cpp.

References mlir::Error, mlir::Note, mlir::Remark, and mlir::Warning.

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

◆ getDiagKindStr()

StringRef getDiagKindStr ( DiagnosticSeverity kind)
static

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

Definition at line 707 of file Diagnostics.cpp.

References mlir::Error, mlir::Note, mlir::Remark, and mlir::Warning.

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

◆ twineToStrRef()

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<<(), and mlir::Diagnostic::operator<<().