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 bool ShouldOwnClient) {
94 Owner.reset(ShouldOwnClient ? client :
nullptr);
99 DiagStateOnPushStack.push_back(GetCurDiagState());
103 if (DiagStateOnPushStack.empty())
106 if (DiagStateOnPushStack.back() != GetCurDiagState()) {
108 PushDiagStatePoint(DiagStateOnPushStack.back(), Loc);
110 DiagStateOnPushStack.pop_back();
115 ErrorOccurred =
false;
116 UncompilableErrorOccurred =
false;
117 FatalErrorOccurred =
false;
118 UnrecoverableErrorOccurred =
false;
122 TrapNumErrorsOccurred = 0;
123 TrapNumUnrecoverableErrorsOccurred = 0;
131 DiagStatesByLoc.clear();
132 DiagStateOnPushStack.clear();
136 DiagStates.emplace_back();
137 DiagStatesByLoc.appendFirst(&DiagStates.back());
145 DelayedDiagID = DiagID;
146 DelayedDiagArg1 = Arg1.str();
147 DelayedDiagArg2 = Arg2.str();
150 void DiagnosticsEngine::ReportDelayed() {
151 unsigned ID = DelayedDiagID;
153 Report(ID) << DelayedDiagArg1 << DelayedDiagArg2;
156 void DiagnosticsEngine::DiagStateMap::appendFirst(DiagState *
State) {
157 assert(Files.empty() &&
"not first");
158 FirstDiagState = CurDiagState =
State;
162 void DiagnosticsEngine::DiagStateMap::append(
SourceManager &SrcMgr,
165 CurDiagState =
State;
166 CurDiagStateLoc = Loc;
169 unsigned Offset = Decomp.second;
170 for (File *F = getFile(SrcMgr, Decomp.first); F;
171 Offset = F->ParentOffset, F = F->Parent) {
172 F->HasLocalTransitions =
true;
173 auto &
Last = F->StateTransitions.back();
174 assert(
Last.Offset <= Offset &&
"state transitions added out of order");
176 if (
Last.Offset == Offset) {
177 if (
Last.State == State)
183 F->StateTransitions.push_back({
State, Offset});
187 DiagnosticsEngine::DiagState *
188 DiagnosticsEngine::DiagStateMap::lookup(
SourceManager &SrcMgr,
192 return FirstDiagState;
195 const File *F = getFile(SrcMgr, Decomp.first);
196 return F->lookup(Decomp.second);
199 DiagnosticsEngine::DiagState *
200 DiagnosticsEngine::DiagStateMap::File::lookup(
unsigned Offset)
const {
201 auto OnePastIt = std::upper_bound(
202 StateTransitions.begin(), StateTransitions.end(),
Offset,
203 [](
unsigned Offset,
const DiagStatePoint &
P) {
204 return Offset <
P.Offset;
206 assert(OnePastIt != StateTransitions.begin() &&
"missing initial state");
207 return OnePastIt[-1].State;
210 DiagnosticsEngine::DiagStateMap::File *
211 DiagnosticsEngine::DiagStateMap::getFile(
SourceManager &SrcMgr,
214 auto Range = Files.equal_range(ID);
215 if (Range.first != Range.second)
216 return &Range.first->second;
217 auto &F = Files.insert(Range.first, std::make_pair(ID, File()))->second;
223 F.Parent = getFile(SrcMgr, Decomp.first);
224 F.ParentOffset = Decomp.second;
225 F.StateTransitions.push_back({F.Parent->lookup(Decomp.second), 0});
234 F.StateTransitions.push_back({FirstDiagState, 0});
240 StringRef DiagName)
const {
241 llvm::errs() <<
"diagnostic state at ";
242 CurDiagStateLoc.dump(SrcMgr);
243 llvm::errs() <<
": " << CurDiagState <<
"\n";
245 for (
auto &F : Files) {
247 File &File = F.second;
249 bool PrintedOuterHeading =
false;
250 auto PrintOuterHeading = [&] {
251 if (PrintedOuterHeading)
return;
252 PrintedOuterHeading =
true;
254 llvm::errs() <<
"File " << &File <<
" <FileID " << ID.
getHashValue()
255 <<
">: " << SrcMgr.
getBuffer(ID)->getBufferIdentifier();
256 if (F.second.Parent) {
257 std::pair<FileID, unsigned> Decomp =
259 assert(File.ParentOffset == Decomp.second);
260 llvm::errs() <<
" parent " << File.Parent <<
" <FileID " 261 << Decomp.first.getHashValue() <<
"> ";
266 if (File.HasLocalTransitions)
267 llvm::errs() <<
" has_local_transitions";
268 llvm::errs() <<
"\n";
271 if (DiagName.empty())
274 for (DiagStatePoint &Transition : File.StateTransitions) {
275 bool PrintedInnerHeading =
false;
276 auto PrintInnerHeading = [&] {
277 if (PrintedInnerHeading)
return;
278 PrintedInnerHeading =
true;
285 llvm::errs() <<
": state " << Transition.State <<
":\n";
288 if (DiagName.empty())
291 for (
auto &Mapping : *Transition.State) {
294 if (!DiagName.empty() && DiagName != Option)
300 llvm::errs() <<
"<unknown " << Mapping.first <<
">";
302 llvm::errs() << Option;
303 llvm::errs() <<
": ";
305 switch (Mapping.second.getSeverity()) {
313 if (!Mapping.second.isUser())
314 llvm::errs() <<
" default";
315 if (Mapping.second.isPragma())
316 llvm::errs() <<
" pragma";
317 if (Mapping.second.hasNoWarningAsError())
318 llvm::errs() <<
" no-error";
319 if (Mapping.second.hasNoErrorAsFatal())
320 llvm::errs() <<
" no-fatal";
321 if (Mapping.second.wasUpgradedFromWarning())
322 llvm::errs() <<
" overruled";
323 llvm::errs() <<
"\n";
329 void DiagnosticsEngine::PushDiagStatePoint(DiagState *
State,
331 assert(Loc.
isValid() &&
"Adding invalid loc point");
332 DiagStatesByLoc.append(*SourceMgr, Loc,
State);
338 "Can only map builtin diagnostics");
339 assert((Diags->isBuiltinWarningOrExtension(Diag) ||
341 "Cannot map errors into warnings!");
342 assert((L.
isInvalid() || SourceMgr) &&
"No SourceMgr for valid location");
345 bool WasUpgradedFromWarning =
false;
351 WasUpgradedFromWarning =
true;
358 if ((L.
isInvalid() || L == DiagStatesByLoc.getCurDiagStateLoc()) &&
359 DiagStatesByLoc.getCurDiagState()) {
364 DiagStatesByLoc.getCurDiagState()->setMapping(Diag, Mapping);
371 DiagStates.push_back(*GetCurDiagState());
372 DiagStates.back().setMapping(Diag, Mapping);
373 PushDiagStatePoint(&DiagStates.back(), L);
381 if (Diags->getDiagnosticsInGroup(Flavor, Group, GroupDiags))
456 std::vector<diag::kind> AllDiags;
461 if (Diags->isBuiltinWarningOrExtension(
Diag))
467 "Multiple diagnostics in flight at once!");
470 CurDiagID = storedDiag.
getID();
476 DiagFixItHints.clear();
479 assert(Client &&
"DiagnosticConsumer not set!");
492 assert(
getClient() &&
"DiagnosticClient not set!");
505 Diags->EmitDiag(*
this, DiagLevel);
510 Emitted = ProcessDiag();
517 if (!Force && DelayedDiagID)
527 if (!IncludeInDiagnosticCounts())
537 template <std::
size_t StrLen>
539 const char (&Str)[StrLen]) {
540 return StrLen-1 == ModifierLen && memcmp(Modifier, Str, StrLen-1) == 0;
548 for ( ; I != E; ++I) {
549 if (Depth == 0 && *I == Target)
return I;
550 if (Depth != 0 && *I ==
'}') Depth--;
560 for (I++; I != E && !
isDigit(*I) && *I !=
'{'; I++) ;
576 const char *Argument,
unsigned ArgumentLen,
578 const char *ArgumentEnd = Argument+ArgumentLen;
582 const char *NextVal =
ScanFormat(Argument, ArgumentEnd,
'|');
583 assert(NextVal != ArgumentEnd &&
"Value for integer select modifier was" 584 " larger than the number of options in the diagnostic string!");
585 Argument = NextVal+1;
590 const char *EndPtr =
ScanFormat(Argument, ArgumentEnd,
'|');
602 OutStr.push_back(
's');
611 assert(ValNo != 0 &&
"ValNo must be strictly positive!");
613 llvm::raw_svector_ostream Out(OutStr);
617 Out << ValNo << llvm::getOrdinalSuffix(ValNo);
624 while (Start != End && *Start >=
'0' && *Start <=
'9') {
641 assert(*Start ==
',' &&
"Bad plural expression syntax: expected ,");
644 assert(*Start ==
']' &&
"Bad plural expression syntax: expected )");
646 return Low <= Val && Val <= High;
661 assert(*Start ==
'=' &&
"Bad plural expression syntax: expected =");
663 unsigned ValMod = ValNo % Arg;
667 assert((C ==
'[' || (C >=
'0' && C <=
'9')) &&
668 "Bad plural expression syntax: unexpected character");
675 Start = std::find(Start, End,
',');
717 const char *Argument,
unsigned ArgumentLen,
719 const char *ArgumentEnd = Argument + ArgumentLen;
721 assert(Argument < ArgumentEnd &&
"Plural expression didn't match.");
722 const char *ExprEnd = Argument;
723 while (*ExprEnd !=
':') {
724 assert(ExprEnd != ArgumentEnd &&
"Plural missing expression end");
728 Argument = ExprEnd + 1;
729 ExprEnd =
ScanFormat(Argument, ArgumentEnd,
'|');
736 Argument =
ScanFormat(Argument, ArgumentEnd - 1,
'|') + 1;
745 case tok::identifier:
757 if (!StoredDiagMessage.empty()) {
758 OutStr.append(StoredDiagMessage.begin(), StoredDiagMessage.end());
763 getDiags()->getDiagnosticIDs()->getDescription(getID());
765 FormatDiagnostic(Diag.begin(), Diag.end(), OutStr);
774 if (DiagEnd - DiagStr == 2 &&
775 StringRef(DiagStr, DiagEnd - DiagStr).
equals(
"%0") &&
777 const std::string &S = getArgStdStr(0);
779 if (llvm::sys::locale::isPrint(c) || c ==
'\t') {
797 for (
unsigned i = 0, e = getNumArgs(); i < e; ++i)
799 QualTypeVals.push_back(getRawArg(i));
801 while (DiagStr != DiagEnd) {
802 if (DiagStr[0] !=
'%') {
804 const char *StrEnd = std::find(DiagStr, DiagEnd,
'%');
805 OutStr.append(DiagStr, StrEnd);
809 OutStr.push_back(DiagStr[1]);
822 const char *Modifier =
nullptr, *Argument =
nullptr;
823 unsigned ModifierLen = 0, ArgumentLen = 0;
828 while (DiagStr[0] ==
'-' ||
829 (DiagStr[0] >=
'a' && DiagStr[0] <=
'z'))
834 if (DiagStr[0] ==
'{') {
839 assert(DiagStr != DiagEnd &&
"Mismatched {}'s in diagnostic string!");
840 ArgumentLen = DiagStr-Argument;
845 assert(
isDigit(*DiagStr) &&
"Invalid format for argument in diagnostic");
846 unsigned ArgNo = *DiagStr++ -
'0';
849 unsigned ArgNo2 = ArgNo;
852 if (
ModifierIs(Modifier, ModifierLen,
"diff")) {
853 assert(*DiagStr ==
',' &&
isDigit(*(DiagStr + 1)) &&
854 "Invalid format for diff modifier");
856 ArgNo2 = *DiagStr++ -
'0';
867 const char *ArgumentEnd = Argument + ArgumentLen;
868 const char *Pipe =
ScanFormat(Argument, ArgumentEnd,
'|');
869 assert(
ScanFormat(Pipe + 1, ArgumentEnd,
'|') == ArgumentEnd &&
870 "Found too many '|'s in a %diff modifier!");
871 const char *FirstDollar =
ScanFormat(Argument, Pipe,
'$');
872 const char *SecondDollar =
ScanFormat(FirstDollar + 1, Pipe,
'$');
873 const char ArgStr1[] = {
'%',
static_cast<char>(
'0' + ArgNo) };
874 const char ArgStr2[] = {
'%',
static_cast<char>(
'0' + ArgNo2) };
875 FormatDiagnostic(Argument, FirstDollar, OutStr);
876 FormatDiagnostic(ArgStr1, ArgStr1 + 2, OutStr);
877 FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
878 FormatDiagnostic(ArgStr2, ArgStr2 + 2, OutStr);
879 FormatDiagnostic(SecondDollar + 1, Pipe, OutStr);
887 const std::string &S = getArgStdStr(ArgNo);
888 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
889 OutStr.append(S.begin(), S.end());
893 const char *S = getArgCStr(ArgNo);
894 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
900 OutStr.append(S, S + strlen(S));
905 int Val = getArgSInt(ArgNo);
907 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
910 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
912 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
915 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
918 assert(ModifierLen == 0 &&
"Unknown integer modifier");
919 llvm::raw_svector_ostream(OutStr) << Val;
924 unsigned Val = getArgUInt(ArgNo);
926 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
928 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
930 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
933 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
936 assert(ModifierLen == 0 &&
"Unknown integer modifier");
937 llvm::raw_svector_ostream(OutStr) << Val;
944 assert(ModifierLen == 0 &&
"No modifiers for token kinds yet");
946 llvm::raw_svector_ostream Out(OutStr);
949 Out <<
'\'' << S <<
'\'';
958 Out << '<' << S << '>
'; 963 // ---- NAMES and TYPES ---- 964 case DiagnosticsEngine::ak_identifierinfo: { 965 const IdentifierInfo *II = getArgIdentifier(ArgNo); 966 assert(ModifierLen == 0 && "No modifiers for strings yet"); 968 // Don't crash
if get passed a null pointer by accident.
970 const char *S =
"(null)";
971 OutStr.append(S, S + strlen(S));
975 llvm::raw_svector_ostream(OutStr) <<
'\'' << II->getName() <<
'\'';
984 getDiags()->ConvertArgToString(Kind, getRawArg(ArgNo),
985 StringRef(Modifier, ModifierLen),
986 StringRef(Argument, ArgumentLen),
988 OutStr, QualTypeVals);
994 TDT.
ToType = getRawArg(ArgNo2);
1000 const char *ArgumentEnd = Argument + ArgumentLen;
1001 const char *Pipe =
ScanFormat(Argument, ArgumentEnd,
'|');
1005 if (getDiags()->PrintTemplateTree && Tree.empty()) {
1008 getDiags()->ConvertArgToString(Kind, val,
1009 StringRef(Modifier, ModifierLen),
1010 StringRef(Argument, ArgumentLen),
1012 Tree, QualTypeVals);
1014 if (!Tree.empty()) {
1015 FormatDiagnostic(Pipe + 1, ArgumentEnd, OutStr);
1022 const char *FirstDollar =
ScanFormat(Argument, ArgumentEnd,
'$');
1023 const char *SecondDollar =
ScanFormat(FirstDollar + 1, ArgumentEnd,
'$');
1026 FormatDiagnostic(Argument, FirstDollar, OutStr);
1031 getDiags()->ConvertArgToString(Kind, val,
1032 StringRef(Modifier, ModifierLen),
1033 StringRef(Argument, ArgumentLen),
1035 OutStr, QualTypeVals);
1041 FormatDiagnostic(FirstDollar + 1, SecondDollar, OutStr);
1045 getDiags()->ConvertArgToString(Kind, val,
1046 StringRef(Modifier, ModifierLen),
1047 StringRef(Argument, ArgumentLen),
1049 OutStr, QualTypeVals);
1055 FormatDiagnostic(SecondDollar + 1, Pipe, OutStr);
1066 FormattedArgs.push_back(std::make_pair(Kind, getRawArg(ArgNo)));
1069 (
intptr_t)getArgStdStr(ArgNo).c_str()));
1073 OutStr.append(Tree.begin(), Tree.end());
1078 : ID(ID), Level(Level), Message(Message) {}
1082 : ID(Info.
getID()), Level(Level) {
1084 "Valid source location without setting a source manager for diagnostic");
1089 this->Message.assign(Message.begin(), Message.end());
1098 : ID(ID), Level(Level), Loc(Loc), Message(Message),
1099 Ranges(Ranges.begin(), Ranges.end()), FixIts(FixIts.begin(), FixIts.end())
1109 void IgnoringDiagConsumer::anchor() {}
1116 Target.HandleDiagnostic(DiagLevel, Info);
1125 return Target.IncludeInDiagnosticCounts();
1129 for (
unsigned I = 0; I != NumCached; ++I)
1130 FreeList[I] = Cached + I;
1131 NumFreeListEntries = NumCached;
1137 assert((NumFreeListEntries == NumCached ||
1138 llvm::CrashRecoveryContext::isRecoveringFromCrash()) &&
1139 "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.
void setClient(DiagnosticConsumer *client, bool ShouldOwnClient=true)
Set the diagnostic client associated with this diagnostic object.
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.
void dump(const SourceManager &SM) const
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::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