14#ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_H
15#define LLVM_CLANG_BASIC_DIAGNOSTIC_H
21#include "llvm/ADT/ArrayRef.h"
22#include "llvm/ADT/DenseMap.h"
23#include "llvm/ADT/IntrusiveRefCntPtr.h"
24#include "llvm/ADT/SmallVector.h"
25#include "llvm/ADT/StringRef.h"
26#include "llvm/ADT/iterator_range.h"
27#include "llvm/Support/Compiler.h"
48class DiagnosticBuilder;
49class DiagnosticConsumer;
54class StoredDiagnostic;
257 unsigned char AllExtensionsSilenced = 0;
260 bool FatalsAsError =
false;
263 bool SuppressAllDiagnostics =
false;
266 bool ElideType =
true;
269 bool PrintTemplateTree =
false;
272 bool ShowColors =
false;
282 unsigned NumOverloadsToShow = 32;
285 unsigned ErrorLimit = 0;
288 unsigned TemplateBacktraceLimit = 0;
291 unsigned ConstexprBacktraceLimit = 0;
296 std::unique_ptr<DiagnosticConsumer> Owner;
311 llvm::DenseMap<unsigned, DiagnosticMapping> DiagMap;
317 unsigned IgnoreAllWarnings : 1;
320 unsigned EnableAllWarnings : 1;
323 unsigned WarningsAsErrors : 1;
326 unsigned ErrorsAsFatal : 1;
329 unsigned SuppressSystemWarnings : 1;
335 : IgnoreAllWarnings(
false), EnableAllWarnings(
false),
336 WarningsAsErrors(
false), ErrorsAsFatal(
false),
337 SuppressSystemWarnings(
false) {}
339 using iterator = llvm::DenseMap<unsigned, DiagnosticMapping>::iterator;
340 using const_iterator =
341 llvm::DenseMap<unsigned, DiagnosticMapping>::const_iterator;
344 DiagMap[
Diag] = Info;
348 return DiagMap.lookup(
Diag);
353 const_iterator begin()
const {
return DiagMap.begin(); }
354 const_iterator end()
const {
return DiagMap.end(); }
358 std::list<DiagState> DiagStates;
365 void appendFirst(DiagState *State);
374 bool empty()
const {
return Files.empty(); }
379 FirstDiagState = CurDiagState =
nullptr;
380 CurDiagStateLoc = SourceLocation();
384 LLVM_DUMP_METHOD
void dump(SourceManager &SrcMgr,
385 StringRef DiagName = StringRef())
const;
388 DiagState *getCurDiagState()
const {
return CurDiagState; }
391 SourceLocation getCurDiagStateLoc()
const {
return CurDiagStateLoc; }
394 friend class ASTReader;
395 friend class ASTWriter;
402 struct DiagStatePoint {
406 DiagStatePoint(DiagState *State,
unsigned Offset)
419 unsigned ParentOffset = 0;
423 bool HasLocalTransitions =
false;
429 DiagState *lookup(
unsigned Offset)
const;
433 mutable std::map<FileID, File> Files;
436 DiagState *FirstDiagState;
439 DiagState *CurDiagState;
442 SourceLocation CurDiagStateLoc;
445 File *getFile(SourceManager &SrcMgr, FileID ID)
const;
448 DiagStateMap DiagStatesByLoc;
452 std::vector<DiagState *> DiagStateOnPushStack;
454 DiagState *GetCurDiagState()
const {
455 return DiagStatesByLoc.getCurDiagState();
458 void PushDiagStatePoint(DiagState *State, SourceLocation L);
462 DiagState *GetDiagStateForLoc(SourceLocation Loc)
const {
463 return SourceMgr ? DiagStatesByLoc.lookup(*SourceMgr, Loc)
464 : DiagStatesByLoc.getCurDiagState();
472 bool UncompilableErrorOccurred;
475 bool FatalErrorOccurred;
478 bool UnrecoverableErrorOccurred;
482 unsigned TrapNumErrorsOccurred;
483 unsigned TrapNumUnrecoverableErrorsOccurred;
492 unsigned NumWarnings;
507 using ArgToStringFnTy = void (*)(
509 StringRef Modifier, StringRef Argument,
510 ArrayRef<ArgumentValue> PrevArgs,
511 SmallVectorImpl<char> &Output,
513 ArrayRef<intptr_t> QualTypeVals);
515 void *ArgToStringCookie =
nullptr;
516 ArgToStringFnTy ArgToStringFn;
521 unsigned DelayedDiagID;
524 std::string DelayedDiagArg1;
527 std::string DelayedDiagArg2;
530 std::string DelayedDiagArg3;
537 std::string FlagValue;
541 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts,
542 DiagnosticConsumer *client =
nullptr,
543 bool ShouldOwnClient =
true);
549 LLVM_DUMP_METHOD
void dump()
const;
550 LLVM_DUMP_METHOD
void dump(StringRef DiagName)
const;
563 const DiagState &DS = *GetCurDiagState();
575 std::unique_ptr<DiagnosticConsumer>
takeClient() {
return std::move(Owner); }
580 assert(SourceMgr &&
"SourceManager not set!");
585 assert(DiagStatesByLoc.empty() &&
586 "Leftover diag state from a different SourceManager.");
621 TemplateBacktraceLimit = Limit;
627 return TemplateBacktraceLimit;
633 ConstexprBacktraceLimit = Limit;
639 return ConstexprBacktraceLimit;
646 GetCurDiagState()->IgnoreAllWarnings = Val;
649 return GetCurDiagState()->IgnoreAllWarnings;
657 GetCurDiagState()->EnableAllWarnings = Val;
660 return GetCurDiagState()->EnableAllWarnings;
665 GetCurDiagState()->WarningsAsErrors = Val;
668 return GetCurDiagState()->WarningsAsErrors;
683 GetCurDiagState()->SuppressSystemWarnings = Val;
686 return GetCurDiagState()->SuppressSystemWarnings;
732 return std::numeric_limits<int>::max();
734 return NumOverloadsToShow;
736 llvm_unreachable(
"invalid OverloadsShown kind");
746 NumOverloadsToShow = 4;
758 FatalErrorOccurred =
true;
774 GetCurDiagState()->ExtBehavior = H;
777 return GetCurDiagState()->ExtBehavior;
843 return UncompilableErrorOccurred;
849 return FatalErrorOccurred || UnrecoverableErrorOccurred;
856 this->NumWarnings = NumWarnings;
867 template <
unsigned N>
870 StringRef(FormatString, N - 1));
876 StringRef Modifier, StringRef Argument,
880 ArgToStringFn(Kind, Val, Modifier, Argument, PrevArgs, Output,
881 ArgToStringCookie, QualTypeVals);
886 ArgToStringCookie = Cookie;
892 LastDiagLevel = Other.LastDiagLevel;
897 void Reset(
bool soft =
false);
912 return Diags->getDiagnosticSeverity(DiagID, Loc, *
this) ==
927 return (
Level)Diags->getDiagnosticLevel(DiagID, Loc, *
this);
945 return CurDiagID != std::numeric_limits<unsigned>::max();
974 StringRef Arg2 =
"", StringRef Arg3 =
"");
977 void Clear() { CurDiagID = std::numeric_limits<unsigned>::max(); }
996 void ReportDelayed();
1036 bool ProcessDiag() {
1037 return Diags->ProcessDiag(*
this);
1075 unsigned NumUnrecoverableErrors;
1079 : Diag(Diag) {
reset(); }
1084 return Diag.TrapNumErrorsOccurred > NumErrors;
1090 return Diag.TrapNumUnrecoverableErrorsOccurred > NumUnrecoverableErrors;
1095 NumErrors = Diag.TrapNumErrorsOccurred;
1096 NumUnrecoverableErrors = Diag.TrapNumUnrecoverableErrorsOccurred;
1115 static const unsigned NumCached = 16;
1118 unsigned NumFreeListEntries;
1126 if (NumFreeListEntries == 0)
1131 Result->DiagRanges.clear();
1132 Result->FixItHints.clear();
1138 if (S >= Cached && S <= Cached + NumCached) {
1139 FreeList[NumFreeListEntries++] = S;
1189 "Too many arguments to diagnostic!");
1199 "Too many arguments to diagnostic!");
1229 operator bool()
const {
return true; }
1277 mutable bool IsActive =
false;
1281 mutable bool IsForceEmit =
false;
1288 assert(diagObj &&
"DiagnosticBuilder requires a valid DiagnosticsEngine!");
1290 "DiagnosticBuilder requires a valid DiagnosticStorage!");
1301 IsForceEmit =
false;
1332 DiagObj = D.DiagObj;
1334 IsActive = D.IsActive;
1335 IsForceEmit = D.IsForceEmit;
1340 assert(
isActive() &&
"Clients must not add to cleared diagnostic!");
1349 template <
typename T,
1350 typename = std::enable_if_t<!std::is_lvalue_reference<T>::value>>
1352 assert(
isActive() &&
"Clients must not add to cleared diagnostic!");
1421template <
typename T>
1422inline std::enable_if_t<std::is_same<T, bool>::value,
1423 const StreamingDiagnostic &>
1424operator<<(
const StreamingDiagnostic &DB, T I) {
1442 unsigned long long I) {
1464template <
typename T>
1465inline std::enable_if_t<
1466 std::is_same<std::remove_const_t<T>, DeclContext>::value,
1467 const StreamingDiagnostic &>
1468operator<<(
const StreamingDiagnostic &DB, T *DC) {
1514 const std::optional<SourceRange> &Opt) {
1522 const std::optional<CharSourceRange> &Opt) {
1544 assert(CurDiagID == std::numeric_limits<unsigned>::max() &&
1545 "Multiple diagnostics in flight at once!");
1568 std::optional<StringRef> StoredDiagMessage;
1573 : DiagObj(DO), StoredDiagMessage(storedDiagMessage) {}
1576 unsigned getID()
const {
return DiagObj->CurDiagID; }
1590 assert(Idx <
getNumArgs() &&
"Argument index out of range!");
1599 "invalid argument accessor!");
1607 "invalid argument accessor!");
1608 return reinterpret_cast<const char *
>(
1616 "invalid argument accessor!");
1624 "invalid argument accessor!");
1632 "invalid argument accessor!");
1641 "invalid argument accessor!");
1647 return DiagObj->DiagStorage.
DiagRanges.size();
1652 assert(Idx <
getNumRanges() &&
"Invalid diagnostic range index!");
1662 return DiagObj->DiagStorage.
FixItHints.size();
1694 std::string Message;
1695 std::vector<CharSourceRange> Ranges;
1696 std::vector<FixItHint> FixIts;
1709 explicit operator bool()
const {
return !Message.empty(); }
1736llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
const StoredDiagnostic &);
1796 virtual void anchor();
1816 void clear()
override;
1842 bool ReportDiags =
true);
Defines the Diagnostic IDs-related interfaces.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
Reads an AST files chain containing the contents of a translation unit.
Writes an AST file containing the contents of a translation unit.
Represents a character-granular source range.
static CharSourceRange getCharRange(SourceRange R)
static CharSourceRange getTokenRange(SourceRange R)
A little helper class used to produce diagnostics.
DiagnosticBuilder & operator=(const DiagnosticBuilder &)=delete
const DiagnosticBuilder & setForceEmit() const
Forces the diagnostic to be emitted.
void Clear() const
Clear out the current diagnostic.
void addFlagValue(StringRef V) const
bool isActive() const
Determine whether this diagnostic is still active.
DiagnosticBuilder(const DiagnosticBuilder &D)
Copy constructor.
const DiagnosticBuilder & operator<<(const T &V) const
bool Emit()
Force the diagnostic builder to emit the diagnostic now.
~DiagnosticBuilder()
Emits the diagnostic.
const DiagnosticBuilder & operator<<(T &&V) const
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
virtual ~DiagnosticConsumer()
virtual void EndSourceFile()
Callback to inform the diagnostic client that processing of a source file has ended.
virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info)
Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
unsigned getNumErrors() const
virtual void finish()
Callback to inform the diagnostic client that processing of all source files has ended.
unsigned NumErrors
Number of errors reported.
unsigned getNumWarnings() const
unsigned NumWarnings
Number of warnings reported.
virtual bool IncludeInDiagnosticCounts() const
Indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number...
virtual void BeginSourceFile(const LangOptions &LangOpts, const Preprocessor *PP=nullptr)
Callback to inform the diagnostic client that processing of a source file is beginning.
DiagnosticConsumer()=default
RAII class that determines when any errors have occurred between the time the instance was created an...
void reset()
Set to initial state of "no errors occurred".
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred since this object instance was created.
DiagnosticErrorTrap(DiagnosticsEngine &Diag)
bool hasErrorOccurred() const
Determine whether any errors have occurred since this object instance was created.
Used for handling and querying diagnostic IDs.
Level
The level of the diagnostic, after it has been through mapping.
void setNoWarningAsError(bool Value)
static DiagnosticMapping Make(diag::Severity Severity, bool IsUser, bool IsPragma)
void setNoErrorAsFatal(bool Value)
Options for controlling the compiler diagnostics engine.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
const SourceLocation & getLocation() const
const std::string & getArgStdStr(unsigned Idx) const
Return the provided argument string specified by Idx.
void FormatDiagnostic(SmallVectorImpl< char > &OutStr) const
Format this diagnostic into a string, substituting the formal arguments into the %0 slots.
Diagnostic(const DiagnosticsEngine *DO, StringRef storedDiagMessage)
uint64_t getRawArg(unsigned Idx) const
Return the specified non-string argument in an opaque form.
unsigned getNumFixItHints() const
unsigned getNumRanges() const
Return the number of source ranges associated with this diagnostic.
const char * getArgCStr(unsigned Idx) const
Return the specified C string argument.
const IdentifierInfo * getArgIdentifier(unsigned Idx) const
Return the specified IdentifierInfo argument.
const CharSourceRange & getRange(unsigned Idx) const
SourceManager & getSourceManager() const
ArrayRef< FixItHint > getFixItHints() const
unsigned getNumArgs() const
bool hasSourceManager() const
DiagnosticsEngine::ArgumentKind getArgKind(unsigned Idx) const
Return the kind of the specified index.
int64_t getArgSInt(unsigned Idx) const
Return the specified signed integer argument.
uint64_t getArgUInt(unsigned Idx) const
Return the specified unsigned integer argument.
Diagnostic(const DiagnosticsEngine *DO)
const FixItHint & getFixItHint(unsigned Idx) const
ArrayRef< CharSourceRange > getRanges() const
Return an array reference for this diagnostic's ranges.
const DiagnosticsEngine * getDiags() const
Concrete class used by the front-end to report problems and issues.
void setErrorsAsFatal(bool Val)
When set to true, any error reported is made a fatal error.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie)
bool hasSourceManager() const
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
bool isLastDiagnosticIgnored() const
Determine whether the previous diagnostic was ignored.
bool hasErrorOccurred() const
void overloadCandidatesShown(unsigned N)
Call this after showing N overload candidates.
void setPrintTemplateTree(bool Val)
Set tree printing, to outputting the template difference in a tree format.
void setSuppressSystemWarnings(bool Val)
When set to true mask warnings that come from system headers.
void setNumWarnings(unsigned NumWarnings)
bool getErrorsAsFatal() const
DiagnosticsEngine(const DiagnosticsEngine &)=delete
void setSeverityForAll(diag::Flavor Flavor, diag::Severity Map, SourceLocation Loc=SourceLocation())
Add the specified mapping to all diagnostics of the specified flavor.
void setIgnoreAllWarnings(bool Val)
When set to true, any unmapped warnings are ignored.
bool getSuppressAllDiagnostics() const
bool getIgnoreAllWarnings() const
void setSourceManager(SourceManager *SrcMgr)
void notePriorDiagnosticFrom(const DiagnosticsEngine &Other)
Note that the prior diagnostic was emitted by some other DiagnosticsEngine, and we may be attaching a...
friend void DiagnosticsTestHelper(DiagnosticsEngine &)
void setLastDiagnosticIgnored(bool Ignored)
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed,...
void setExtensionHandlingBehavior(diag::Severity H)
Controls whether otherwise-unmapped extension diagnostics are mapped onto ignore/warning/error.
LLVM_DUMP_METHOD void dump() const
unsigned getNumOverloadCandidatesToShow() const
When a call or operator fails, print out up to this many candidate overloads as suggestions.
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
void setTemplateBacktraceLimit(unsigned Limit)
Specify the maximum number of template instantiation notes to emit along with a given diagnostic.
void DecrementAllExtensionsSilenced()
SourceLocation getCurrentDiagLoc() const
bool hasUnrecoverableErrorOccurred() const
Determine whether any kind of unrecoverable error has occurred.
void setFatalsAsError(bool Val)
When set to true, any fatal error reported is made an error.
StringRef getFlagValue() const
Return the value associated with this diagnostic flag.
diag_mapping_range getDiagnosticMappings() const
Get the current set of diagnostic mappings.
void setErrorLimit(unsigned Limit)
Specify a limit for the number of errors we should emit before giving up.
void setWarningsAsErrors(bool Val)
When set to true, any warnings reported are issued as errors.
bool getEnableAllWarnings() const
bool getPrintTemplateTree()
void setClient(DiagnosticConsumer *client, bool ShouldOwnClient=true)
Set the diagnostic client associated with this diagnostic object.
void Clear()
Clear out the current diagnostic.
void setShowOverloads(OverloadsShown Val)
Specify which overload candidates to show when overload resolution fails.
std::unique_ptr< DiagnosticConsumer > takeClient()
Return the current diagnostic client along with ownership of that client.
llvm::iterator_range< DiagState::const_iterator > diag_mapping_range
SourceManager & getSourceManager() const
bool isDiagnosticInFlight() const
Determine whethere there is already a diagnostic in flight.
void pushMappings(SourceLocation Loc)
Copies the current DiagMappings and pushes the new copy onto the top of the stack.
const DiagnosticConsumer * getClient() const
void setSeverity(diag::kind Diag, diag::Severity Map, SourceLocation Loc)
This allows the client to specify that certain warnings are ignored.
DiagnosticsEngine & operator=(const DiagnosticsEngine &)=delete
unsigned getConstexprBacktraceLimit() const
Retrieve the maximum number of constexpr evaluation notes to emit along with a given diagnostic.
Level
The level of the diagnostic, after it has been through mapping.
void setEnableAllWarnings(bool Val)
When set to true, any unmapped ignored warnings are no longer ignored.
friend class DiagnosticBuilder
DiagnosticConsumer * getClient()
bool hasFatalErrorOccurred() const
std::pair< ArgumentKind, intptr_t > ArgumentValue
Represents on argument value, which is a union discriminated by ArgumentKind, with a value.
@ ak_nameddecl
NamedDecl *.
@ ak_declcontext
DeclContext *.
@ ak_addrspace
address space
@ ak_identifierinfo
IdentifierInfo.
@ ak_qualtype_pair
pair<QualType, QualType>
@ ak_c_string
const char *
@ ak_declarationname
DeclarationName.
@ ak_tokenkind
enum TokenKind : unsigned
@ ak_std_string
std::string
@ ak_nestednamespec
NestedNameSpecifier *.
unsigned getNumErrors() const
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool hasAllExtensionsSilenced()
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
bool ownsClient() const
Determine whether this DiagnosticsEngine object own its client.
DiagnosticsEngine(IntrusiveRefCntPtr< DiagnosticIDs > Diags, IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, DiagnosticConsumer *client=nullptr, bool ShouldOwnClient=true)
bool EmitCurrentDiagnostic(bool Force=false)
Emit the current diagnostic and clear the diagnostic state.
OverloadsShown getShowOverloads() const
void setConstexprBacktraceLimit(unsigned Limit)
Specify the maximum number of constexpr evaluation notes to emit along with a given diagnostic.
bool setDiagnosticGroupErrorAsFatal(StringRef Group, bool Enabled)
Set the error-as-fatal flag for the given diagnostic group.
bool getSuppressSystemWarnings() const
bool getFatalsAsError() const
void setShowColors(bool Val)
Set color printing, so the type diffing will inject color markers into the output.
bool setDiagnosticGroupWarningAsError(StringRef Group, bool Enabled)
Set the warning-as-error flag for the given diagnostic group.
bool getWarningsAsErrors() const
void IncrementAllExtensionsSilenced()
Counter bumped when an extension block is/ encountered.
void ConvertArgToString(ArgumentKind Kind, intptr_t Val, StringRef Modifier, StringRef Argument, ArrayRef< ArgumentValue > PrevArgs, SmallVectorImpl< char > &Output, ArrayRef< intptr_t > QualTypeVals) const
Converts a diagnostic argument (as an intptr_t) into the string that represents it.
void SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1="", StringRef Arg2="", StringRef Arg3="")
Set the "delayed" diagnostic that will be emitted once the current diagnostic completes.
diag::Severity getExtensionHandlingBehavior() const
void setSuppressAllDiagnostics(bool Val)
Suppress all diagnostics, to silence the front end when we know that we don't want any more diagnosti...
unsigned getTemplateBacktraceLimit() const
Retrieve the maximum number of template instantiation notes to emit along with a given diagnostic.
bool setSeverityForGroup(diag::Flavor Flavor, StringRef Group, diag::Severity Map, SourceLocation Loc=SourceLocation())
Change an entire diagnostic group (e.g.
bool hasUncompilableErrorOccurred() const
Errors that actually prevent compilation, not those that are upgraded from a warning by -Werror.
void setElideType(bool Val)
Set type eliding, to skip outputting same types occurring in template types.
unsigned getCurrentDiagID() const
bool popMappings(SourceLocation Loc)
Pops the current DiagMappings off the top of the stack, causing the new top of the stack to be the ac...
unsigned getNumWarnings() const
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
void Reset(bool soft=false)
Reset the state of the diagnostic object to its initial configuration.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location.
static FixItHint CreateRemoval(SourceRange RemoveRange)
FixItHint()=default
Empty code modification hint, indicating that no code modification is known.
bool BeforePreviousInsertions
CharSourceRange RemoveRange
Code that should be replaced to correct the error.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateReplacement(SourceRange RemoveRange, StringRef Code)
CharSourceRange InsertFromRange
Code in the specific range that should be inserted in the insertion location.
std::string CodeToInsert
The actual code to insert at the insertion location, as a string.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Diagnostic consumer that forwards diagnostics along to an existing, already-initialized diagnostic co...
bool IncludeInDiagnosticCounts() const override
Indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number...
~ForwardingDiagnosticConsumer() override
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) override
Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
ForwardingDiagnosticConsumer(DiagnosticConsumer &Target)
A SourceLocation and its associated SourceManager.
One of these records is kept for each identifier that is lexed.
A diagnostic client that ignores all diagnostics.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Sema - This implements semantic analysis and AST building for C.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
Represents a diagnostic in a form that can be retained until its corresponding source manager is dest...
void setLocation(FullSourceLoc Loc)
unsigned range_size() const
ArrayRef< FixItHint > getFixIts() const
range_iterator range_begin() const
StoredDiagnostic()=default
ArrayRef< CharSourceRange > getRanges() const
unsigned fixit_size() const
DiagnosticsEngine::Level getLevel() const
fixit_iterator fixit_begin() const
const FullSourceLoc & getLocation() const
std::vector< FixItHint >::const_iterator fixit_iterator
range_iterator range_end() const
std::vector< CharSourceRange >::const_iterator range_iterator
StringRef getMessage() const
fixit_iterator fixit_end() const
An allocator for DiagnosticStorage objects, which uses a small cache to objects, used to reduce mallo...
void Deallocate(DiagnosticStorage *S)
Free the given storage object.
DiagnosticStorage * Allocate()
Allocate new storage.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
StreamingDiagnostic(StreamingDiagnostic &&Diag)=default
DiagStorageAllocator * Allocator
Allocator used to allocate storage for this diagnostic.
StreamingDiagnostic()=default
StreamingDiagnostic(DiagStorageAllocator &Alloc)
Construct with a storage allocator which will manage the storage.
StreamingDiagnostic(DiagnosticStorage *Storage)
Construct with an external storage not owned by itself.
DiagnosticStorage * DiagStorage
void AddString(StringRef V) const
StreamingDiagnostic(const StreamingDiagnostic &Diag)=default
void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const
void AddSourceRange(const CharSourceRange &R) const
DiagnosticStorage * getStorage() const
Retrieve storage for this particular diagnostic.
void AddFixItHint(const FixItHint &Hint) const
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing),...
@ Ignored
Do not present this diagnostic, ignore it.
Flavor
Flavors of diagnostics we can emit.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts, bool ReportDiags=true)
ProcessWarningOptions - Initialize the diagnostic client and process the warning options specified on...
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
@ Ovl_All
Show all overloads.
@ Ovl_Best
Show just the "best" overload candidates.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
@ Result
The result type of a method or function.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
const char ToggleHighlight
Special character that the diagnostic printer will use to toggle the bold attribute.
YAML serialization mapping.
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type,...
AddFlagValue(StringRef V)
unsigned char DiagArgumentsKind[MaxArguments]
Specifies for each argument whether it is in DiagArgumentsStr or in DiagArguments.
@ MaxArguments
The maximum number of arguments we can hold.
SmallVector< CharSourceRange, 8 > DiagRanges
The list of ranges added to this diagnostic.
unsigned char NumDiagArgs
The number of entries in Arguments.
SmallVector< FixItHint, 6 > FixItHints
If valid, provides a hint with some code to insert, remove, or modify at a particular position.
std::string DiagArgumentsStr[MaxArguments]
The values for the various substitution positions that have string arguments.
uint64_t DiagArgumentsVal[MaxArguments]
The values for the various substitution positions.
DiagnosticStorage()=default
unsigned TemplateDiffUsed