14#ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_H
15#define LLVM_CLANG_BASIC_DIAGNOSTIC_H
22#include "llvm/ADT/ArrayRef.h"
23#include "llvm/ADT/DenseMap.h"
24#include "llvm/ADT/FunctionExtras.h"
25#include "llvm/ADT/IntrusiveRefCntPtr.h"
26#include "llvm/ADT/SmallString.h"
27#include "llvm/ADT/SmallVector.h"
28#include "llvm/ADT/StringExtras.h"
29#include "llvm/ADT/iterator_range.h"
30#include "llvm/Support/Compiler.h"
57class DiagnosticConsumer;
62class StoredDiagnostic;
194 static const unsigned NumCached = 16;
197 unsigned NumFreeListEntries;
205 if (NumFreeListEntries == 0)
210 Result->DiagRanges.clear();
211 Result->FixItHints.clear();
217 if (S >= Cached && S <= Cached + NumCached) {
218 FreeList[NumFreeListEntries++] = S;
305 unsigned char AllExtensionsSilenced = 0;
308 bool FatalsAsError =
false;
311 bool SuppressAllDiagnostics =
false;
316 bool ForceSystemWarnings =
false;
319 bool ElideType =
true;
322 bool PrintTemplateTree =
false;
325 bool ShowColors =
false;
335 unsigned NumOverloadsToShow = 32;
338 unsigned ErrorLimit = 0;
341 unsigned TemplateBacktraceLimit = 0;
344 unsigned ConstexprBacktraceLimit = 0;
349 std::unique_ptr<DiagnosticConsumer> Owner;
364 llvm::DenseMap<unsigned, DiagnosticMapping> DiagMap;
370 LLVM_PREFERRED_TYPE(
bool)
371 unsigned IgnoreAllWarnings : 1;
374 LLVM_PREFERRED_TYPE(
bool)
375 unsigned EnableAllWarnings : 1;
378 LLVM_PREFERRED_TYPE(
bool)
379 unsigned WarningsAsErrors : 1;
382 LLVM_PREFERRED_TYPE(
bool)
383 unsigned ErrorsAsFatal : 1;
386 LLVM_PREFERRED_TYPE(
bool)
387 unsigned SuppressSystemWarnings : 1;
395 : IgnoreAllWarnings(
false), EnableAllWarnings(
false),
396 WarningsAsErrors(
false), ErrorsAsFatal(
false),
397 SuppressSystemWarnings(
false), DiagIDs(DiagIDs) {}
399 using iterator = llvm::DenseMap<unsigned, DiagnosticMapping>::iterator;
401 llvm::DenseMap<unsigned, DiagnosticMapping>::const_iterator;
404 DiagMap[
Diag] = Info;
408 return DiagMap.lookup(
Diag);
418 std::list<DiagState> DiagStates;
425 void appendFirst(DiagState *State);
434 bool empty()
const {
return Files.empty(); }
437 void clear(
bool Soft) {
441 FirstDiagState = CurDiagState =
nullptr;
442 CurDiagStateLoc = SourceLocation();
447 LLVM_DUMP_METHOD
void dump(SourceManager &SrcMgr,
448 StringRef DiagName = StringRef())
const;
451 DiagState *getCurDiagState()
const {
return CurDiagState; }
454 SourceLocation getCurDiagStateLoc()
const {
return CurDiagStateLoc; }
457 friend class ASTReader;
458 friend class ASTWriter;
465 struct DiagStatePoint {
469 DiagStatePoint(DiagState *State,
unsigned Offset)
470 : State(State), Offset(Offset) {}
479 File *Parent =
nullptr;
482 unsigned ParentOffset = 0;
486 bool HasLocalTransitions =
false;
490 llvm::SmallVector<DiagStatePoint, 4> StateTransitions;
492 DiagState *lookup(
unsigned Offset)
const;
496 mutable std::map<FileID, File> Files;
499 DiagState *FirstDiagState;
502 DiagState *CurDiagState;
505 SourceLocation CurDiagStateLoc;
508 File *getFile(SourceManager &SrcMgr, FileID ID)
const;
511 DiagStateMap DiagStatesByLoc;
515 std::vector<DiagState *> DiagStateOnPushStack;
517 DiagState *GetCurDiagState()
const {
518 return DiagStatesByLoc.getCurDiagState();
521 void PushDiagStatePoint(DiagState *State, SourceLocation L);
525 DiagState *GetDiagStateForLoc(SourceLocation Loc)
const {
526 return SourceMgr ? DiagStatesByLoc.lookup(*SourceMgr, Loc)
527 : DiagStatesByLoc.getCurDiagState();
535 bool UncompilableErrorOccurred;
538 bool FatalErrorOccurred;
541 bool UnrecoverableErrorOccurred;
545 unsigned TrapNumErrorsOccurred;
546 unsigned TrapNumUnrecoverableErrorsOccurred;
555 unsigned NumWarnings;
571 StringRef Modifier, StringRef Argument,
572 ArrayRef<ArgumentValue> PrevArgs,
573 SmallVectorImpl<char> &Output,
void *Cookie,
574 ArrayRef<intptr_t> QualTypeVals);
576 void *ArgToStringCookie =
nullptr;
577 ArgToStringFnTy ArgToStringFn;
581 const SourceManager &)
const>
582 DiagSuppressionMapping;
586 DiagnosticOptions &DiagOpts,
587 DiagnosticConsumer *client =
nullptr,
588 bool ShouldOwnClient =
true);
594 LLVM_DUMP_METHOD
void dump()
const;
595 LLVM_DUMP_METHOD
void dump(StringRef DiagName)
const;
608 const DiagState &DS = *GetCurDiagState();
620 std::unique_ptr<DiagnosticConsumer>
takeClient() {
return std::move(Owner); }
625 assert(SourceMgr &&
"SourceManager not set!");
630 assert(DiagStatesByLoc.empty() &&
631 "Leftover diag state from a different SourceManager.");
666 TemplateBacktraceLimit = Limit;
676 ConstexprBacktraceLimit = Limit;
682 return ConstexprBacktraceLimit;
689 GetCurDiagState()->IgnoreAllWarnings = Val;
692 return GetCurDiagState()->IgnoreAllWarnings;
700 GetCurDiagState()->EnableAllWarnings = Val;
703 return GetCurDiagState()->EnableAllWarnings;
708 GetCurDiagState()->WarningsAsErrors = Val;
711 return GetCurDiagState()->WarningsAsErrors;
726 GetCurDiagState()->SuppressSystemWarnings = Val;
729 return GetCurDiagState()->SuppressSystemWarnings;
776 return std::numeric_limits<int>::max();
778 return NumOverloadsToShow;
780 llvm_unreachable(
"invalid OverloadsShown kind");
790 NumOverloadsToShow = 4;
801 if (LastDiagLevel ==
Fatal)
802 FatalErrorOccurred =
true;
816 GetCurDiagState()->ExtBehavior = H;
819 return GetCurDiagState()->ExtBehavior;
885 return UncompilableErrorOccurred;
891 return FatalErrorOccurred || UnrecoverableErrorOccurred;
907 template <
unsigned N>
915 StringRef(FormatString, N - 1));
924 ArgToStringFn(Kind, Val, Modifier, Argument, PrevArgs, Output,
925 ArgToStringCookie, QualTypeVals);
930 ArgToStringCookie = Cookie;
936 LastDiagLevel =
Other.LastDiagLevel;
941 void Reset(
bool soft =
false);
960 return Diags->getDiagnosticSeverity(DiagID, Loc, *
this) ==
975 return (
Level)Diags->getDiagnosticLevel(DiagID, Loc, *
this);
1088 unsigned NumUnrecoverableErrors;
1098 return Diag.TrapNumErrorsOccurred > NumErrors;
1104 return Diag.TrapNumUnrecoverableErrorsOccurred > NumUnrecoverableErrors;
1109 NumErrors = Diag.TrapNumErrorsOccurred;
1110 NumUnrecoverableErrors = Diag.TrapNumUnrecoverableErrorsOccurred;
1170 "Too many arguments to diagnostic!");
1180 "Too many arguments to diagnostic!");
1210 operator bool()
const {
return true; }
1257 mutable std::string FlagValue;
1264 mutable bool IsActive =
false;
1268 mutable bool IsForceEmit =
false;
1270 DiagnosticBuilder() =
default;
1283 IsForceEmit =
false;
1303 bool Result = DiagObj->EmitDiagnostic(*
this, IsForceEmit);
1316 template <
typename T>
const DiagnosticBuilder &
operator<<(
const T &
V)
const {
1317 assert(
isActive() &&
"Clients must not add to cleared diagnostic!");
1326 template <
typename T,
1327 typename = std::enable_if_t<!std::is_lvalue_reference<T>::value>>
1329 assert(
isActive() &&
"Clients must not add to cleared diagnostic!");
1335 DiagnosticBuilder &
operator=(
const DiagnosticBuilder &) =
delete;
1379 const llvm::APSInt &Int) {
1387 const llvm::APInt &Int) {
1414template <
typename T>
1415inline std::enable_if_t<std::is_same<T, bool>::value,
1416 const StreamingDiagnostic &>
1417operator<<(
const StreamingDiagnostic &DB, T I) {
1435 unsigned long long I) {
1457template <
typename T>
1458inline std::enable_if_t<
1459 std::is_same<std::remove_const_t<T>, DeclContext>::value,
1460 const StreamingDiagnostic &>
1461operator<<(
const StreamingDiagnostic &DB, T *DC) {
1473template <
typename T,
typename U,
1474 typename UnderlyingU =
typename std::enable_if_t<
1475 std::is_enum_v<std::remove_reference_t<U>>,
1476 std::underlying_type<std::remove_reference_t<U>>>
::type>
1477inline std::enable_if_t<
1479 !std::is_convertible_v<U, UnderlyingU>,
1482 DB << llvm::to_underlying(SE);
1526 const std::optional<SourceRange> &Opt) {
1534 const std::optional<CharSourceRange> &Opt) {
1577 std::string FlagValue;
1579 std::optional<StringRef> StoredDiagMessage;
1585 StringRef StoredDiagMessage);
1588 unsigned getID()
const {
return DiagID; }
1592 return DiagObj->getSourceManager();
1604 assert(Idx <
getNumArgs() &&
"Argument index out of range!");
1612 "invalid argument accessor!");
1613 return DiagStorage.DiagArgumentsStr[Idx];
1620 "invalid argument accessor!");
1621 return reinterpret_cast<const char *
>(DiagStorage.DiagArgumentsVal[Idx]);
1628 "invalid argument accessor!");
1629 return (int64_t)DiagStorage.DiagArgumentsVal[Idx];
1636 "invalid argument accessor!");
1637 return DiagStorage.DiagArgumentsVal[Idx];
1644 "invalid argument accessor!");
1646 DiagStorage.DiagArgumentsVal[Idx]);
1653 "invalid argument accessor!");
1654 return DiagStorage.DiagArgumentsVal[Idx];
1662 assert(Idx <
getNumRanges() &&
"Invalid diagnostic range index!");
1663 return DiagStorage.DiagRanges[Idx];
1673 return DiagStorage.FixItHints[Idx];
1701 std::string Message;
1702 std::vector<CharSourceRange> Ranges;
1703 std::vector<FixItHint> FixIts;
1716 explicit operator bool()
const {
return !Message.empty(); }
1743llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
const StoredDiagnostic &);
1800 virtual void anchor();
1820 void clear()
override;
1829 LLVM_PREFERRED_TYPE(
bool)
1831 LLVM_PREFERRED_TYPE(
bool)
1833 LLVM_PREFERRED_TYPE(
bool)
1835 LLVM_PREFERRED_TYPE(
bool)
1839 LLVM_PREFERRED_TYPE(
bool)
1851 llvm::
vfs::FileSystem &VFS,
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.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
Defines clang::UnsignedOrNone.
Class to make it convenient to initialize TrapReason objects which can be used to attach the "trap re...
Represents a byte-granular source range.
static CharSourceRange getCharRange(SourceRange R)
static CharSourceRange getTokenRange(SourceRange R)
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.
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.
friend class PartialDiagnostic
const DiagnosticBuilder & operator<<(const T &V) const
DiagnosticsEngine * getDiagnosticsEngine() const
friend class DiagnosticsEngine
bool Emit()
Force the diagnostic builder to emit the diagnostic now.
~DiagnosticBuilder()
Emits the diagnostic.
const DiagnosticBuilder & operator<<(T &&V) const
unsigned getDiagID() 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
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
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.
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 a...
Diagnostic(const DiagnosticsEngine *DO, const DiagnosticBuilder &DiagBuilder)
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.
uint64_t getRawArg(unsigned Idx) const
Return the specified non-string argument in an opaque form.
unsigned getNumFixItHints() const
StringRef getFlagValue() const
Return the value associated with this diagnostic flag.
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.
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
bool EmitDiagnostic(const DiagnosticBuilder &DB, bool Force=false)
Emit the diagnostic.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
void setDiagSuppressionMapping(llvm::MemoryBuffer &Input)
Diagnostic suppression mappings can be used to suppress specific diagnostics in specific files.
bool isLastDiagnosticIgnored() const
Determine whether the previous diagnostic was ignored.
DiagnosticsEngine(IntrusiveRefCntPtr< DiagnosticIDs > Diags, DiagnosticOptions &DiagOpts, DiagnosticConsumer *client=nullptr, bool ShouldOwnClient=true)
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
bool isSuppressedViaMapping(diag::kind DiagId, SourceLocation DiagLoc) const
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 getForceSystemWarnings() const
bool getSuppressAllDiagnostics() const
bool getIgnoreAllWarnings() const
friend class DiagnosticIDs
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 &)
friend class DiagnosticErrorTrap
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.
friend class PartialDiagnostic
void setTemplateBacktraceLimit(unsigned Limit)
Specify the maximum number of template instantiation notes to emit along with a given diagnostic.
void DecrementAllExtensionsSilenced()
bool hasUnrecoverableErrorOccurred() const
Determine whether any kind of unrecoverable error has occurred.
void ResetPragmas()
We keep a cache of FileIDs for diagnostics mapped by pragmas.
void setFatalsAsError(bool Val)
When set to true, any fatal error reported is made an error.
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 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
void setLastDiagnosticIgnored(bool IsIgnored)
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed,...
SourceManager & getSourceManager() const
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_attr_info
AttributeCommonInfo *.
@ 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.
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 setForceSystemWarnings(bool Val)
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.
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.
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
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.
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.
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
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
StreamingDiagnostic(StreamingDiagnostic &&Diag)=default
DiagStorageAllocator * Allocator
Allocator used to allocate storage for this diagnostic.
StreamingDiagnostic()=default
clang::DiagStorageAllocator DiagStorageAllocator
StreamingDiagnostic(DiagStorageAllocator &Alloc)
Construct with a storage allocator which will manage the storage.
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
Public enums and private classes that are part of the SourceManager implementation.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Flavor
Flavors of diagnostics we can emit.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
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.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
OverloadsShown
Specifies which overload candidates to display when overload resolution fails.
@ Ovl_All
Show all overloads.
@ Ovl_Best
Show just the "best" overload candidates.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
@ Result
The result type of a method or function.
void EscapeStringForDiagnostic(StringRef Str, SmallVectorImpl< char > &OutStr)
EscapeStringForDiagnostic - Append Str to the diagnostic buffer, escaping non-printable characters an...
void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts, llvm::vfs::FileSystem &VFS, bool ReportDiags=true)
ProcessWarningOptions - Initialize the diagnostic client and process the warning options specified on...
const char ToggleHighlight
Special character that the diagnostic printer will use to toggle the bold attribute.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
__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.
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.
@ MaxArguments
The maximum number of arguments we can hold.
uint64_t DiagArgumentsVal[MaxArguments]
The values for the various substitution positions.
DiagnosticStorage()=default
unsigned TemplateDiffUsed