24#include "llvm/ADT/SmallString.h"
25#include "llvm/ADT/SmallVector.h"
26#include "llvm/ADT/StringExtras.h"
27#include "llvm/ADT/StringRef.h"
28#include "llvm/Support/ConvertUTF.h"
29#include "llvm/Support/CrashRecoveryContext.h"
30#include "llvm/Support/Unicode.h"
31#include "llvm/Support/raw_ostream.h"
62 StringRef Modifier, StringRef Argument,
67 StringRef Str =
"<can't format argument>";
68 Output.append(Str.begin(), Str.end());
75 : Diags(
std::move(diags)), DiagOpts(
std::move(DiagOpts)) {
89 DiagStatesByLoc.dump(*SourceMgr);
93 DiagStatesByLoc.dump(*SourceMgr, DiagName);
97 bool ShouldOwnClient) {
98 Owner.reset(ShouldOwnClient ? client :
nullptr);
103 DiagStateOnPushStack.push_back(GetCurDiagState());
107 if (DiagStateOnPushStack.empty())
110 if (DiagStateOnPushStack.back() != GetCurDiagState()) {
112 PushDiagStatePoint(DiagStateOnPushStack.back(), Loc);
114 DiagStateOnPushStack.pop_back();
119 ErrorOccurred =
false;
120 UncompilableErrorOccurred =
false;
121 FatalErrorOccurred =
false;
122 UnrecoverableErrorOccurred =
false;
126 TrapNumErrorsOccurred = 0;
127 TrapNumUnrecoverableErrorsOccurred = 0;
129 CurDiagID = std::numeric_limits<unsigned>::max();
136 DiagStatesByLoc.clear();
137 DiagStateOnPushStack.clear();
141 DiagStates.emplace_back();
142 DiagStatesByLoc.appendFirst(&DiagStates.back());
147 StringRef Arg2, StringRef Arg3) {
151 DelayedDiagID = DiagID;
152 DelayedDiagArg1 = Arg1.str();
153 DelayedDiagArg2 = Arg2.str();
154 DelayedDiagArg3 = Arg3.str();
157void DiagnosticsEngine::ReportDelayed() {
158 unsigned ID = DelayedDiagID;
160 Report(ID) << DelayedDiagArg1 << DelayedDiagArg2 << DelayedDiagArg3;
163void DiagnosticsEngine::DiagStateMap::appendFirst(DiagState *State) {
164 assert(Files.empty() &&
"not first");
165 FirstDiagState = CurDiagState = State;
169void DiagnosticsEngine::DiagStateMap::append(
SourceManager &SrcMgr,
172 CurDiagState = State;
173 CurDiagStateLoc = Loc;
176 unsigned Offset = Decomp.second;
177 for (
File *F = getFile(SrcMgr, Decomp.first); F;
178 Offset = F->ParentOffset, F = F->Parent) {
179 F->HasLocalTransitions =
true;
180 auto &
Last = F->StateTransitions.back();
181 assert(
Last.Offset <=
Offset &&
"state transitions added out of order");
184 if (
Last.State == State)
190 F->StateTransitions.push_back({State,
Offset});
194DiagnosticsEngine::DiagState *
195DiagnosticsEngine::DiagStateMap::lookup(
SourceManager &SrcMgr,
199 return FirstDiagState;
202 const File *F = getFile(SrcMgr, Decomp.first);
203 return F->lookup(Decomp.second);
206DiagnosticsEngine::DiagState *
207DiagnosticsEngine::DiagStateMap::File::lookup(
unsigned Offset)
const {
209 llvm::partition_point(StateTransitions, [=](
const DiagStatePoint &
P) {
212 assert(OnePastIt != StateTransitions.begin() &&
"missing initial state");
213 return OnePastIt[-1].State;
216DiagnosticsEngine::DiagStateMap::File *
217DiagnosticsEngine::DiagStateMap::getFile(
SourceManager &SrcMgr,
220 auto Range = Files.equal_range(ID);
222 return &
Range.first->second;
223 auto &F = Files.insert(
Range.first, std::make_pair(ID,
File()))->second;
229 F.Parent = getFile(SrcMgr, Decomp.first);
230 F.ParentOffset = Decomp.second;
231 F.StateTransitions.push_back({F.Parent->lookup(Decomp.second), 0});
240 F.StateTransitions.push_back({FirstDiagState, 0});
245void DiagnosticsEngine::DiagStateMap::dump(
SourceManager &SrcMgr,
246 StringRef DiagName)
const {
247 llvm::errs() <<
"diagnostic state at ";
248 CurDiagStateLoc.print(llvm::errs(), SrcMgr);
249 llvm::errs() <<
": " << CurDiagState <<
"\n";
251 for (
auto &F : Files) {
255 bool PrintedOuterHeading =
false;
256 auto PrintOuterHeading = [&] {
257 if (PrintedOuterHeading)
return;
258 PrintedOuterHeading =
true;
260 llvm::errs() <<
"File " << &
File <<
" <FileID " <<
ID.getHashValue()
263 if (F.second.Parent) {
264 std::pair<FileID, unsigned> Decomp =
266 assert(
File.ParentOffset == Decomp.second);
267 llvm::errs() <<
" parent " <<
File.Parent <<
" <FileID "
268 << Decomp.first.getHashValue() <<
"> ";
271 .
print(llvm::errs(), SrcMgr);
273 if (
File.HasLocalTransitions)
274 llvm::errs() <<
" has_local_transitions";
275 llvm::errs() <<
"\n";
278 if (DiagName.empty())
281 for (DiagStatePoint &Transition :
File.StateTransitions) {
282 bool PrintedInnerHeading =
false;
283 auto PrintInnerHeading = [&] {
284 if (PrintedInnerHeading)
return;
285 PrintedInnerHeading =
true;
291 .
print(llvm::errs(), SrcMgr);
292 llvm::errs() <<
": state " << Transition.State <<
":\n";
295 if (DiagName.empty())
298 for (
auto &Mapping : *Transition.State) {
301 if (!DiagName.empty() && DiagName != Option)
307 llvm::errs() <<
"<unknown " << Mapping.first <<
">";
309 llvm::errs() << Option;
310 llvm::errs() <<
": ";
312 switch (Mapping.second.getSeverity()) {
320 if (!Mapping.second.isUser())
321 llvm::errs() <<
" default";
322 if (Mapping.second.isPragma())
323 llvm::errs() <<
" pragma";
324 if (Mapping.second.hasNoWarningAsError())
325 llvm::errs() <<
" no-error";
326 if (Mapping.second.hasNoErrorAsFatal())
327 llvm::errs() <<
" no-fatal";
328 if (Mapping.second.wasUpgradedFromWarning())
329 llvm::errs() <<
" overruled";
330 llvm::errs() <<
"\n";
336void DiagnosticsEngine::PushDiagStatePoint(DiagState *State,
338 assert(Loc.
isValid() &&
"Adding invalid loc point");
339 DiagStatesByLoc.append(*SourceMgr, Loc, State);
345 "Can only map builtin diagnostics");
346 assert((Diags->isBuiltinWarningOrExtension(
Diag) ||
348 "Cannot map errors into warnings!");
349 assert((L.
isInvalid() || SourceMgr) &&
"No SourceMgr for valid location");
352 bool WasUpgradedFromWarning =
false;
358 WasUpgradedFromWarning =
true;
371 if ((L.
isInvalid() || L == DiagStatesByLoc.getCurDiagStateLoc()) &&
372 DiagStatesByLoc.getCurDiagState()) {
377 DiagStatesByLoc.getCurDiagState()->setMapping(
Diag, Mapping);
384 DiagStates.push_back(*GetCurDiagState());
385 DiagStates.back().setMapping(
Diag, Mapping);
386 PushDiagStatePoint(&DiagStates.back(), L);
394 if (Diags->getDiagnosticsInGroup(Flavor, Group, GroupDiags))
477 std::vector<diag::kind> AllDiags;
482 if (Diags->isBuiltinWarningOrExtension(
Diag))
487 assert(CurDiagID == std::numeric_limits<unsigned>::max() &&
488 "Multiple diagnostics in flight at once!");
491 CurDiagID = storedDiag.
getID();
502 assert(Client &&
"DiagnosticConsumer not set!");
511 CurDiagID = std::numeric_limits<unsigned>::max();
515 assert(
getClient() &&
"DiagnosticClient not set!");
528 Diags->EmitDiag(*
this, DiagLevel);
533 Emitted = ProcessDiag();
540 if (!Force && DelayedDiagID)
560template <std::
size_t StrLen>
561static bool ModifierIs(
const char *Modifier,
unsigned ModifierLen,
562 const char (&Str)[StrLen]) {
563 return StrLen-1 == ModifierLen && memcmp(Modifier, Str, StrLen-1) == 0;
571 for ( ; I != E; ++I) {
572 if (Depth == 0 && *I ==
Target)
return I;
573 if (Depth != 0 && *I ==
'}') Depth--;
583 for (I++; I != E && !
isDigit(*I) && *I !=
'{'; I++) ;
599 const char *Argument,
unsigned ArgumentLen,
601 const char *ArgumentEnd = Argument+ArgumentLen;
605 const char *NextVal =
ScanFormat(Argument, ArgumentEnd,
'|');
606 assert(NextVal != ArgumentEnd &&
"Value for integer select modifier was"
607 " larger than the number of options in the diagnostic string!");
608 Argument = NextVal+1;
613 const char *EndPtr =
ScanFormat(Argument, ArgumentEnd,
'|');
625 OutStr.push_back(
's');
634 assert(ValNo != 0 &&
"ValNo must be strictly positive!");
636 llvm::raw_svector_ostream Out(OutStr);
640 Out << ValNo << llvm::getOrdinalSuffix(ValNo);
647 while (Start != End && *Start >=
'0' && *Start <=
'9') {
664 assert(*Start ==
',' &&
"Bad plural expression syntax: expected ,");
667 assert(*Start ==
']' &&
"Bad plural expression syntax: expected )");
669 return Low <= Val && Val <= High;
684 assert(*Start ==
'=' &&
"Bad plural expression syntax: expected =");
686 unsigned ValMod = ValNo % Arg;
690 assert((
C ==
'[' || (
C >=
'0' &&
C <=
'9')) &&
691 "Bad plural expression syntax: unexpected character");
698 Start = std::find(Start, End,
',');
740 const char *Argument,
unsigned ArgumentLen,
742 const char *ArgumentEnd = Argument + ArgumentLen;
744 assert(Argument < ArgumentEnd &&
"Plural expression didn't match.");
745 const char *ExprEnd = Argument;
746 while (*ExprEnd !=
':') {
747 assert(ExprEnd != ArgumentEnd &&
"Plural missing expression end");
751 Argument = ExprEnd + 1;
752 ExprEnd =
ScanFormat(Argument, ArgumentEnd,
'|');
759 Argument =
ScanFormat(Argument, ArgumentEnd - 1,
'|') + 1;
768 case tok::identifier:
780 if (StoredDiagMessage.has_value()) {
781 OutStr.append(StoredDiagMessage->begin(), StoredDiagMessage->end());
794 OutStr.reserve(OutStr.size() + Str.size());
795 auto *
Begin =
reinterpret_cast<const unsigned char *
>(Str.data());
796 llvm::raw_svector_ostream OutStream(OutStr);
797 const unsigned char *End =
Begin + Str.size();
798 while (
Begin != End) {
805 if (llvm::isLegalUTF8Sequence(
Begin, End)) {
806 llvm::UTF32 CodepointValue;
807 llvm::UTF32 *CpPtr = &CodepointValue;
808 const unsigned char *CodepointBegin =
Begin;
809 const unsigned char *CodepointEnd =
811 llvm::ConversionResult Res = llvm::ConvertUTF8toUTF32(
812 &
Begin, CodepointEnd, &CpPtr, CpPtr + 1, llvm::strictConversion);
815 llvm::conversionOK == Res &&
816 "the sequence is legal UTF-8 but we couldn't convert it to UTF-32");
817 assert(
Begin == CodepointEnd &&
818 "we must be further along in the string now");
819 if (llvm::sys::unicode::isPrintable(CodepointValue) ||
820 llvm::sys::unicode::isFormatting(CodepointValue)) {
821 OutStr.append(CodepointBegin, CodepointEnd);
825 OutStream <<
"<U+" << llvm::format_hex_no_prefix(CodepointValue, 4,
true)
830 OutStream <<
"<" << llvm::format_hex_no_prefix(*
Begin, 2,
true) <<
">";
841 if (DiagEnd - DiagStr == 2 &&
842 StringRef(DiagStr, DiagEnd - DiagStr).
equals(
"%0") &&
860 for (
unsigned i = 0, e =
getNumArgs(); i < e; ++i)
864 while (DiagStr != DiagEnd) {
865 if (DiagStr[0] !=
'%') {
867 const char *StrEnd = std::find(DiagStr, DiagEnd,
'%');
868 OutStr.append(DiagStr, StrEnd);
872 OutStr.push_back(DiagStr[1]);
885 const char *Modifier =
nullptr, *Argument =
nullptr;
886 unsigned ModifierLen = 0, ArgumentLen = 0;
891 while (DiagStr[0] ==
'-' ||
892 (DiagStr[0] >=
'a' && DiagStr[0] <=
'z'))
894 ModifierLen = DiagStr-Modifier;
897 if (DiagStr[0] ==
'{') {
902 assert(DiagStr != DiagEnd &&
"Mismatched {}'s in diagnostic string!");
903 ArgumentLen = DiagStr-Argument;
908 assert(
isDigit(*DiagStr) &&
"Invalid format for argument in diagnostic");
909 unsigned ArgNo = *DiagStr++ -
'0';
912 unsigned ArgNo2 = ArgNo;
915 if (
ModifierIs(Modifier, ModifierLen,
"diff")) {
916 assert(*DiagStr ==
',' &&
isDigit(*(DiagStr + 1)) &&
917 "Invalid format for diff modifier");
919 ArgNo2 = *DiagStr++ -
'0';
930 const char *ArgumentEnd = Argument + ArgumentLen;
933 "Found too many '|'s in a %diff modifier!");
935 const char *SecondDollar =
ScanFormat(FirstDollar + 1,
Pipe,
'$');
936 const char ArgStr1[] = {
'%',
static_cast<char>(
'0' + ArgNo) };
937 const char ArgStr2[] = {
'%',
static_cast<char>(
'0' + ArgNo2) };
951 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
957 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
969 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
972 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
974 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
977 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
980 assert(ModifierLen == 0 &&
"Unknown integer modifier");
981 llvm::raw_svector_ostream(OutStr) << Val;
988 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
990 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
992 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
995 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
998 assert(ModifierLen == 0 &&
"Unknown integer modifier");
999 llvm::raw_svector_ostream(OutStr) << Val;
1006 assert(ModifierLen == 0 &&
"No modifiers for token kinds yet");
1008 llvm::raw_svector_ostream Out(OutStr);
1011 Out <<
'\'' << S <<
'\'';
1020 Out <<
'<' << S <<
'>';
1028 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
1032 const char *S =
"(null)";
1033 OutStr.append(S, S + strlen(S));
1037 llvm::raw_svector_ostream(OutStr) <<
'\'' << II->
getName() <<
'\'';
1049 StringRef(Modifier, ModifierLen),
1050 StringRef(Argument, ArgumentLen),
1052 OutStr, QualTypeVals);
1064 const char *ArgumentEnd = Argument + ArgumentLen;
1073 StringRef(Modifier, ModifierLen),
1074 StringRef(Argument, ArgumentLen),
1076 Tree, QualTypeVals);
1078 if (!
Tree.empty()) {
1086 const char *FirstDollar =
ScanFormat(Argument, ArgumentEnd,
'$');
1087 const char *SecondDollar =
ScanFormat(FirstDollar + 1, ArgumentEnd,
'$');
1096 StringRef(Modifier, ModifierLen),
1097 StringRef(Argument, ArgumentLen),
1099 OutStr, QualTypeVals);
1110 StringRef(Modifier, ModifierLen),
1111 StringRef(Argument, ArgumentLen),
1113 OutStr, QualTypeVals);
1130 FormattedArgs.push_back(std::make_pair(Kind,
getRawArg(ArgNo)));
1137 OutStr.append(
Tree.begin(),
Tree.end());
1142 : ID(ID), Level(Level), Message(Message) {}
1146 : ID(Info.getID()), Level(Level) {
1148 "Valid source location without setting a source manager for diagnostic");
1153 this->Message.assign(Message.begin(), Message.end());
1162 : ID(ID), Level(Level), Loc(Loc), Message(Message),
1163 Ranges(Ranges.begin(), Ranges.end()), FixIts(FixIts.begin(), FixIts.end())
1181void IgnoringDiagConsumer::anchor() {}
1200PartialDiagnostic::DiagStorageAllocator::DiagStorageAllocator() {
1201 for (
unsigned I = 0; I != NumCached; ++I)
1202 FreeList[I] = Cached + I;
1203 NumFreeListEntries = NumCached;
1206PartialDiagnostic::DiagStorageAllocator::~DiagStorageAllocator() {
1209 assert((NumFreeListEntries == NumCached ||
1210 llvm::CrashRecoveryContext::isRecoveringFromCrash()) &&
1211 "A partial is on the lam");
static const char * ScanFormat(const char *I, const char *E, char Target)
ScanForward - Scans forward, looking for the given character, skipping nested clauses and escaped cha...
static void HandlePluralModifier(const Diagnostic &DInfo, unsigned ValNo, const char *Argument, unsigned ArgumentLen, SmallVectorImpl< char > &OutStr)
HandlePluralModifier - Handle the integer 'plural' modifier.
static void pushEscapedString(StringRef Str, SmallVectorImpl< char > &OutStr)
pushEscapedString - Append Str to the diagnostic buffer, escaping non-printable characters and ill-fo...
static void HandleIntegerSModifier(unsigned ValNo, SmallVectorImpl< char > &OutStr)
HandleIntegerSModifier - Handle the integer 's' modifier.
static void DummyArgToStringFn(DiagnosticsEngine::ArgumentKind AK, intptr_t QT, StringRef Modifier, StringRef Argument, ArrayRef< DiagnosticsEngine::ArgumentValue > PrevArgs, SmallVectorImpl< char > &Output, void *Cookie, ArrayRef< intptr_t > QualTypeVals)
static bool EvalPluralExpr(unsigned ValNo, const char *Start, const char *End)
EvalPluralExpr - Actual expression evaluator for HandlePluralModifier.
static unsigned PluralNumber(const char *&Start, const char *End)
PluralNumber - Parse an unsigned integer and advance Start.
static void HandleSelectModifier(const Diagnostic &DInfo, unsigned ValNo, const char *Argument, unsigned ArgumentLen, SmallVectorImpl< char > &OutStr)
HandleSelectModifier - Handle the integer 'select' modifier.
static bool ModifierIs(const char *Modifier, unsigned ModifierLen, const char(&Str)[StrLen])
ModifierIs - Return true if the specified modifier matches specified string.
static bool TestPluralRange(unsigned Val, const char *&Start, const char *End)
TestPluralRange - Test if Val is in the parsed range. Modifies Start.
static void HandleOrdinalModifier(unsigned ValNo, SmallVectorImpl< char > &OutStr)
HandleOrdinalModifier - Handle the integer 'ord' modifier.
static const char * getTokenDescForDiagnostic(tok::TokenKind Kind)
Returns the friendly description for a token kind that will appear without quotes in diagnostic messa...
Defines the Diagnostic-related interfaces.
Defines the Diagnostic IDs-related interfaces.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector 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.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
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 the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TokenKind enum and support functions.
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
virtual ~DiagnosticConsumer()
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 NumErrors
Number of errors reported.
unsigned NumWarnings
Number of warnings reported.
virtual bool IncludeInDiagnosticCounts() const
Indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number...
static StringRef getWarningOptionForDiag(unsigned DiagID)
Return the lowest-level warning option that enables the specified diagnostic.
Level
The level of the diagnostic, after it has been through mapping.
static void getAllDiagnostics(diag::Flavor Flavor, std::vector< diag::kind > &Diags)
Get the set of all diagnostic IDs.
void setNoWarningAsError(bool Value)
void setSeverity(diag::Severity Value)
diag::Severity getSeverity() const
void setUpgradedFromWarning(bool Value)
void setNoErrorAsFatal(bool Value)
bool hasNoWarningAsError() const
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.
uint64_t getRawArg(unsigned Idx) const
Return the specified non-string argument in an opaque form.
const char * getArgCStr(unsigned Idx) const
Return the specified C string argument.
const IdentifierInfo * getArgIdentifier(unsigned Idx) const
Return the specified IdentifierInfo argument.
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.
ArrayRef< CharSourceRange > getRanges() const
Return an array reference for this diagnostic's ranges.
const DiagnosticsEngine * getDiags() const
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void setSeverityForAll(diag::Flavor Flavor, diag::Severity Map, SourceLocation Loc=SourceLocation())
Add the specified mapping to all diagnostics of the specified flavor.
LLVM_DUMP_METHOD void dump() const
void setClient(DiagnosticConsumer *client, bool ShouldOwnClient=true)
Set the diagnostic client associated with this diagnostic object.
void Clear()
Clear out the current diagnostic.
void pushMappings(SourceLocation Loc)
Copies the current DiagMappings and pushes the new copy onto the top of the stack.
void setSeverity(diag::kind Diag, diag::Severity Map, SourceLocation Loc)
This allows the client to specify that certain warnings are ignored.
Level
The level of the diagnostic, after it has been through mapping.
DiagnosticConsumer * getClient()
@ 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 *.
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.
bool setDiagnosticGroupErrorAsFatal(StringRef Group, bool Enabled)
Set the error-as-fatal flag for the given diagnostic group.
bool setDiagnosticGroupWarningAsError(StringRef Group, bool Enabled)
Set the warning-as-error flag for the given diagnostic group.
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.
bool setSeverityForGroup(diag::Flavor Flavor, StringRef Group, diag::Severity Map, SourceLocation Loc=SourceLocation())
Change an entire diagnostic group (e.g.
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...
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
void Reset(bool soft=false)
Reset the state of the diagnostic object to its initial configuration.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
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.
A SourceLocation and its associated SourceManager.
bool hasManager() const
Checks whether the SourceManager is present.
const SourceManager & getManager() const
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
Encodes a location in the source.
std::string printToString(const SourceManager &SM) const
bool isValid() const
Return true if this is a valid SourceLocation object.
void print(raw_ostream &OS, const SourceManager &SM) const
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
llvm::MemoryBufferRef getBufferOrFake(FileID FID, SourceLocation Loc=SourceLocation()) const
Return the buffer for the specified FileID.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
std::pair< FileID, unsigned > getDecomposedIncludedLoc(FileID FID) const
Returns the "included/expanded in" decomposed location of the given FileID.
Represents a diagnostic in a form that can be retained until its corresponding source manager is dest...
range_iterator range_begin() const
StoredDiagnostic()=default
DiagnosticsEngine::Level getLevel() const
fixit_iterator fixit_begin() const
const FullSourceLoc & getLocation() const
range_iterator range_end() const
StringRef getMessage() const
fixit_iterator fixit_end() const
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
void AddString(StringRef V) const
internal::PolymorphicMatcher< internal::ValueEqualsMatcher, void(internal::AllNodeBaseTypes), ValueT > equals(const ValueT &Value)
Matches literals that are equal to the given value of type ValueT.
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing),...
@ Warning
Present this diagnostic as a warning.
@ Fatal
Present this diagnostic as a fatal error.
@ Error
Present this diagnostic as an error.
@ Remark
Present this diagnostic as a remark.
@ Ignored
Do not present this diagnostic, ignore it.
Flavor
Flavors of diagnostics we can emit.
@ WarningOrError
A diagnostic that indicates a problem or potential problem.
const char * getTokenName(TokenKind Kind) LLVM_READNONE
Determines the name of a token as used within the front end.
const char * getKeywordSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple keyword and contextual keyword tokens like 'int' and 'dynamic_cast'...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
const char * getPunctuatorSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple punctuation tokens like '!' or '', and returns NULL for literal and...
LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
@ C
Languages that the frontend can parse and compile.
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
LLVM_READONLY bool isPunctuation(unsigned char c)
Return true if this character is an ASCII punctuation character.
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type,...
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.
unsigned TemplateDiffUsed