MLIR  15.0.0git
Public Types | Public Member Functions | List of all members
mlir::Diagnostic Class Reference

This class contains all of the information necessary to report a diagnostic to the DiagnosticEngine. More...

#include "mlir/IR/Diagnostics.h"

Public Types

using note_iterator = llvm::pointee_iterator< NoteVector::iterator >
 
using const_note_iterator = llvm::pointee_iterator< NoteVector::const_iterator >
 

Public Member Functions

 Diagnostic (Location loc, DiagnosticSeverity severity)
 
 Diagnostic (Diagnostic &&)=default
 
Diagnosticoperator= (Diagnostic &&)=default
 
DiagnosticSeverity getSeverity () const
 Returns the severity of this diagnostic. More...
 
Location getLocation () const
 Returns the source location for this diagnostic. More...
 
MutableArrayRef< DiagnosticArgumentgetArguments ()
 Returns the current list of diagnostic arguments. More...
 
ArrayRef< DiagnosticArgumentgetArguments () const
 
template<typename Arg >
std::enable_if< !std::is_convertible< Arg, StringRef >::value &&std::is_constructible< DiagnosticArgument, Arg >::value, Diagnostic & >::type operator<< (Arg &&val)
 Stream operator for inserting new diagnostic arguments. More...
 
Diagnosticoperator<< (StringAttr val)
 
Diagnosticoperator<< (const char *val)
 Stream in a string literal. More...
 
Diagnosticoperator<< (char val)
 Stream in a Twine argument. More...
 
Diagnosticoperator<< (const Twine &val)
 
Diagnosticoperator<< (Twine &&val)
 
Diagnosticoperator<< (OperationName val)
 Stream in an OperationName. More...
 
Diagnosticoperator<< (Operation &val)
 Stream in an Operation. More...
 
Diagnosticoperator<< (Operation *val)
 
DiagnosticappendOp (Operation &val, const OpPrintingFlags &flags)
 Append an operation with the given printing flags. More...
 
Diagnosticoperator<< (Value val)
 Stream in a Value. More...
 
template<typename T , typename ValueT = llvm::detail::ValueOfRange<T>>
std::enable_if_t<!std::is_constructible< DiagnosticArgument, T >::value, Diagnostic & > operator<< (T &&range)
 Stream in a range. More...
 
template<typename T >
DiagnosticappendRange (const T &c, const char *delim=", ")
 Append a range to the diagnostic. More...
 
template<typename Arg1 , typename Arg2 , typename... Args>
Diagnosticappend (Arg1 &&arg1, Arg2 &&arg2, Args &&... args)
 Append arguments to the diagnostic. More...
 
template<typename Arg >
Diagnosticappend (Arg &&arg)
 Append one argument to the diagnostic. More...
 
void print (raw_ostream &os) const
 Outputs this diagnostic to a stream. More...
 
std::string str () const
 Converts the diagnostic to a string. More...
 
DiagnosticattachNote (Optional< Location > noteLoc=llvm::None)
 Attaches a note to this diagnostic. More...
 
iterator_range< note_iteratorgetNotes ()
 Returns the notes held by this diagnostic. More...
 
iterator_range< const_note_iteratorgetNotes () const
 
 operator LogicalResult () const
 Allow a diagnostic to be converted to 'failure'. More...
 
 operator ParseResult () const
 Allow a diagnostic to be converted to 'failure'. More...
 
template<typename T >
 operator FailureOr< T > () const
 Allow a diagnostic to be converted to FailureOr<T>. More...
 

Detailed Description

This class contains all of the information necessary to report a diagnostic to the DiagnosticEngine.

It should generally not be constructed directly, and instead used transitively via InFlightDiagnostic.

Definition at line 157 of file Diagnostics.h.

Member Typedef Documentation

◆ const_note_iterator

using mlir::Diagnostic::const_note_iterator = llvm::pointee_iterator<NoteVector::const_iterator>

Definition at line 255 of file Diagnostics.h.

◆ note_iterator

using mlir::Diagnostic::note_iterator = llvm::pointee_iterator<NoteVector::iterator>

Definition at line 253 of file Diagnostics.h.

Constructor & Destructor Documentation

◆ Diagnostic() [1/2]

mlir::Diagnostic::Diagnostic ( Location  loc,
DiagnosticSeverity  severity 
)
inline

Definition at line 161 of file Diagnostics.h.

◆ Diagnostic() [2/2]

mlir::Diagnostic::Diagnostic ( Diagnostic &&  )
default

Member Function Documentation

◆ append() [1/2]

template<typename Arg1 , typename Arg2 , typename... Args>
Diagnostic& mlir::Diagnostic::append ( Arg1 &&  arg1,
Arg2 &&  arg2,
Args &&...  args 
)
inline

Append arguments to the diagnostic.

Definition at line 232 of file Diagnostics.h.

Referenced by mlir::Operation::emitError().

◆ append() [2/2]

template<typename Arg >
Diagnostic& mlir::Diagnostic::append ( Arg &&  arg)
inline

Append one argument to the diagnostic.

Definition at line 237 of file Diagnostics.h.

References print().

◆ appendOp()

Diagnostic & Diagnostic::appendOp ( Operation val,
const OpPrintingFlags flags 
)

Append an operation with the given printing flags.

Definition at line 139 of file Diagnostics.cpp.

References adjustPrintingFlags(), and mlir::Operation::print().

Referenced by mlir::Operation::emitError().

◆ appendRange()

template<typename T >
Diagnostic& mlir::Diagnostic::appendRange ( const T &  c,
const char *  delim = ", " 
)
inline

Append a range to the diagnostic.

The default delimiter between elements is ','.

Definition at line 224 of file Diagnostics.h.

◆ attachNote()

Diagnostic & Diagnostic::attachNote ( Optional< Location noteLoc = llvm::None)

Attaches a note to this diagnostic.

A new location may be optionally provided, if not, then the location defaults to the one specified for this diagnostic. Notes may not be attached to other notes.

Append and return a new note.

Definition at line 171 of file Diagnostics.cpp.

References mlir::Note.

◆ getArguments() [1/2]

MutableArrayRef<DiagnosticArgument> mlir::Diagnostic::getArguments ( )
inline

Returns the current list of diagnostic arguments.

Definition at line 173 of file Diagnostics.h.

◆ getArguments() [2/2]

ArrayRef<DiagnosticArgument> mlir::Diagnostic::getArguments ( ) const
inline

Definition at line 174 of file Diagnostics.h.

References value.

◆ getLocation()

Location mlir::Diagnostic::getLocation ( ) const
inline

Returns the source location for this diagnostic.

Definition at line 170 of file Diagnostics.h.

Referenced by mlir::SourceMgrDiagnosticHandler::emitDiagnostic(), getLspDiagnoticFromDiag(), and mlir::detail::ParallelDiagnosticHandlerImpl::print().

◆ getNotes() [1/2]

iterator_range<note_iterator> mlir::Diagnostic::getNotes ( )
inline

◆ getNotes() [2/2]

iterator_range<const_note_iterator> mlir::Diagnostic::getNotes ( ) const
inline

Definition at line 261 of file Diagnostics.h.

◆ getSeverity()

DiagnosticSeverity mlir::Diagnostic::getSeverity ( ) const
inline

Returns the severity of this diagnostic.

Definition at line 167 of file Diagnostics.h.

Referenced by mlir::SourceMgrDiagnosticHandler::emitDiagnostic(), getLspDiagnoticFromDiag(), and mlir::detail::ParallelDiagnosticHandlerImpl::print().

◆ operator FailureOr< T >()

template<typename T >
mlir::Diagnostic::operator FailureOr< T > ( ) const
inline

Allow a diagnostic to be converted to FailureOr<T>.

Always results in 'failure' because this cast cannot possibly return an object of 'T'.

Definition at line 274 of file Diagnostics.h.

References mlir::failure().

◆ operator LogicalResult()

Diagnostic::operator LogicalResult ( ) const

Allow a diagnostic to be converted to 'failure'.

Definition at line 187 of file Diagnostics.cpp.

References mlir::failure().

◆ operator ParseResult()

mlir::Diagnostic::operator ParseResult ( ) const
inline

Allow a diagnostic to be converted to 'failure'.

Definition at line 269 of file Diagnostics.h.

◆ operator<<() [1/11]

template<typename Arg >
std::enable_if< !std::is_convertible<Arg, StringRef>::value && std::is_constructible<DiagnosticArgument, Arg>::value, Diagnostic &>::type mlir::Diagnostic::operator<< ( Arg &&  val)
inline

Stream operator for inserting new diagnostic arguments.

Definition at line 182 of file Diagnostics.h.

References operator<<().

◆ operator<<() [2/11]

Diagnostic & Diagnostic::operator<< ( StringAttr  val)

Definition at line 111 of file Diagnostics.cpp.

References mlir::DiagnosticArgument::DiagnosticArgument().

◆ operator<<() [3/11]

Diagnostic& mlir::Diagnostic::operator<< ( const char *  val)
inline

Stream in a string literal.

Definition at line 189 of file Diagnostics.h.

References operator<<().

◆ operator<<() [4/11]

Diagnostic & Diagnostic::operator<< ( char  val)

Stream in a Twine argument.

Definition at line 101 of file Diagnostics.cpp.

◆ operator<<() [5/11]

Diagnostic & Diagnostic::operator<< ( const Twine &  val)

◆ operator<<() [6/11]

Diagnostic & Diagnostic::operator<< ( Twine &&  val)

◆ operator<<() [7/11]

Diagnostic & Diagnostic::operator<< ( OperationName  val)

◆ operator<<() [8/11]

Diagnostic & Diagnostic::operator<< ( Operation val)

Stream in an Operation.

Definition at line 136 of file Diagnostics.cpp.

◆ operator<<() [9/11]

Diagnostic& mlir::Diagnostic::operator<< ( Operation val)
inline

Definition at line 204 of file Diagnostics.h.

References operator<<(), and value.

◆ operator<<() [10/11]

Diagnostic & Diagnostic::operator<< ( Value  val)

Stream in a Value.

Definition at line 147 of file Diagnostics.cpp.

References adjustPrintingFlags(), and mlir::Value::print().

◆ operator<<() [11/11]

template<typename T , typename ValueT = llvm::detail::ValueOfRange<T>>
std::enable_if_t<!std::is_constructible<DiagnosticArgument, T>::value, Diagnostic &> mlir::Diagnostic::operator<< ( T &&  range)
inline

Stream in a range.

Definition at line 217 of file Diagnostics.h.

◆ operator=()

Diagnostic& mlir::Diagnostic::operator= ( Diagnostic &&  )
default

◆ print()

void Diagnostic::print ( raw_ostream &  os) const

◆ str()

std::string Diagnostic::str ( ) const

Converts the diagnostic to a string.

Convert the diagnostic to a string.

Definition at line 161 of file Diagnostics.cpp.

References mlir::DiagnosticArgument::print().

Referenced by mlir::SourceMgrDiagnosticHandler::emitDiagnostic(), getLspDiagnoticFromDiag(), and mlir::detail::ConversionPatternRewriterImpl::notifyMatchFailure().


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