clang  6.0.0svn
Public Member Functions | List of all members
clang::Diagnostic Class Reference

A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) that allows clients to enquire about the currently in-flight diagnostic. More...

#include "clang/Basic/Diagnostic.h"

Public Member Functions

 Diagnostic (const DiagnosticsEngine *DO)
 
 Diagnostic (const DiagnosticsEngine *DO, StringRef storedDiagMessage)
 
const DiagnosticsEnginegetDiags () const
 
unsigned getID () const
 
const SourceLocationgetLocation () const
 
bool hasSourceManager () const
 
SourceManagergetSourceManager () const
 
unsigned getNumArgs () const
 
DiagnosticsEngine::ArgumentKind getArgKind (unsigned Idx) const
 Return the kind of the specified index. More...
 
const std::string & getArgStdStr (unsigned Idx) const
 Return the provided argument string specified by Idx. More...
 
const char * getArgCStr (unsigned Idx) const
 Return the specified C string argument. More...
 
int getArgSInt (unsigned Idx) const
 Return the specified signed integer argument. More...
 
unsigned getArgUInt (unsigned Idx) const
 Return the specified unsigned integer argument. More...
 
const IdentifierInfogetArgIdentifier (unsigned Idx) const
 Return the specified IdentifierInfo argument. More...
 
intptr_t getRawArg (unsigned Idx) const
 Return the specified non-string argument in an opaque form. More...
 
unsigned getNumRanges () const
 Return the number of source ranges associated with this diagnostic. More...
 
const CharSourceRangegetRange (unsigned Idx) const
 
ArrayRef< CharSourceRangegetRanges () const
 Return an array reference for this diagnostic's ranges. More...
 
unsigned getNumFixItHints () const
 
const FixItHintgetFixItHint (unsigned Idx) const
 
ArrayRef< FixItHintgetFixItHints () const
 
void FormatDiagnostic (SmallVectorImpl< char > &OutStr) const
 Format this diagnostic into a string, substituting the formal arguments into the %0 slots. More...
 
void FormatDiagnostic (const char *DiagStr, const char *DiagEnd, SmallVectorImpl< char > &OutStr) const
 Format the given format-string into the output buffer using the arguments stored in this diagnostic. More...
 

Detailed Description

A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) that allows clients to enquire about the currently in-flight diagnostic.

Definition at line 1225 of file Diagnostic.h.

Constructor & Destructor Documentation

◆ Diagnostic() [1/2]

clang::Diagnostic::Diagnostic ( const DiagnosticsEngine DO)
inlineexplicit

Definition at line 1230 of file Diagnostic.h.

◆ Diagnostic() [2/2]

clang::Diagnostic::Diagnostic ( const DiagnosticsEngine DO,
StringRef  storedDiagMessage 
)
inline

Definition at line 1231 of file Diagnostic.h.

Member Function Documentation

◆ FormatDiagnostic() [1/2]

void Diagnostic::FormatDiagnostic ( SmallVectorImpl< char > &  OutStr) const

Format this diagnostic into a string, substituting the formal arguments into the %0 slots.

FormatDiagnostic - Format this diagnostic into a string, substituting the formal arguments into the %0 slots.

The result is appended onto the OutStr array.

The result is appended onto the Str array.

Definition at line 667 of file Diagnostic.cpp.

References Diag().

Referenced by AddRangeLocationAbbrev(), clang::PartialDiagnostic::EmitToString(), getTokenDescForDiagnostic(), clang::TextDiagnosticBuffer::HandleDiagnostic(), clang::TextDiagnosticPrinter::HandleDiagnostic(), clang::LogDiagnosticPrinter::HandleDiagnostic(), HandlePluralModifier(), HandleSelectModifier(), and clang::StoredDiagnostic::StoredDiagnostic().

◆ FormatDiagnostic() [2/2]

void Diagnostic::FormatDiagnostic ( const char *  DiagStr,
const char *  DiagEnd,
SmallVectorImpl< char > &  OutStr 
) const

Format the given format-string into the output buffer using the arguments stored in this diagnostic.

FormattedArgs - Keep track of all of the arguments formatted by ConvertArgToString and pass them into subsequent calls to ConvertArgToString, allowing the implementation to avoid redundancies in obvious cases.

QualTypeVals - Pass a vector of arrays so that QualType names can be compared to see if more information is needed to be printed.

Definition at line 680 of file Diagnostic.cpp.

References clang::DiagnosticsEngine::ak_std_string, and clang::threadSafety::sx::equals().

◆ getArgCStr()

const char* clang::Diagnostic::getArgCStr ( unsigned  Idx) const
inline

Return the specified C string argument.

Precondition
getArgKind(Idx) == DiagnosticsEngine::ak_c_string

Definition at line 1263 of file Diagnostic.h.

References clang::DiagnosticsEngine::ak_c_string.

◆ getArgIdentifier()

const IdentifierInfo* clang::Diagnostic::getArgIdentifier ( unsigned  Idx) const
inline

Return the specified IdentifierInfo argument.

Precondition
getArgKind(Idx) == DiagnosticsEngine::ak_identifierinfo

Definition at line 1287 of file Diagnostic.h.

References clang::DiagnosticsEngine::ak_identifierinfo.

◆ getArgKind()

DiagnosticsEngine::ArgumentKind clang::Diagnostic::getArgKind ( unsigned  Idx) const
inline

Return the kind of the specified index.

Based on the kind of argument, the accessors below can be used to get the value.

Precondition
Idx < getNumArgs()

Definition at line 1248 of file Diagnostic.h.

◆ getArgSInt()

int clang::Diagnostic::getArgSInt ( unsigned  Idx) const
inline

Return the specified signed integer argument.

Precondition
getArgKind(Idx) == DiagnosticsEngine::ak_sint

Definition at line 1271 of file Diagnostic.h.

References clang::DiagnosticsEngine::ak_sint.

◆ getArgStdStr()

const std::string& clang::Diagnostic::getArgStdStr ( unsigned  Idx) const
inline

Return the provided argument string specified by Idx.

Precondition
getArgKind(Idx) == DiagnosticsEngine::ak_std_string

Definition at line 1255 of file Diagnostic.h.

References clang::DiagnosticsEngine::ak_std_string.

◆ getArgUInt()

unsigned clang::Diagnostic::getArgUInt ( unsigned  Idx) const
inline

Return the specified unsigned integer argument.

Precondition
getArgKind(Idx) == DiagnosticsEngine::ak_uint

Definition at line 1279 of file Diagnostic.h.

References clang::DiagnosticsEngine::ak_uint.

◆ getDiags()

const DiagnosticsEngine* clang::Diagnostic::getDiags ( ) const
inline

Definition at line 1234 of file Diagnostic.h.

Referenced by printDiagnosticOptions().

◆ getFixItHint()

const FixItHint& clang::Diagnostic::getFixItHint ( unsigned  Idx) const
inline

Definition at line 1321 of file Diagnostic.h.

Referenced by clang::FixItRewriter::HandleDiagnostic().

◆ getFixItHints()

ArrayRef<FixItHint> clang::Diagnostic::getFixItHints ( ) const
inline

◆ getID()

unsigned clang::Diagnostic::getID ( ) const
inline

◆ getLocation()

const SourceLocation& clang::Diagnostic::getLocation ( ) const
inline

◆ getNumArgs()

unsigned clang::Diagnostic::getNumArgs ( ) const
inline

Definition at line 1240 of file Diagnostic.h.

◆ getNumFixItHints()

unsigned clang::Diagnostic::getNumFixItHints ( ) const
inline

Definition at line 1317 of file Diagnostic.h.

Referenced by clang::FixItRewriter::HandleDiagnostic().

◆ getNumRanges()

unsigned clang::Diagnostic::getNumRanges ( ) const
inline

Return the number of source ranges associated with this diagnostic.

Definition at line 1302 of file Diagnostic.h.

◆ getRange()

const CharSourceRange& clang::Diagnostic::getRange ( unsigned  Idx) const
inline
Precondition
Idx < getNumRanges()

Definition at line 1307 of file Diagnostic.h.

◆ getRanges()

ArrayRef<CharSourceRange> clang::Diagnostic::getRanges ( ) const
inline

Return an array reference for this diagnostic's ranges.

Definition at line 1313 of file Diagnostic.h.

Referenced by AddRangeLocationAbbrev(), clang::TextDiagnosticPrinter::HandleDiagnostic(), and clang::StoredDiagnostic::StoredDiagnostic().

◆ getRawArg()

intptr_t clang::Diagnostic::getRawArg ( unsigned  Idx) const
inline

Return the specified non-string argument in an opaque form.

Precondition
getArgKind(Idx) != DiagnosticsEngine::ak_std_string

Definition at line 1295 of file Diagnostic.h.

References clang::DiagnosticsEngine::ak_std_string.

◆ getSourceManager()

SourceManager& clang::Diagnostic::getSourceManager ( ) const
inline

◆ hasSourceManager()

bool clang::Diagnostic::hasSourceManager ( ) const
inline

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