25 #include "llvm/ADT/SmallString.h" 26 #include "llvm/ADT/SmallVector.h" 27 #include "llvm/ADT/StringExtras.h" 28 #include "llvm/ADT/StringRef.h" 29 #include "llvm/Support/CrashRecoveryContext.h" 30 #include "llvm/Support/Locale.h" 31 #include "llvm/Support/raw_ostream.h" 42 using namespace clang;
47 switch (nullability.first) {
49 string = nullability.second ?
"'nonnull'" :
"'_Nonnull'";
53 string = nullability.second ?
"'nullable'" :
"'_Nullable'";
57 string = nullability.second ?
"'null_unspecified'" :
"'_Null_unspecified'";
66 StringRef
Modifier, StringRef Argument,
71 StringRef Str =
"<can't format argument>";
72 Output.append(Str.begin(), Str.end());
79 : Diags(
std::move(diags)), DiagOpts(
std::move(DiagOpts)) {
93 DiagStatesByLoc.dump(*SourceMgr);
97 DiagStatesByLoc.dump(*SourceMgr, DiagName);
101 bool ShouldOwnClient) {
102 Owner.reset(ShouldOwnClient ? client :
nullptr);
107 DiagStateOnPushStack.push_back(GetCurDiagState());
111 if (DiagStateOnPushStack.empty())
114 if (DiagStateOnPushStack.back() != GetCurDiagState()) {
116 PushDiagStatePoint(DiagStateOnPushStack.back(), Loc);
118 DiagStateOnPushStack.pop_back();
123 ErrorOccurred =
false;
124 UncompilableErrorOccurred =
false;
125 FatalErrorOccurred =
false;
126 UnrecoverableErrorOccurred =
false;
130 TrapNumErrorsOccurred = 0;
131 TrapNumUnrecoverableErrorsOccurred = 0;
139 DiagStatesByLoc.clear();
140 DiagStateOnPushStack.clear();
144 DiagStates.emplace_back();
145 DiagStatesByLoc.appendFirst(&DiagStates.back());
153 DelayedDiagID = DiagID;
154 DelayedDiagArg1 = Arg1.str();
155 DelayedDiagArg2 = Arg2.str();
158 void DiagnosticsEngine::ReportDelayed() {
159 unsigned ID = DelayedDiagID;
161 Report(ID) << DelayedDiagArg1 << DelayedDiagArg2;
164 void DiagnosticsEngine::DiagStateMap::appendFirst(DiagState *
State) {
165 assert(Files.empty() &&
"not first");
166 FirstDiagState = CurDiagState =
State;
170 void DiagnosticsEngine::DiagStateMap::append(
SourceManager &SrcMgr,
173 CurDiagState =
State;
174 CurDiagStateLoc = Loc;
177 unsigned Offset = Decomp.second;
178 for (File *F = getFile(SrcMgr, Decomp.first); F;
179 Offset = F->ParentOffset, F = F->Parent) {
180 F->HasLocalTransitions =
true;
181 auto &
Last = F->StateTransitions.back();
182 assert(
Last.Offset <= Offset &&
"state transitions added out of order");
184 if (
Last.Offset == Offset) {
185 if (
Last.State == State)
191 F->StateTransitions.push_back({
State, Offset});
195 DiagnosticsEngine::DiagState *
196 DiagnosticsEngine::DiagStateMap::lookup(
SourceManager &SrcMgr,
200 return FirstDiagState;
203 const File *F = getFile(SrcMgr, Decomp.first);
204 return F->lookup(Decomp.second);
207 DiagnosticsEngine::DiagState *
208 DiagnosticsEngine::DiagStateMap::File::lookup(
unsigned Offset)
const {
209 auto OnePastIt = std::upper_bound(
210 StateTransitions.begin(), StateTransitions.end(),
Offset,
211 [](
unsigned Offset,
const DiagStatePoint &
P) {
212 return Offset <
P.Offset;
214 assert(OnePastIt != StateTransitions.begin() &&
"missing initial state");
215 return OnePastIt[-1].State;
218 DiagnosticsEngine::DiagStateMap::File *
219 DiagnosticsEngine::DiagStateMap::getFile(
SourceManager &SrcMgr,
222 auto Range = Files.equal_range(ID);
223 if (Range.first != Range.second)
224 return &Range.first->second;
225 auto &F = Files.insert(Range.first, std::make_pair(ID, File()))->second;
231 F.Parent = getFile(SrcMgr, Decomp.first);
232 F.ParentOffset = Decomp.second;
233 F.StateTransitions.push_back({F.Parent->lookup(Decomp.second), 0});
242 F.StateTransitions.push_back({FirstDiagState, 0});
248 StringRef DiagName)
const {
249 llvm::errs() <<
"diagnostic state at ";
250 CurDiagStateLoc.print(llvm::errs(), SrcMgr);
251 llvm::errs() <<
": " << CurDiagState <<
"\n";
253 for (
auto &F : Files) {
255 File &File = F.second;
257 bool PrintedOuterHeading =
false;
258 auto PrintOuterHeading = [&] {
259 if (PrintedOuterHeading)
return;
260 PrintedOuterHeading =
true;
262 llvm::errs() <<
"File " << &File <<
" <FileID " << ID.
getHashValue()
263 <<
">: " << SrcMgr.
getBuffer(ID)->getBufferIdentifier();
264 if (F.second.Parent) {
265 std::pair<FileID, unsigned> Decomp =
267 assert(File.ParentOffset == Decomp.second);
268 llvm::errs() <<
" parent " << File.Parent <<
" <FileID " 269 << Decomp.first.getHashValue() <<
"> ";
272 .
print(llvm::errs(), SrcMgr);
274 if (File.HasLocalTransitions)
275 llvm::errs() <<
" has_local_transitions";
276 llvm::errs() <<
"\n";
279 if (DiagName.empty())
282 for (DiagStatePoint &Transition : File.StateTransitions) {
283 bool PrintedInnerHeading =
false;
284 auto PrintInnerHeading = [&] {
285 if (PrintedInnerHeading)
return;
286 PrintedInnerHeading =
true;
292 .
print(llvm::errs(), SrcMgr);
293 llvm::errs() <<
": state " << Transition.State <<
":\n";
296 if (DiagName.empty())
299 for (
auto &Mapping : *Transition.State) {
302 if (!DiagName.empty() && DiagName != Option)
308 llvm::errs() <<
"<unknown " << Mapping.first <<
">";
310 llvm::errs() << Option;
311 llvm::errs() <<
": ";
313 switch (Mapping.second.getSeverity()) {
321 if (!Mapping.second.isUser())
322 llvm::errs() <<
" default";
323 if (Mapping.second.isPragma())
324 llvm::errs() <<
" pragma";
325 if (Mapping.second.hasNoWarningAsError())
326 llvm::errs() <<
" no-error";
327 if (Mapping.second.hasNoErrorAsFatal())
328 llvm::errs() <<
" no-fatal";
329 if (Mapping.second.wasUpgradedFromWarning())
330 llvm::errs() <<
" overruled";
331 llvm::errs() <<
"\n";
337 void DiagnosticsEngine::PushDiagStatePoint(DiagState *
State,
339 assert(Loc.
isValid() &&
"Adding invalid loc point");
340 DiagStatesByLoc.append(*SourceMgr, Loc,
State);
346 "Can only map builtin diagnostics");
347 assert((Diags->isBuiltinWarningOrExtension(Diag) ||
349 "Cannot map errors into warnings!");
350 assert((L.
isInvalid() || SourceMgr) &&
"No SourceMgr for valid location");
353 bool WasUpgradedFromWarning =
false;
359 WasUpgradedFromWarning =
true;
366 if ((L.
isInvalid() || L == DiagStatesByLoc.getCurDiagStateLoc()) &&
367 DiagStatesByLoc.getCurDiagState()) {
372 DiagStatesByLoc.getCurDiagState()->setMapping(Diag, Mapping);
379 DiagStates.push_back(*GetCurDiagState());
380 DiagStates.back().setMapping(Diag, Mapping);
381 PushDiagStatePoint(&DiagStates.back(), L);
389 if (Diags->getDiagnosticsInGroup(Flavor, Group, GroupDiags))
464 std::vector<diag::kind> AllDiags;
469 if (Diags->isBuiltinWarningOrExtension(
Diag))
475 "Multiple diagnostics in flight at once!");
478 CurDiagID = storedDiag.
getID();
484 DiagFixItHints.clear();
487 assert(Client &&
"DiagnosticConsumer not set!");
500 assert(
getClient() &&
"DiagnosticClient not set!");
513 Diags->EmitDiag(*
this, DiagLevel);
518 Emitted = ProcessDiag();
525 if (!Force && DelayedDiagID)
535 if (!IncludeInDiagnosticCounts())
545 template <std::
size_t StrLen>
547 const char (&Str)[StrLen]) {
548 return StrLen-1 == ModifierLen && memcmp(Modifier, Str, StrLen-1) == 0;
556 for ( ; I != E; ++I) {
557 if (Depth == 0 && *I == Target)
return I;
558 if (Depth != 0 && *I ==
'}') Depth--;
568 for (I++; I != E && !
isDigit(*I) && *I !=
'{'; I++) ;
584 const char *Argument,
unsigned ArgumentLen,
586 const char *ArgumentEnd = Argument+ArgumentLen;
590 const char *NextVal =
ScanFormat(Argument, ArgumentEnd,
'|');
591 assert(NextVal != ArgumentEnd &&
"Value for integer select modifier was" 592 " larger than the number of options in the diagnostic string!");
593 Argument = NextVal+1;
598 const char *EndPtr =
ScanFormat(Argument, ArgumentEnd,
'|');
610 OutStr.push_back(
's');
619 assert(ValNo != 0 &&
"ValNo must be strictly positive!");
621 llvm::raw_svector_ostream Out(OutStr);
625 Out << ValNo << llvm::getOrdinalSuffix(ValNo);
632 while (Start != End && *Start >=
'0' && *Start <=
'9') {
649 assert(*Start ==
',' &&
"Bad plural expression syntax: expected ,");
652 assert(*Start ==
']' &&
"Bad plural expression syntax: expected )");
654 return Low <= Val && Val <= High;
669 assert(*Start ==
'=' &&
"Bad plural expression syntax: expected =");
671 unsigned ValMod = ValNo % Arg;
675 assert((C ==
'[' || (C >=
'0' && C <=
'9')) &&
676 "Bad plural expression syntax: unexpected character");
683 Start = std::find(Start, End,
',');
725 const char *Argument,
unsigned ArgumentLen,
727 const char *ArgumentEnd = Argument + ArgumentLen;
729 assert(Argument < ArgumentEnd &&
"Plural expression didn't match.");
730 const char *ExprEnd = Argument;
731 while (*ExprEnd !=
':') {
732 assert(ExprEnd != ArgumentEnd &&
"Plural missing expression end");
736 Argument = ExprEnd + 1;
737 ExprEnd =
ScanFormat(Argument, ArgumentEnd,
'|');
744 Argument =
ScanFormat(Argument, ArgumentEnd - 1,
'|') + 1;
753 case tok::identifier:
765 if (!StoredDiagMessage.empty()) {
766 OutStr.append(StoredDiagMessage.begin(), StoredDiagMessage.end());
771 getDiags()->getDiagnosticIDs()->getDescription(
getID());
773 FormatDiagnostic(Diag.begin(), Diag.end(), OutStr);
782 if (DiagEnd - DiagStr == 2 &&
783 StringRef(DiagStr, DiagEnd - DiagStr).
equals(
"%0") &&
785 const std::string &S = getArgStdStr(0);
787 if (llvm::sys::locale::isPrint(c) || c ==
'\t') {
805 for (
unsigned i = 0, e = getNumArgs(); i < e; ++i)
807 QualTypeVals.push_back(getRawArg(i));
809 while (DiagStr != DiagEnd) {
810 if (DiagStr[0] !=
'%') {
812 const char *StrEnd = std::find(DiagStr, DiagEnd,
'%');
813 OutStr.append(DiagStr, StrEnd);
817 OutStr.push_back(DiagStr[1]);
830 const char *Modifier =
nullptr, *Argument =
nullptr;
831 unsigned ModifierLen = 0, ArgumentLen = 0;
836 while (DiagStr[0] ==
'-' ||
837 (DiagStr[0] >=
'a' && DiagStr[0] <=
'z'))
842 if (DiagStr[0] ==
'{') {
847 assert(DiagStr != DiagEnd &&
"Mismatched {}'s in diagnostic string!");
848 ArgumentLen = DiagStr-Argument;
853 assert(
isDigit(*DiagStr) &&
"Invalid format for argument in diagnostic");
854 unsigned ArgNo = *DiagStr++ -
'0';
857 unsigned ArgNo2 = ArgNo;
860 if (
ModifierIs(Modifier, ModifierLen,
"diff")) {
861 assert(*DiagStr ==
',' &&
isDigit(*(DiagStr + 1)) &&
862 "Invalid format for diff modifier");
864 ArgNo2 = *DiagStr++ -
'0';
875 const char *ArgumentEnd = Argument + ArgumentLen;
876 const char *Pipe =
ScanFormat(Argument, ArgumentEnd,
'|');
877 assert(
ScanFormat(Pipe + 1, ArgumentEnd,
'|') == ArgumentEnd &&
878 "Found too many '|'s in a %diff modifier!");
879 const char *FirstDollar =
ScanFormat(Argument, Pipe,
'$');
880 const char *SecondDollar =
ScanFormat(FirstDollar + 1, Pipe,
'$');
881 const char ArgStr1[] = {
'%',
static_cast<char>(
'0' + ArgNo) };
882 const char ArgStr2[] = {
'%',
static_cast<char>(
'0' + ArgNo2) };
883 FormatDiagnostic(Argument, FirstDollar, OutStr);
884 FormatDiagnostic(ArgStr1, ArgStr1 + 2, OutStr);
885 FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
886 FormatDiagnostic(ArgStr2, ArgStr2 + 2, OutStr);
887 FormatDiagnostic(SecondDollar + 1, Pipe, OutStr);
895 const std::string &S = getArgStdStr(ArgNo);
896 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
897 OutStr.append(S.begin(), S.end());
901 const char *S = getArgCStr(ArgNo);
902 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
908 OutStr.append(S, S + strlen(S));
913 int Val = getArgSInt(ArgNo);
915 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
918 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
920 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
923 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
926 assert(ModifierLen == 0 &&
"Unknown integer modifier");
927 llvm::raw_svector_ostream(OutStr) << Val;
932 unsigned Val = getArgUInt(ArgNo);
934 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
936 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
938 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
941 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
944 assert(ModifierLen == 0 &&
"Unknown integer modifier");
945 llvm::raw_svector_ostream(OutStr) << Val;
952 assert(ModifierLen == 0 &&
"No modifiers for token kinds yet");
954 llvm::raw_svector_ostream Out(OutStr);
957 Out <<
'\'' << S <<
'\'';
966 Out << '<' << S << '>
'; 971 // ---- NAMES and TYPES ---- 972 case DiagnosticsEngine::ak_identifierinfo: { 973 const IdentifierInfo *II = getArgIdentifier(ArgNo); 974 assert(ModifierLen == 0 && "No modifiers for strings yet"); 976 // Don't crash
if get passed a null pointer by accident.
978 const char *S =
"(null)";
979 OutStr.append(S, S + strlen(S));
983 llvm::raw_svector_ostream(OutStr) <<
'\'' << II->getName() <<
'\'';
993 getDiags()->ConvertArgToString(Kind, getRawArg(ArgNo),
994 StringRef(Modifier, ModifierLen),
995 StringRef(Argument, ArgumentLen),
997 OutStr, QualTypeVals);
1003 TDT.
ToType = getRawArg(ArgNo2);
1009 const char *ArgumentEnd = Argument + ArgumentLen;
1010 const char *Pipe =
ScanFormat(Argument, ArgumentEnd,
'|');
1014 if (getDiags()->PrintTemplateTree && Tree.empty()) {
1017 getDiags()->ConvertArgToString(Kind, val,
1018 StringRef(Modifier, ModifierLen),
1019 StringRef(Argument, ArgumentLen),
1021 Tree, QualTypeVals);
1023 if (!Tree.empty()) {
1024 FormatDiagnostic(Pipe + 1, ArgumentEnd, OutStr);
1031 const char *FirstDollar =
ScanFormat(Argument, ArgumentEnd,
'$');
1032 const char *SecondDollar =
ScanFormat(FirstDollar + 1, ArgumentEnd,
'$');
1035 FormatDiagnostic(Argument, FirstDollar, OutStr);
1040 getDiags()->ConvertArgToString(Kind, val,
1041 StringRef(Modifier, ModifierLen),
1042 StringRef(Argument, ArgumentLen),
1044 OutStr, QualTypeVals);
1050 FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
1054 getDiags()->ConvertArgToString(Kind, val,
1055 StringRef(Modifier, ModifierLen),
1056 StringRef(Argument, ArgumentLen),
1058 OutStr, QualTypeVals);
1064 FormatDiagnostic(SecondDollar + 1, Pipe, OutStr);
1075 FormattedArgs.push_back(std::make_pair(Kind, getRawArg(ArgNo)));
1078 (
intptr_t)getArgStdStr(ArgNo).c_str()));
1082 OutStr.append(Tree.begin(), Tree.end());
1087 : ID(ID), Level(Level), Message(Message) {}
1091 : ID(Info.
getID()), Level(Level) {
1093 "Valid source location without setting a source manager for diagnostic");
1098 this->Message.assign(Message.begin(), Message.end());
1107 : ID(ID), Level(Level), Loc(Loc), Message(Message),
1108 Ranges(Ranges.begin(), Ranges.end()), FixIts(FixIts.begin(), FixIts.end())
1118 void IgnoringDiagConsumer::anchor() {}
1125 Target.HandleDiagnostic(DiagLevel, Info);
1134 return Target.IncludeInDiagnosticCounts();
1138 for (
unsigned I = 0; I != NumCached; ++I)
1139 FreeList[I] = Cached + I;
1140 NumFreeListEntries = NumCached;
1146 assert((NumFreeListEntries == NumCached ||
1147 llvm::CrashRecoveryContext::isRecoveringFromCrash()) &&
1148 "A partial is on the lam");
A diagnostic that indicates a problem or potential problem.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
void setSeverityForAll(diag::Flavor Flavor, diag::Severity Map, SourceLocation Loc=SourceLocation())
Add the specified mapping to all diagnostics of the specified flavor.
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.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
DiagnosticConsumer * getClient()
fixit_iterator fixit_end() const
void pushMappings(SourceLocation Loc)
Copies the current DiagMappings and pushes the new copy onto the top of the stack.
range_iterator range_begin() const
static void HandleSelectModifier(const Diagnostic &DInfo, unsigned ValNo, const char *Argument, unsigned ArgumentLen, SmallVectorImpl< char > &OutStr)
HandleSelectModifier - Handle the integer 'select' modifier.
Defines the SourceManager interface.
Represents a diagnostic in a form that can be retained until its corresponding source manager is dest...
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
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.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
bool setDiagnosticGroupWarningAsError(StringRef Group, bool Enabled)
Set the warning-as-error flag for the given diagnostic group.
range_iterator range_end() const
virtual bool IncludeInDiagnosticCounts() const
Indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number...
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing)...
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
void SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1="", StringRef Arg2="")
Set the "delayed" diagnostic that will be emitted once the current diagnostic completes.
bool hasSourceManager() const
static void HandleOrdinalModifier(unsigned ValNo, SmallVectorImpl< char > &OutStr)
HandleOrdinalModifier - Handle the integer 'ord' modifier.
LLVM_DUMP_METHOD void dump() const
void setClient(DiagnosticConsumer *client, bool ShouldOwnClient=true)
Set the diagnostic client associated with this diagnostic object.
void print(raw_ostream &OS, const SourceManager &SM) const
bool setDiagnosticGroupErrorAsFatal(StringRef Group, bool Enabled)
Set the error-as-fatal flag for the given diagnostic group.
unsigned getHashValue() const
Values of this type can be null.
const char * getKeywordSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple keyword and contextual keyword tokens like 'int' and 'dynamic_cast'...
static const char * getTokenDescForDiagnostic(tok::TokenKind Kind)
Returns the friendly description for a token kind that will appear without quotes in diagnostic messa...
const SourceLocation & getLocation() const
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Whether values of this type can be null is (explicitly) unspecified.
bool setSeverityForGroup(diag::Flavor Flavor, StringRef Group, diag::Severity Map, SourceLocation Loc=SourceLocation())
Change an entire diagnostic group (e.g.
Defines the Diagnostic-related interfaces.
Values of this type can never be null.
diag::Severity getSeverity() const
Present this diagnostic as an error.
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type...
StringRef getMessage() const
void Reset()
Reset the state of the diagnostic object to its initial configuration.
bool IncludeInDiagnosticCounts() const override
Indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number...
bool EmitCurrentDiagnostic(bool Force=false)
Emit the current diagnostic and clear the diagnostic state.
A little helper class used to produce diagnostics.
static bool EvalPluralExpr(unsigned ValNo, const char *Start, const char *End)
EvalPluralExpr - Actual expression evaluator for HandlePluralModifier.
std::pair< FileID, unsigned > getDecomposedIncludedLoc(FileID FID) const
Returns the "included/expanded in" decomposed location of the given FileID.
virtual ~DiagnosticConsumer()
bool equals(const til::SExpr *E1, const til::SExpr *E2)
DiagnosticsEngine::Level getLevel() const
unsigned TemplateDiffUsed
const char * getPunctuatorSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple punctuation tokens like '!' or '', and returns NULL for literal and...
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
void Clear()
Clear out the current diagnostic.
static StringRef getWarningOptionForDiag(unsigned DiagID)
Return the lowest-level warning option that enables the specified diagnostic.
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...
fixit_iterator fixit_begin() const
DiagnosticsEngine(IntrusiveRefCntPtr< DiagnosticIDs > Diags, IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, DiagnosticConsumer *client=nullptr, bool ShouldOwnClient=true)
llvm::DOTGraphTraits< ExplodedGraph * > DefaultDOTGraphTraits const ExplodedNode const ExplodedNode *Out<< "\l\|";Out<< "StateID: ST"<< State-> getID()<< "
llvm::MemoryBuffer * getBuffer(FileID FID, SourceLocation Loc, bool *Invalid=nullptr) const
Return the buffer for the specified FileID.
static void getAllDiagnostics(diag::Flavor Flavor, std::vector< diag::kind > &Diags)
Get the set of all diagnostic IDs.
Encodes a location in the source.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
static void HandleIntegerSModifier(unsigned ValNo, SmallVectorImpl< char > &OutStr)
HandleIntegerSModifier - Handle the integer 's' modifier.
void AddString(StringRef S) const
OpenMPLinearClauseKind Modifier
Modifier of 'linear' clause.
void setUpgradedFromWarning(bool Value)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void setNoErrorAsFatal(bool Value)
~ForwardingDiagnosticConsumer() override
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.
Flavor
Flavors of diagnostics we can emit.
SourceManager & getSourceManager() const
Defines various enumerations that describe declaration and type specifiers.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
Present this diagnostic as a remark.
const FullSourceLoc & getLocation() const
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)
Level
The level of the diagnostic, after it has been through mapping.
StoredDiagnostic()=default
LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
void setSeverity(diag::kind Diag, diag::Severity Map, SourceLocation Loc)
This allows the client to specify that certain warnings are ignored.
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...
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
static bool ModifierIs(const char *Modifier, unsigned ModifierLen, const char(&Str)[StrLen])
ModifierIs - Return true if the specified modifier matches specified string.
void setSeverity(diag::Severity Value)
Defines the clang::TokenKind enum and support functions.
static bool TestPluralRange(unsigned Val, const char *&Start, const char *End)
TestPluralRange - Test if Val is in the parsed range. Modifies Start.
Defines the clang::SourceLocation class and associated facilities.
ArrayRef< CharSourceRange > getRanges() const
Return an array reference for this diagnostic's ranges.
ArrayRef< FixItHint > getFixItHints() const
Level
The level of the diagnostic, after it has been through mapping.
Do not present this diagnostic, ignore it.
LLVM_READONLY bool isPunctuation(unsigned char c)
Return true if this character is an ASCII punctuation character.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
const char * getTokenName(TokenKind Kind) LLVM_READNONE
Determines the name of a token as used within the front end.
A SourceLocation and its associated SourceManager.
Defines the Diagnostic IDs-related interfaces.
__DEVICE__ int max(int __a, int __b)
static void HandlePluralModifier(const Diagnostic &DInfo, unsigned ValNo, const char *Argument, unsigned ArgumentLen, SmallVectorImpl< char > &OutStr)
HandlePluralModifier - Handle the integer 'plural' modifier.
Present this diagnostic as a fatal error.
void setNoWarningAsError(bool Value)
static unsigned PluralNumber(const char *&Start, const char *End)
PluralNumber - Parse an unsigned integer and advance Start.
Present this diagnostic as a warning.
void FormatDiagnostic(SmallVectorImpl< char > &OutStr) const
Format this diagnostic into a string, substituting the formal arguments into the %0 slots...
This class handles loading and caching of source files into memory.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
enum TokenKind : unsigned