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/CrashRecoveryContext.h" 29 #include "llvm/Support/Locale.h" 30 #include "llvm/Support/raw_ostream.h" 41 using namespace clang;
46 switch (nullability.first) {
48 string = nullability.second ?
"'nonnull'" :
"'_Nonnull'";
52 string = nullability.second ?
"'nullable'" :
"'_Nullable'";
56 string = nullability.second ?
"'null_unspecified'" :
"'_Null_unspecified'";
65 StringRef
Modifier, StringRef Argument,
70 StringRef Str =
"<can't format argument>";
71 Output.append(Str.begin(), Str.end());
78 : Diags(
std::move(diags)), DiagOpts(
std::move(DiagOpts)) {
92 DiagStatesByLoc.dump(*SourceMgr);
96 DiagStatesByLoc.dump(*SourceMgr, DiagName);
100 bool ShouldOwnClient) {
101 Owner.reset(ShouldOwnClient ? client :
nullptr);
106 DiagStateOnPushStack.push_back(GetCurDiagState());
110 if (DiagStateOnPushStack.empty())
113 if (DiagStateOnPushStack.back() != GetCurDiagState()) {
115 PushDiagStatePoint(DiagStateOnPushStack.back(), Loc);
117 DiagStateOnPushStack.pop_back();
122 ErrorOccurred =
false;
123 UncompilableErrorOccurred =
false;
124 FatalErrorOccurred =
false;
125 UnrecoverableErrorOccurred =
false;
129 TrapNumErrorsOccurred = 0;
130 TrapNumUnrecoverableErrorsOccurred = 0;
138 DiagStatesByLoc.clear();
139 DiagStateOnPushStack.clear();
143 DiagStates.emplace_back();
144 DiagStatesByLoc.appendFirst(&DiagStates.back());
148 StringRef Arg2, StringRef Arg3) {
152 DelayedDiagID = DiagID;
153 DelayedDiagArg1 = Arg1.str();
154 DelayedDiagArg2 = Arg2.str();
155 DelayedDiagArg3 = Arg3.str();
158 void DiagnosticsEngine::ReportDelayed() {
159 unsigned ID = DelayedDiagID;
161 Report(ID) << DelayedDiagArg1 << DelayedDiagArg2 << DelayedDiagArg3;
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 {
210 llvm::partition_point(StateTransitions, [=](
const DiagStatePoint &
P) {
211 return P.Offset <=
Offset;
213 assert(OnePastIt != StateTransitions.begin() &&
"missing initial state");
214 return OnePastIt[-1].State;
217 DiagnosticsEngine::DiagStateMap::File *
218 DiagnosticsEngine::DiagStateMap::getFile(
SourceManager &SrcMgr,
221 auto Range = Files.equal_range(ID);
222 if (Range.first != Range.second)
223 return &Range.first->second;
224 auto &F = Files.insert(Range.first, std::make_pair(ID, File()))->second;
230 F.Parent = getFile(SrcMgr, Decomp.first);
231 F.ParentOffset = Decomp.second;
232 F.StateTransitions.push_back({F.Parent->lookup(Decomp.second), 0});
241 F.StateTransitions.push_back({FirstDiagState, 0});
247 StringRef DiagName)
const {
248 llvm::errs() <<
"diagnostic state at ";
249 CurDiagStateLoc.print(llvm::errs(), SrcMgr);
250 llvm::errs() <<
": " << CurDiagState <<
"\n";
252 for (
auto &F : Files) {
254 File &File = F.second;
256 bool PrintedOuterHeading =
false;
257 auto PrintOuterHeading = [&] {
258 if (PrintedOuterHeading)
return;
259 PrintedOuterHeading =
true;
261 llvm::errs() <<
"File " << &File <<
" <FileID " << ID.
getHashValue()
262 <<
">: " << SrcMgr.
getBuffer(ID)->getBufferIdentifier();
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";
336 void 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;
365 if ((L.
isInvalid() || L == DiagStatesByLoc.getCurDiagStateLoc()) &&
366 DiagStatesByLoc.getCurDiagState()) {
371 DiagStatesByLoc.getCurDiagState()->setMapping(Diag, Mapping);
378 DiagStates.push_back(*GetCurDiagState());
379 DiagStates.back().setMapping(Diag, Mapping);
380 PushDiagStatePoint(&DiagStates.back(), L);
388 if (Diags->getDiagnosticsInGroup(Flavor, Group, GroupDiags))
463 std::vector<diag::kind> AllDiags;
468 if (Diags->isBuiltinWarningOrExtension(
Diag))
474 "Multiple diagnostics in flight at once!");
477 CurDiagID = storedDiag.
getID();
483 DiagFixItHints.clear();
486 assert(Client &&
"DiagnosticConsumer not set!");
499 assert(
getClient() &&
"DiagnosticClient not set!");
512 Diags->EmitDiag(*
this, DiagLevel);
517 Emitted = ProcessDiag();
524 if (!Force && DelayedDiagID)
534 if (!IncludeInDiagnosticCounts())
544 template <std::
size_t StrLen>
546 const char (&Str)[StrLen]) {
547 return StrLen-1 == ModifierLen && memcmp(Modifier, Str, StrLen-1) == 0;
555 for ( ; I != E; ++I) {
556 if (Depth == 0 && *I == Target)
return I;
557 if (Depth != 0 && *I ==
'}') Depth--;
567 for (I++; I != E && !
isDigit(*I) && *I !=
'{'; I++) ;
583 const char *Argument,
unsigned ArgumentLen,
585 const char *ArgumentEnd = Argument+ArgumentLen;
589 const char *NextVal =
ScanFormat(Argument, ArgumentEnd,
'|');
590 assert(NextVal != ArgumentEnd &&
"Value for integer select modifier was" 591 " larger than the number of options in the diagnostic string!");
592 Argument = NextVal+1;
597 const char *EndPtr =
ScanFormat(Argument, ArgumentEnd,
'|');
609 OutStr.push_back(
's');
618 assert(ValNo != 0 &&
"ValNo must be strictly positive!");
620 llvm::raw_svector_ostream Out(OutStr);
624 Out << ValNo << llvm::getOrdinalSuffix(ValNo);
631 while (Start != End && *Start >=
'0' && *Start <=
'9') {
648 assert(*Start ==
',' &&
"Bad plural expression syntax: expected ,");
651 assert(*Start ==
']' &&
"Bad plural expression syntax: expected )");
653 return Low <= Val && Val <= High;
668 assert(*Start ==
'=' &&
"Bad plural expression syntax: expected =");
670 unsigned ValMod = ValNo % Arg;
674 assert((C ==
'[' || (C >=
'0' && C <=
'9')) &&
675 "Bad plural expression syntax: unexpected character");
682 Start = std::find(Start, End,
',');
724 const char *Argument,
unsigned ArgumentLen,
726 const char *ArgumentEnd = Argument + ArgumentLen;
728 assert(Argument < ArgumentEnd &&
"Plural expression didn't match.");
729 const char *ExprEnd = Argument;
730 while (*ExprEnd !=
':') {
731 assert(ExprEnd != ArgumentEnd &&
"Plural missing expression end");
735 Argument = ExprEnd + 1;
736 ExprEnd =
ScanFormat(Argument, ArgumentEnd,
'|');
743 Argument =
ScanFormat(Argument, ArgumentEnd - 1,
'|') + 1;
752 case tok::identifier:
764 if (!StoredDiagMessage.empty()) {
765 OutStr.append(StoredDiagMessage.begin(), StoredDiagMessage.end());
770 getDiags()->getDiagnosticIDs()->getDescription(getID());
772 FormatDiagnostic(Diag.begin(), Diag.end(), OutStr);
781 if (DiagEnd - DiagStr == 2 &&
782 StringRef(DiagStr, DiagEnd - DiagStr).
equals(
"%0") &&
784 const std::string &S = getArgStdStr(0);
786 if (llvm::sys::locale::isPrint(c) || c ==
'\t') {
804 for (
unsigned i = 0, e = getNumArgs(); i < e; ++i)
806 QualTypeVals.push_back(getRawArg(i));
808 while (DiagStr != DiagEnd) {
809 if (DiagStr[0] !=
'%') {
811 const char *StrEnd = std::find(DiagStr, DiagEnd,
'%');
812 OutStr.append(DiagStr, StrEnd);
816 OutStr.push_back(DiagStr[1]);
829 const char *Modifier =
nullptr, *Argument =
nullptr;
830 unsigned ModifierLen = 0, ArgumentLen = 0;
835 while (DiagStr[0] ==
'-' ||
836 (DiagStr[0] >=
'a' && DiagStr[0] <=
'z'))
841 if (DiagStr[0] ==
'{') {
846 assert(DiagStr != DiagEnd &&
"Mismatched {}'s in diagnostic string!");
847 ArgumentLen = DiagStr-Argument;
852 assert(
isDigit(*DiagStr) &&
"Invalid format for argument in diagnostic");
853 unsigned ArgNo = *DiagStr++ -
'0';
856 unsigned ArgNo2 = ArgNo;
859 if (
ModifierIs(Modifier, ModifierLen,
"diff")) {
860 assert(*DiagStr ==
',' &&
isDigit(*(DiagStr + 1)) &&
861 "Invalid format for diff modifier");
863 ArgNo2 = *DiagStr++ -
'0';
874 const char *ArgumentEnd = Argument + ArgumentLen;
875 const char *Pipe =
ScanFormat(Argument, ArgumentEnd,
'|');
876 assert(
ScanFormat(Pipe + 1, ArgumentEnd,
'|') == ArgumentEnd &&
877 "Found too many '|'s in a %diff modifier!");
878 const char *FirstDollar =
ScanFormat(Argument, Pipe,
'$');
879 const char *SecondDollar =
ScanFormat(FirstDollar + 1, Pipe,
'$');
880 const char ArgStr1[] = {
'%',
static_cast<char>(
'0' + ArgNo) };
881 const char ArgStr2[] = {
'%',
static_cast<char>(
'0' + ArgNo2) };
882 FormatDiagnostic(Argument, FirstDollar, OutStr);
883 FormatDiagnostic(ArgStr1, ArgStr1 + 2, OutStr);
884 FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
885 FormatDiagnostic(ArgStr2, ArgStr2 + 2, OutStr);
886 FormatDiagnostic(SecondDollar + 1, Pipe, OutStr);
894 const std::string &S = getArgStdStr(ArgNo);
895 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
896 OutStr.append(S.begin(), S.end());
900 const char *S = getArgCStr(ArgNo);
901 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
907 OutStr.append(S, S + strlen(S));
912 int Val = getArgSInt(ArgNo);
914 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
917 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
919 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
922 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
925 assert(ModifierLen == 0 &&
"Unknown integer modifier");
926 llvm::raw_svector_ostream(OutStr) << Val;
931 unsigned Val = getArgUInt(ArgNo);
933 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
935 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
937 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
940 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
943 assert(ModifierLen == 0 &&
"Unknown integer modifier");
944 llvm::raw_svector_ostream(OutStr) << Val;
951 assert(ModifierLen == 0 &&
"No modifiers for token kinds yet");
953 llvm::raw_svector_ostream Out(OutStr);
956 Out <<
'\'' << S <<
'\'';
965 Out << '<' << S << '>
'; 970 // ---- NAMES and TYPES ---- 971 case DiagnosticsEngine::ak_identifierinfo: { 972 const IdentifierInfo *II = getArgIdentifier(ArgNo); 973 assert(ModifierLen == 0 && "No modifiers for strings yet"); 975 // Don't crash
if get passed a null pointer by accident.
977 const char *S =
"(null)";
978 OutStr.append(S, S + strlen(S));
982 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...
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
__DEVICE__ int max(int __a, int __b)
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.
void SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1="", StringRef Arg2="", StringRef Arg3="")
Set the "delayed" diagnostic that will be emitted once the current diagnostic completes.
Defines the Diagnostic-related interfaces.
Values of this type can never be null.
diag::Severity getSeverity() const
Present this diagnostic as an error.
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)
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type...
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...
const llvm::MemoryBuffer * getBuffer(FileID FID, SourceLocation Loc, bool *Invalid=nullptr) const
Return the buffer for the specified FileID.
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.
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