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());
152 DelayedDiagID = DiagID;
153 DelayedDiagArg1 = Arg1.str();
154 DelayedDiagArg2 = Arg2.str();
157 void DiagnosticsEngine::ReportDelayed() {
158 unsigned ID = DelayedDiagID;
160 Report(ID) << DelayedDiagArg1 << DelayedDiagArg2;
163 void DiagnosticsEngine::DiagStateMap::appendFirst(DiagState *
State) {
164 assert(Files.empty() &&
"not first");
165 FirstDiagState = CurDiagState =
State;
169 void 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");
183 if (
Last.Offset == Offset) {
184 if (
Last.State == State)
190 F->StateTransitions.push_back({
State, Offset});
194 DiagnosticsEngine::DiagState *
195 DiagnosticsEngine::DiagStateMap::lookup(
SourceManager &SrcMgr,
199 return FirstDiagState;
202 const File *F = getFile(SrcMgr, Decomp.first);
203 return F->lookup(Decomp.second);
206 DiagnosticsEngine::DiagState *
207 DiagnosticsEngine::DiagStateMap::File::lookup(
unsigned Offset)
const {
209 llvm::partition_point(StateTransitions, [=](
const DiagStatePoint &
P) {
210 return P.Offset <=
Offset;
212 assert(OnePastIt != StateTransitions.begin() &&
"missing initial state");
213 return OnePastIt[-1].State;
216 DiagnosticsEngine::DiagStateMap::File *
217 DiagnosticsEngine::DiagStateMap::getFile(
SourceManager &SrcMgr,
220 auto Range = Files.equal_range(ID);
221 if (Range.first != Range.second)
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});
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) {
253 File &File = F.second;
255 bool PrintedOuterHeading =
false;
256 auto PrintOuterHeading = [&] {
257 if (PrintedOuterHeading)
return;
258 PrintedOuterHeading =
true;
260 llvm::errs() <<
"File " << &File <<
" <FileID " << ID.
getHashValue()
261 <<
">: " << SrcMgr.
getBuffer(ID)->getBufferIdentifier();
262 if (F.second.Parent) {
263 std::pair<FileID, unsigned> Decomp =
265 assert(File.ParentOffset == Decomp.second);
266 llvm::errs() <<
" parent " << File.Parent <<
" <FileID " 267 << Decomp.first.getHashValue() <<
"> ";
270 .
print(llvm::errs(), SrcMgr);
272 if (File.HasLocalTransitions)
273 llvm::errs() <<
" has_local_transitions";
274 llvm::errs() <<
"\n";
277 if (DiagName.empty())
280 for (DiagStatePoint &Transition : File.StateTransitions) {
281 bool PrintedInnerHeading =
false;
282 auto PrintInnerHeading = [&] {
283 if (PrintedInnerHeading)
return;
284 PrintedInnerHeading =
true;
290 .
print(llvm::errs(), SrcMgr);
291 llvm::errs() <<
": state " << Transition.State <<
":\n";
294 if (DiagName.empty())
297 for (
auto &Mapping : *Transition.State) {
300 if (!DiagName.empty() && DiagName != Option)
306 llvm::errs() <<
"<unknown " << Mapping.first <<
">";
308 llvm::errs() << Option;
309 llvm::errs() <<
": ";
311 switch (Mapping.second.getSeverity()) {
319 if (!Mapping.second.isUser())
320 llvm::errs() <<
" default";
321 if (Mapping.second.isPragma())
322 llvm::errs() <<
" pragma";
323 if (Mapping.second.hasNoWarningAsError())
324 llvm::errs() <<
" no-error";
325 if (Mapping.second.hasNoErrorAsFatal())
326 llvm::errs() <<
" no-fatal";
327 if (Mapping.second.wasUpgradedFromWarning())
328 llvm::errs() <<
" overruled";
329 llvm::errs() <<
"\n";
335 void DiagnosticsEngine::PushDiagStatePoint(DiagState *
State,
337 assert(Loc.
isValid() &&
"Adding invalid loc point");
338 DiagStatesByLoc.append(*SourceMgr, Loc,
State);
344 "Can only map builtin diagnostics");
345 assert((Diags->isBuiltinWarningOrExtension(Diag) ||
347 "Cannot map errors into warnings!");
348 assert((L.
isInvalid() || SourceMgr) &&
"No SourceMgr for valid location");
351 bool WasUpgradedFromWarning =
false;
357 WasUpgradedFromWarning =
true;
364 if ((L.
isInvalid() || L == DiagStatesByLoc.getCurDiagStateLoc()) &&
365 DiagStatesByLoc.getCurDiagState()) {
370 DiagStatesByLoc.getCurDiagState()->setMapping(Diag, Mapping);
377 DiagStates.push_back(*GetCurDiagState());
378 DiagStates.back().setMapping(Diag, Mapping);
379 PushDiagStatePoint(&DiagStates.back(), L);
387 if (Diags->getDiagnosticsInGroup(Flavor, Group, GroupDiags))
462 std::vector<diag::kind> AllDiags;
467 if (Diags->isBuiltinWarningOrExtension(
Diag))
473 "Multiple diagnostics in flight at once!");
476 CurDiagID = storedDiag.
getID();
482 DiagFixItHints.clear();
485 assert(Client &&
"DiagnosticConsumer not set!");
498 assert(
getClient() &&
"DiagnosticClient not set!");
511 Diags->EmitDiag(*
this, DiagLevel);
516 Emitted = ProcessDiag();
523 if (!Force && DelayedDiagID)
533 if (!IncludeInDiagnosticCounts())
543 template <std::
size_t StrLen>
545 const char (&Str)[StrLen]) {
546 return StrLen-1 == ModifierLen && memcmp(Modifier, Str, StrLen-1) == 0;
554 for ( ; I != E; ++I) {
555 if (Depth == 0 && *I == Target)
return I;
556 if (Depth != 0 && *I ==
'}') Depth--;
566 for (I++; I != E && !
isDigit(*I) && *I !=
'{'; I++) ;
582 const char *Argument,
unsigned ArgumentLen,
584 const char *ArgumentEnd = Argument+ArgumentLen;
588 const char *NextVal =
ScanFormat(Argument, ArgumentEnd,
'|');
589 assert(NextVal != ArgumentEnd &&
"Value for integer select modifier was" 590 " larger than the number of options in the diagnostic string!");
591 Argument = NextVal+1;
596 const char *EndPtr =
ScanFormat(Argument, ArgumentEnd,
'|');
608 OutStr.push_back(
's');
617 assert(ValNo != 0 &&
"ValNo must be strictly positive!");
619 llvm::raw_svector_ostream Out(OutStr);
623 Out << ValNo << llvm::getOrdinalSuffix(ValNo);
630 while (Start != End && *Start >=
'0' && *Start <=
'9') {
647 assert(*Start ==
',' &&
"Bad plural expression syntax: expected ,");
650 assert(*Start ==
']' &&
"Bad plural expression syntax: expected )");
652 return Low <= Val && Val <= High;
667 assert(*Start ==
'=' &&
"Bad plural expression syntax: expected =");
669 unsigned ValMod = ValNo % Arg;
673 assert((C ==
'[' || (C >=
'0' && C <=
'9')) &&
674 "Bad plural expression syntax: unexpected character");
681 Start = std::find(Start, End,
',');
723 const char *Argument,
unsigned ArgumentLen,
725 const char *ArgumentEnd = Argument + ArgumentLen;
727 assert(Argument < ArgumentEnd &&
"Plural expression didn't match.");
728 const char *ExprEnd = Argument;
729 while (*ExprEnd !=
':') {
730 assert(ExprEnd != ArgumentEnd &&
"Plural missing expression end");
734 Argument = ExprEnd + 1;
735 ExprEnd =
ScanFormat(Argument, ArgumentEnd,
'|');
742 Argument =
ScanFormat(Argument, ArgumentEnd - 1,
'|') + 1;
751 case tok::identifier:
763 if (!StoredDiagMessage.empty()) {
764 OutStr.append(StoredDiagMessage.begin(), StoredDiagMessage.end());
769 getDiags()->getDiagnosticIDs()->getDescription(getID());
771 FormatDiagnostic(Diag.begin(), Diag.end(), OutStr);
780 if (DiagEnd - DiagStr == 2 &&
781 StringRef(DiagStr, DiagEnd - DiagStr).
equals(
"%0") &&
783 const std::string &S = getArgStdStr(0);
785 if (llvm::sys::locale::isPrint(
c) ||
c ==
'\t') {
803 for (
unsigned i = 0, e = getNumArgs();
i < e; ++
i)
805 QualTypeVals.push_back(getRawArg(
i));
807 while (DiagStr != DiagEnd) {
808 if (DiagStr[0] !=
'%') {
810 const char *StrEnd = std::find(DiagStr, DiagEnd,
'%');
811 OutStr.append(DiagStr, StrEnd);
815 OutStr.push_back(DiagStr[1]);
828 const char *Modifier =
nullptr, *Argument =
nullptr;
829 unsigned ModifierLen = 0, ArgumentLen = 0;
834 while (DiagStr[0] ==
'-' ||
835 (DiagStr[0] >=
'a' && DiagStr[0] <=
'z'))
840 if (DiagStr[0] ==
'{') {
845 assert(DiagStr != DiagEnd &&
"Mismatched {}'s in diagnostic string!");
846 ArgumentLen = DiagStr-Argument;
851 assert(
isDigit(*DiagStr) &&
"Invalid format for argument in diagnostic");
852 unsigned ArgNo = *DiagStr++ -
'0';
855 unsigned ArgNo2 = ArgNo;
858 if (
ModifierIs(Modifier, ModifierLen,
"diff")) {
859 assert(*DiagStr ==
',' &&
isDigit(*(DiagStr + 1)) &&
860 "Invalid format for diff modifier");
862 ArgNo2 = *DiagStr++ -
'0';
873 const char *ArgumentEnd = Argument + ArgumentLen;
874 const char *Pipe =
ScanFormat(Argument, ArgumentEnd,
'|');
875 assert(
ScanFormat(Pipe + 1, ArgumentEnd,
'|') == ArgumentEnd &&
876 "Found too many '|'s in a %diff modifier!");
877 const char *FirstDollar =
ScanFormat(Argument, Pipe,
'$');
878 const char *SecondDollar =
ScanFormat(FirstDollar + 1, Pipe,
'$');
879 const char ArgStr1[] = {
'%',
static_cast<char>(
'0' + ArgNo) };
880 const char ArgStr2[] = {
'%',
static_cast<char>(
'0' + ArgNo2) };
881 FormatDiagnostic(Argument, FirstDollar, OutStr);
882 FormatDiagnostic(ArgStr1, ArgStr1 + 2, OutStr);
883 FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
884 FormatDiagnostic(ArgStr2, ArgStr2 + 2, OutStr);
885 FormatDiagnostic(SecondDollar + 1, Pipe, OutStr);
893 const std::string &S = getArgStdStr(ArgNo);
894 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
895 OutStr.append(S.begin(), S.end());
899 const char *S = getArgCStr(ArgNo);
900 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
906 OutStr.append(S, S + strlen(S));
911 int Val = getArgSInt(ArgNo);
913 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
916 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
918 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
921 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
924 assert(ModifierLen == 0 &&
"Unknown integer modifier");
925 llvm::raw_svector_ostream(OutStr) << Val;
930 unsigned Val = getArgUInt(ArgNo);
932 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
934 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
936 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
939 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
942 assert(ModifierLen == 0 &&
"Unknown integer modifier");
943 llvm::raw_svector_ostream(OutStr) << Val;
950 assert(ModifierLen == 0 &&
"No modifiers for token kinds yet");
952 llvm::raw_svector_ostream Out(OutStr);
955 Out <<
'\'' << S <<
'\'';
964 Out << '<' << S << '>
'; 969 // ---- NAMES and TYPES ---- 970 case DiagnosticsEngine::ak_identifierinfo: { 971 const IdentifierInfo *II = getArgIdentifier(ArgNo); 972 assert(ModifierLen == 0 && "No modifiers for strings yet"); 974 // Don't crash
if get passed
a null pointer by accident.
976 const char *S =
"(null)";
977 OutStr.append(S, S + strlen(S));
981 llvm::raw_svector_ostream(OutStr) <<
'\'' << II->getName() <<
'\'';
991 getDiags()->ConvertArgToString(Kind, getRawArg(ArgNo),
992 StringRef(Modifier, ModifierLen),
993 StringRef(Argument, ArgumentLen),
995 OutStr, QualTypeVals);
1001 TDT.
ToType = getRawArg(ArgNo2);
1007 const char *ArgumentEnd = Argument + ArgumentLen;
1008 const char *Pipe =
ScanFormat(Argument, ArgumentEnd,
'|');
1012 if (getDiags()->PrintTemplateTree && Tree.empty()) {
1015 getDiags()->ConvertArgToString(Kind, val,
1016 StringRef(Modifier, ModifierLen),
1017 StringRef(Argument, ArgumentLen),
1019 Tree, QualTypeVals);
1021 if (!Tree.empty()) {
1022 FormatDiagnostic(Pipe + 1, ArgumentEnd, OutStr);
1029 const char *FirstDollar =
ScanFormat(Argument, ArgumentEnd,
'$');
1030 const char *SecondDollar =
ScanFormat(FirstDollar + 1, ArgumentEnd,
'$');
1033 FormatDiagnostic(Argument, FirstDollar, OutStr);
1038 getDiags()->ConvertArgToString(Kind, val,
1039 StringRef(Modifier, ModifierLen),
1040 StringRef(Argument, ArgumentLen),
1042 OutStr, QualTypeVals);
1048 FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
1052 getDiags()->ConvertArgToString(Kind, val,
1053 StringRef(Modifier, ModifierLen),
1054 StringRef(Argument, ArgumentLen),
1056 OutStr, QualTypeVals);
1062 FormatDiagnostic(SecondDollar + 1, Pipe, OutStr);
1073 FormattedArgs.push_back(std::make_pair(Kind, getRawArg(ArgNo)));
1076 (
intptr_t)getArgStdStr(ArgNo).c_str()));
1080 OutStr.append(Tree.begin(), Tree.end());
1085 : ID(ID), Level(Level), Message(Message) {}
1089 : ID(Info.
getID()), Level(Level) {
1091 "Valid source location without setting a source manager for diagnostic");
1096 this->Message.assign(Message.begin(), Message.end());
1105 : ID(ID), Level(Level), Loc(Loc), Message(Message),
1106 Ranges(Ranges.begin(), Ranges.end()), FixIts(FixIts.begin(), FixIts.end())
1116 void IgnoringDiagConsumer::anchor() {}
1123 Target.HandleDiagnostic(DiagLevel, Info);
1132 return Target.IncludeInDiagnosticCounts();
1136 for (
unsigned I = 0; I != NumCached; ++I)
1137 FreeList[I] = Cached + I;
1138 NumFreeListEntries = NumCached;
1144 assert((NumFreeListEntries == NumCached ||
1145 llvm::CrashRecoveryContext::isRecoveringFromCrash()) &&
1146 "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
__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.
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