Go to the documentation of this file.
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'";
60 assert(!nullability.second &&
61 "_Nullable_result isn't supported as context-sensitive keyword");
62 string =
"_Nullable_result";
77 StringRef Modifier, StringRef Argument,
82 StringRef Str =
"<can't format argument>";
83 Output.append(Str.begin(), Str.end());
90 : Diags(
std::move(diags)), DiagOpts(
std::move(DiagOpts)) {
104 DiagStatesByLoc.dump(*SourceMgr);
108 DiagStatesByLoc.dump(*SourceMgr, DiagName);
112 bool ShouldOwnClient) {
113 Owner.reset(ShouldOwnClient ? client :
nullptr);
118 DiagStateOnPushStack.push_back(GetCurDiagState());
122 if (DiagStateOnPushStack.empty())
125 if (DiagStateOnPushStack.back() != GetCurDiagState()) {
127 PushDiagStatePoint(DiagStateOnPushStack.back(), Loc);
129 DiagStateOnPushStack.pop_back();
134 ErrorOccurred =
false;
135 UncompilableErrorOccurred =
false;
136 FatalErrorOccurred =
false;
137 UnrecoverableErrorOccurred =
false;
141 TrapNumErrorsOccurred = 0;
142 TrapNumUnrecoverableErrorsOccurred = 0;
150 DiagStatesByLoc.clear();
151 DiagStateOnPushStack.clear();
155 DiagStates.emplace_back();
156 DiagStatesByLoc.appendFirst(&DiagStates.back());
160 StringRef Arg2, StringRef Arg3) {
164 DelayedDiagID = DiagID;
165 DelayedDiagArg1 = Arg1.str();
166 DelayedDiagArg2 = Arg2.str();
167 DelayedDiagArg3 = Arg3.str();
170 void DiagnosticsEngine::ReportDelayed() {
171 unsigned ID = DelayedDiagID;
173 Report(
ID) << DelayedDiagArg1 << DelayedDiagArg2 << DelayedDiagArg3;
176 void DiagnosticsEngine::DiagStateMap::appendFirst(DiagState *
State) {
177 assert(Files.empty() &&
"not first");
178 FirstDiagState = CurDiagState =
State;
182 void DiagnosticsEngine::DiagStateMap::append(
SourceManager &SrcMgr,
185 CurDiagState =
State;
186 CurDiagStateLoc = Loc;
189 unsigned Offset = Decomp.second;
190 for (File *F = getFile(SrcMgr, Decomp.first); F;
191 Offset = F->ParentOffset, F = F->Parent) {
192 F->HasLocalTransitions =
true;
193 auto &
Last = F->StateTransitions.back();
194 assert(
Last.Offset <=
Offset &&
"state transitions added out of order");
207 DiagnosticsEngine::DiagState *
208 DiagnosticsEngine::DiagStateMap::lookup(
SourceManager &SrcMgr,
212 return FirstDiagState;
215 const File *F = getFile(SrcMgr, Decomp.first);
216 return F->lookup(Decomp.second);
219 DiagnosticsEngine::DiagState *
220 DiagnosticsEngine::DiagStateMap::File::lookup(
unsigned Offset)
const {
222 llvm::partition_point(StateTransitions, [=](
const DiagStatePoint &
P) {
225 assert(OnePastIt != StateTransitions.begin() &&
"missing initial state");
226 return OnePastIt[-1].State;
229 DiagnosticsEngine::DiagStateMap::File *
230 DiagnosticsEngine::DiagStateMap::getFile(
SourceManager &SrcMgr,
233 auto Range = Files.equal_range(
ID);
235 return &
Range.first->second;
236 auto &F = Files.insert(
Range.first, std::make_pair(
ID,
File()))->second;
242 F.Parent = getFile(SrcMgr, Decomp.first);
243 F.ParentOffset = Decomp.second;
244 F.StateTransitions.push_back({F.Parent->lookup(Decomp.second), 0});
253 F.StateTransitions.push_back({FirstDiagState, 0});
259 StringRef DiagName)
const {
260 llvm::errs() <<
"diagnostic state at ";
261 CurDiagStateLoc.print(llvm::errs(), SrcMgr);
262 llvm::errs() <<
": " << CurDiagState <<
"\n";
264 for (
auto &F : Files) {
268 bool PrintedOuterHeading =
false;
269 auto PrintOuterHeading = [&] {
270 if (PrintedOuterHeading)
return;
271 PrintedOuterHeading =
true;
273 llvm::errs() <<
"File " << &
File <<
" <FileID " <<
ID.getHashValue()
276 if (F.second.Parent) {
277 std::pair<FileID, unsigned> Decomp =
279 assert(
File.ParentOffset == Decomp.second);
280 llvm::errs() <<
" parent " <<
File.Parent <<
" <FileID "
281 << Decomp.first.getHashValue() <<
"> ";
284 .
print(llvm::errs(), SrcMgr);
286 if (
File.HasLocalTransitions)
287 llvm::errs() <<
" has_local_transitions";
288 llvm::errs() <<
"\n";
291 if (DiagName.empty())
294 for (DiagStatePoint &Transition :
File.StateTransitions) {
295 bool PrintedInnerHeading =
false;
296 auto PrintInnerHeading = [&] {
297 if (PrintedInnerHeading)
return;
298 PrintedInnerHeading =
true;
304 .
print(llvm::errs(), SrcMgr);
305 llvm::errs() <<
": state " << Transition.State <<
":\n";
308 if (DiagName.empty())
311 for (
auto &Mapping : *Transition.State) {
314 if (!DiagName.empty() && DiagName != Option)
320 llvm::errs() <<
"<unknown " << Mapping.first <<
">";
322 llvm::errs() << Option;
323 llvm::errs() <<
": ";
325 switch (Mapping.second.getSeverity()) {
333 if (!Mapping.second.isUser())
334 llvm::errs() <<
" default";
335 if (Mapping.second.isPragma())
336 llvm::errs() <<
" pragma";
337 if (Mapping.second.hasNoWarningAsError())
338 llvm::errs() <<
" no-error";
339 if (Mapping.second.hasNoErrorAsFatal())
340 llvm::errs() <<
" no-fatal";
341 if (Mapping.second.wasUpgradedFromWarning())
342 llvm::errs() <<
" overruled";
343 llvm::errs() <<
"\n";
349 void DiagnosticsEngine::PushDiagStatePoint(DiagState *
State,
351 assert(Loc.
isValid() &&
"Adding invalid loc point");
352 DiagStatesByLoc.append(*SourceMgr, Loc,
State);
358 "Can only map builtin diagnostics");
359 assert((Diags->isBuiltinWarningOrExtension(
Diag) ||
361 "Cannot map errors into warnings!");
362 assert((L.
isInvalid() || SourceMgr) &&
"No SourceMgr for valid location");
365 bool WasUpgradedFromWarning =
false;
371 WasUpgradedFromWarning =
true;
384 if ((L.
isInvalid() || L == DiagStatesByLoc.getCurDiagStateLoc()) &&
385 DiagStatesByLoc.getCurDiagState()) {
390 DiagStatesByLoc.getCurDiagState()->setMapping(
Diag, Mapping);
397 DiagStates.push_back(*GetCurDiagState());
398 DiagStates.back().setMapping(
Diag, Mapping);
399 PushDiagStatePoint(&DiagStates.back(), L);
407 if (Diags->getDiagnosticsInGroup(
Flavor,
Group, GroupDiags))
490 std::vector<diag::kind> AllDiags;
495 if (Diags->isBuiltinWarningOrExtension(
Diag))
501 "Multiple diagnostics in flight at once!");
504 CurDiagID = storedDiag.
getID();
515 assert(Client &&
"DiagnosticConsumer not set!");
528 assert(
getClient() &&
"DiagnosticClient not set!");
541 Diags->EmitDiag(*
this, DiagLevel);
546 Emitted = ProcessDiag();
553 if (!Force && DelayedDiagID)
573 template <std::
size_t StrLen>
574 static bool ModifierIs(
const char *Modifier,
unsigned ModifierLen,
575 const char (&Str)[StrLen]) {
576 return StrLen-1 == ModifierLen && memcmp(Modifier, Str, StrLen-1) == 0;
581 static const char *
ScanFormat(
const char *I,
const char *E,
char Target) {
584 for ( ; I != E; ++I) {
596 for (I++; I != E && !
isDigit(*I) && *I !=
'{'; I++) ;
612 const char *Argument,
unsigned ArgumentLen,
614 const char *ArgumentEnd = Argument+ArgumentLen;
618 const char *NextVal =
ScanFormat(Argument, ArgumentEnd,
'|');
619 assert(NextVal != ArgumentEnd &&
"Value for integer select modifier was"
620 " larger than the number of options in the diagnostic string!");
621 Argument = NextVal+1;
626 const char *EndPtr =
ScanFormat(Argument, ArgumentEnd,
'|');
638 OutStr.push_back(
's');
647 assert(ValNo != 0 &&
"ValNo must be strictly positive!");
649 llvm::raw_svector_ostream Out(OutStr);
653 Out << ValNo << llvm::getOrdinalSuffix(ValNo);
660 while (Start !=
End && *Start >=
'0' && *Start <=
'9') {
677 assert(*Start ==
',' &&
"Bad plural expression syntax: expected ,");
680 assert(*Start ==
']' &&
"Bad plural expression syntax: expected )");
682 return Low <= Val && Val <= High;
697 assert(*Start ==
'=' &&
"Bad plural expression syntax: expected =");
699 unsigned ValMod = ValNo % Arg;
703 assert((C ==
'[' || (C >=
'0' && C <=
'9')) &&
704 "Bad plural expression syntax: unexpected character");
711 Start = std::find(Start,
End,
',');
753 const char *Argument,
unsigned ArgumentLen,
755 const char *ArgumentEnd = Argument + ArgumentLen;
757 assert(Argument < ArgumentEnd &&
"Plural expression didn't match.");
758 const char *ExprEnd = Argument;
759 while (*ExprEnd !=
':') {
760 assert(ExprEnd != ArgumentEnd &&
"Plural missing expression end");
764 Argument = ExprEnd + 1;
765 ExprEnd =
ScanFormat(Argument, ArgumentEnd,
'|');
772 Argument =
ScanFormat(Argument, ArgumentEnd - 1,
'|') + 1;
781 case tok::identifier:
793 if (!StoredDiagMessage.empty()) {
794 OutStr.append(StoredDiagMessage.begin(), StoredDiagMessage.end());
810 if (DiagEnd - DiagStr == 2 &&
811 StringRef(DiagStr, DiagEnd - DiagStr).
equals(
"%0") &&
815 if (llvm::sys::locale::isPrint(
c) ||
c ==
'\t') {
833 for (
unsigned i = 0, e =
getNumArgs(); i < e; ++i)
837 while (DiagStr != DiagEnd) {
838 if (DiagStr[0] !=
'%') {
840 const char *StrEnd = std::find(DiagStr, DiagEnd,
'%');
841 OutStr.append(DiagStr, StrEnd);
845 OutStr.push_back(DiagStr[1]);
858 const char *Modifier =
nullptr, *Argument =
nullptr;
859 unsigned ModifierLen = 0, ArgumentLen = 0;
864 while (DiagStr[0] ==
'-' ||
865 (DiagStr[0] >=
'a' && DiagStr[0] <=
'z'))
867 ModifierLen = DiagStr-Modifier;
870 if (DiagStr[0] ==
'{') {
875 assert(DiagStr != DiagEnd &&
"Mismatched {}'s in diagnostic string!");
876 ArgumentLen = DiagStr-Argument;
881 assert(
isDigit(*DiagStr) &&
"Invalid format for argument in diagnostic");
882 unsigned ArgNo = *DiagStr++ -
'0';
885 unsigned ArgNo2 = ArgNo;
888 if (
ModifierIs(Modifier, ModifierLen,
"diff")) {
889 assert(*DiagStr ==
',' &&
isDigit(*(DiagStr + 1)) &&
890 "Invalid format for diff modifier");
892 ArgNo2 = *DiagStr++ -
'0';
903 const char *ArgumentEnd = Argument + ArgumentLen;
906 "Found too many '|'s in a %diff modifier!");
908 const char *SecondDollar =
ScanFormat(FirstDollar + 1,
Pipe,
'$');
909 const char ArgStr1[] = {
'%',
static_cast<char>(
'0' + ArgNo) };
910 const char ArgStr2[] = {
'%',
static_cast<char>(
'0' + ArgNo2) };
924 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
925 OutStr.append(S.begin(), S.end());
930 assert(ModifierLen == 0 &&
"No modifiers for strings yet");
936 OutStr.append(S, S + strlen(S));
943 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
946 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
948 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
951 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
954 assert(ModifierLen == 0 &&
"Unknown integer modifier");
955 llvm::raw_svector_ostream(OutStr) << Val;
962 if (
ModifierIs(Modifier, ModifierLen,
"select")) {
964 }
else if (
ModifierIs(Modifier, ModifierLen,
"s")) {
966 }
else if (
ModifierIs(Modifier, ModifierLen,
"plural")) {
969 }
else if (
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
972 assert(ModifierLen == 0 &&
"Unknown integer modifier");
973 llvm::raw_svector_ostream(OutStr) << Val;
980 assert(ModifierLen == 0 &&
"No modifiers for token kinds yet");
982 llvm::raw_svector_ostream Out(OutStr);
985 Out <<
'\'' << S <<
'\'';
994 Out << '<' << S << '>
';
999 // ---- NAMES and TYPES ----
1000 case DiagnosticsEngine::ak_identifierinfo: {
1001 const IdentifierInfo *II = getArgIdentifier(ArgNo);
1002 assert(ModifierLen == 0 && "No modifiers for strings yet");
1004 // Don't crash
if get passed a
null pointer by accident.
1006 const char *S =
"(null)";
1007 OutStr.append(S, S + strlen(S));
1011 llvm::raw_svector_ostream(OutStr) <<
'\'' << II->getName() <<
'\'';
1023 StringRef(Modifier, ModifierLen),
1024 StringRef(Argument, ArgumentLen),
1026 OutStr, QualTypeVals);
1038 const char *ArgumentEnd = Argument + ArgumentLen;
1047 StringRef(Modifier, ModifierLen),
1048 StringRef(Argument, ArgumentLen),
1050 Tree, QualTypeVals);
1052 if (!
Tree.empty()) {
1060 const char *FirstDollar =
ScanFormat(Argument, ArgumentEnd,
'$');
1061 const char *SecondDollar =
ScanFormat(FirstDollar + 1, ArgumentEnd,
'$');
1070 StringRef(Modifier, ModifierLen),
1071 StringRef(Argument, ArgumentLen),
1073 OutStr, QualTypeVals);
1084 StringRef(Modifier, ModifierLen),
1085 StringRef(Argument, ArgumentLen),
1087 OutStr, QualTypeVals);
1104 FormattedArgs.push_back(std::make_pair(
Kind,
getRawArg(ArgNo)));
1111 OutStr.append(
Tree.begin(),
Tree.end());
1122 "Valid source location without setting a source manager for diagnostic");
1127 this->Message.assign(Message.begin(), Message.end());
1137 Ranges(Ranges.begin(), Ranges.end()), FixIts(FixIts.begin(), FixIts.end())
1155 void IgnoringDiagConsumer::anchor() {}
1175 for (
unsigned I = 0; I != NumCached; ++I)
1176 FreeList[I] = Cached + I;
1177 NumFreeListEntries = NumCached;
1183 assert((NumFreeListEntries == NumCached ||
1184 llvm::CrashRecoveryContext::isRecoveringFromCrash()) &&
1185 "A partial is on the lam");
Level
The level of the diagnostic, after it has been through mapping.
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing),...
void Reset()
Reset the state of the diagnostic object to its initial configuration.
__DEVICE__ int max(int __a, int __b)
const SourceManager & getManager() const
bool hasManager() const
Checks whether the SourceManager is present.
bool equals(const til::SExpr *E1, const til::SExpr *E2)
static void getAllDiagnostics(diag::Flavor Flavor, std::vector< diag::kind > &Diags)
Get the set of all diagnostic IDs.
@ Error
Present this diagnostic as an error.
A SourceLocation and its associated SourceManager.
void setSeverity(diag::kind Diag, diag::Severity Map, SourceLocation Loc)
This allows the client to specify that certain warnings are ignored.
void setClient(DiagnosticConsumer *client, bool ShouldOwnClient=true)
Set the diagnostic client associated with this diagnostic object.
const std::string & getArgStdStr(unsigned Idx) const
Return the provided argument string specified by Idx.
unsigned TemplateDiffUsed
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...
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.
bool setDiagnosticGroupErrorAsFatal(StringRef Group, bool Enabled)
Set the error-as-fatal flag for the given diagnostic group.
Encodes a location in the source.
StoredDiagnostic()=default
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
static void HandleSelectModifier(const Diagnostic &DInfo, unsigned ValNo, const char *Argument, unsigned ArgumentLen, SmallVectorImpl< char > &OutStr)
HandleSelectModifier - Handle the integer 'select' modifier.
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
unsigned NumErrors
Number of errors reported.
const char * getPunctuatorSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple punctuation tokens like '!' or '', and returns NULL for literal and...
@ Remark
Present this diagnostic as a remark.
uint64_t getRawArg(unsigned Idx) const
Return the specified non-string argument in an opaque form.
bool hasNoWarningAsError() const
Level
The level of the diagnostic, after it has been through mapping.
bool setSeverityForGroup(diag::Flavor Flavor, StringRef Group, diag::Severity Map, SourceLocation Loc=SourceLocation())
Change an entire diagnostic group (e.g.
StringRef getMessage() const
LLVM_READONLY bool isPunctuation(unsigned char c)
Return true if this character is an ASCII punctuation character.
const DiagnosticsEngine * getDiags() const
static void HandleOrdinalModifier(unsigned ValNo, SmallVectorImpl< char > &OutStr)
HandleOrdinalModifier - Handle the integer 'ord' modifier.
void setUpgradedFromWarning(bool Value)
static const char * getTokenDescForDiagnostic(tok::TokenKind Kind)
Returns the friendly description for a token kind that will appear without quotes in diagnostic messa...
This class handles loading and caching of source files into memory.
SmallVector< CharSourceRange, 8 > DiagRanges
The list of ranges added to this diagnostic.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
unsigned NumWarnings
Number of warnings reported.
bool setDiagnosticGroupWarningAsError(StringRef Group, bool Enabled)
Set the warning-as-error flag for the given diagnostic group.
@ Ignored
Do not present this diagnostic, ignore it.
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.
range_iterator range_begin() const
void print(raw_ostream &OS, const SourceManager &SM) const
bool IncludeInDiagnosticCounts() const override
Indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number...
@ WarningOrError
A diagnostic that indicates a problem or potential problem.
static bool EvalPluralExpr(unsigned ValNo, const char *Start, const char *End)
EvalPluralExpr - Actual expression evaluator for HandlePluralModifier.
std::string toString(const til::SExpr *E)
@ Fatal
Present this diagnostic as a fatal error.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
void Clear()
Clear out the current diagnostic.
bool EmitCurrentDiagnostic(bool Force=false)
Emit the current diagnostic and clear the diagnostic state.
unsigned getNumArgs() const
const char * getArgCStr(unsigned Idx) const
Return the specified C string argument.
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type,...
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
DiagnosticConsumer * getClient()
const char * getTokenName(TokenKind Kind) LLVM_READNONE
Determines the name of a token as used within the front end.
@ ak_qualtype_pair
pair<QualType, QualType>
range_iterator range_end() const
uint64_t getArgUInt(unsigned Idx) const
Return the specified unsigned integer argument.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
virtual ~DiagnosticConsumer()
@ ak_tokenkind
enum TokenKind : unsigned
virtual bool IncludeInDiagnosticCounts() const
Indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number...
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
int64_t getArgSInt(unsigned Idx) const
Return the specified signed integer argument.
Represents a diagnostic in a form that can be retained until its corresponding source manager is dest...
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
@ Warning
Present this diagnostic as a warning.
@ ak_declarationname
DeclarationName.
diag::Severity getSeverity() const
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...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
const FullSourceLoc & getLocation() const
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
const SourceLocation & getLocation() const
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
~ForwardingDiagnosticConsumer() override
const char * getKeywordSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple keyword and contextual keyword tokens like 'int' and 'dynamic_cast'...
void AddString(StringRef V) const
ArrayRef< FixItHint > getFixItHints() const
static void HandleIntegerSModifier(unsigned ValNo, SmallVectorImpl< char > &OutStr)
HandleIntegerSModifier - Handle the integer 's' modifier.
@ ak_nameddecl
NamedDecl *.
fixit_iterator fixit_end() const
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.
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)
SourceManager & getSourceManager() const
DiagnosticsEngine::Level getLevel() const
Flavor
Flavors of diagnostics we can emit.
void setNoErrorAsFatal(bool Value)
void setSeverity(diag::Severity Value)
DiagnosticsEngine(IntrusiveRefCntPtr< DiagnosticIDs > Diags, IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, DiagnosticConsumer *client=nullptr, bool ShouldOwnClient=true)
DiagnosticsEngine::ArgumentKind getArgKind(unsigned Idx) const
Return the kind of the specified index.
@ ak_addrspace
address space
LLVM_DUMP_METHOD void dump() const
void ConvertArgToString(ArgumentKind Kind, intptr_t Val, StringRef Modifier, StringRef Argument, ArrayRef< ArgumentValue > PrevArgs, SmallVectorImpl< char > &Output, ArrayRef< intptr_t > QualTypeVals) const
Converts a diagnostic argument (as an intptr_t) into the string that represents it.
static bool ModifierIs(const char *Modifier, unsigned ModifierLen, const char(&Str)[StrLen])
ModifierIs - Return true if the specified modifier matches specified string.
std::pair< FileID, unsigned > getDecomposedIncludedLoc(FileID FID) const
Returns the "included/expanded in" decomposed location of the given FileID.
ArrayRef< CharSourceRange > getRanges() const
Return an array reference for this diagnostic's ranges.
@ ak_c_string
const char *
void SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1="", StringRef Arg2="", StringRef Arg3="")
Set the "delayed" diagnostic that will be emitted once the current diagnostic completes.
unsigned char NumDiagArgs
The number of entries in Arguments.
LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
bool isValid() const
Return true if this is a valid SourceLocation object.
@ Nullable
Values of this type can be null.
void setSeverityForAll(diag::Flavor Flavor, diag::Severity Map, SourceLocation Loc=SourceLocation())
Add the specified mapping to all diagnostics of the specified flavor.
bool hasSourceManager() const
__device__ __2f16 float c
void pushMappings(SourceLocation Loc)
Copies the current DiagMappings and pushes the new copy onto the top of the stack.
static bool TestPluralRange(unsigned Val, const char *&Start, const char *End)
TestPluralRange - Test if Val is in the parsed range. Modifies Start.
void setNoWarningAsError(bool Value)
void FormatDiagnostic(SmallVectorImpl< char > &OutStr) const
Format this diagnostic into a string, substituting the formal arguments into the %0 slots.
@ NonNull
Values of this type can never be null.
llvm::MemoryBufferRef getBufferOrFake(FileID FID, SourceLocation Loc=SourceLocation()) const
Return the buffer for the specified FileID.
@ ak_std_string
std::string
@ ak_declcontext
DeclContext *.
SmallVector< FixItHint, 6 > FixItHints
If valid, provides a hint with some code to insert, remove, or modify at a particular position.
static StringRef getWarningOptionForDiag(unsigned DiagID)
Return the lowest-level warning option that enables the specified diagnostic.
static void HandlePluralModifier(const Diagnostic &DInfo, unsigned ValNo, const char *Argument, unsigned ArgumentLen, SmallVectorImpl< char > &OutStr)
HandlePluralModifier - Handle the integer 'plural' modifier.
fixit_iterator fixit_begin() const
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
static unsigned PluralNumber(const char *&Start, const char *End)
PluralNumber - Parse an unsigned integer and advance Start.
std::string printToString(const SourceManager &SM) const
@ ak_nestednamespec
NestedNameSpecifier *.