;
71StringRef Modifier, StringRef Argument,
76StringRef Str =
"<can't format argument>";
77Output.append(Str.begin(), Str.end());
84: Diags(
std::move(diags)), DiagOpts(
std::move(DiagOpts)) {
98DiagStatesByLoc.dump(*SourceMgr);
102DiagStatesByLoc.dump(*SourceMgr, DiagName);
106 boolShouldOwnClient) {
107Owner.reset(ShouldOwnClient ? client :
nullptr);
112DiagStateOnPushStack.push_back(GetCurDiagState());
116 if(DiagStateOnPushStack.empty())
119 if(DiagStateOnPushStack.back() != GetCurDiagState()) {
121PushDiagStatePoint(DiagStateOnPushStack.back(),
Loc);
123DiagStateOnPushStack.pop_back();
128ErrorOccurred =
false;
129UncompilableErrorOccurred =
false;
130FatalErrorOccurred =
false;
131UnrecoverableErrorOccurred =
false;
135TrapNumErrorsOccurred = 0;
136TrapNumUnrecoverableErrorsOccurred = 0;
143DiagStatesByLoc.clear();
144DiagStateOnPushStack.clear();
148DiagStates.emplace_back(*Diags);
149DiagStatesByLoc.appendFirst(&DiagStates.back());
154DiagnosticsEngine::DiagState::getOrAddMapping(
diag::kind Diag) {
155std::pair<iterator, bool>
Result=
160 Result.first->second = DiagIDs.getDefaultMapping(
Diag);
162DiagIDs.initCustomDiagMapping(
Result.first->second,
Diag);
165 return Result.first->second;
168voidDiagnosticsEngine::DiagStateMap::appendFirst(DiagState *State) {
169assert(Files.empty() &&
"not first");
170FirstDiagState = CurDiagState = State;
174voidDiagnosticsEngine::DiagStateMap::append(
SourceManager&SrcMgr,
177CurDiagState = State;
178CurDiagStateLoc =
Loc;
181 unsignedOffset = Decomp.second;
182 for(
File*F = getFile(SrcMgr, Decomp.first); F;
183Offset = F->ParentOffset, F = F->Parent) {
184F->HasLocalTransitions =
true;
185 auto&
Last= F->StateTransitions.back();
186assert(
Last.Offset <= Offset &&
"state transitions added out of order");
188 if(
Last.Offset == Offset) {
189 if(
Last.State == State)
195F->StateTransitions.push_back({State, Offset});
199DiagnosticsEngine::DiagState *
200DiagnosticsEngine::DiagStateMap::lookup(
SourceManager&SrcMgr,
204 returnFirstDiagState;
207 const File*F = getFile(SrcMgr, Decomp.first);
208 returnF->lookup(Decomp.second);
211DiagnosticsEngine::DiagState *
212DiagnosticsEngine::DiagStateMap::File::lookup(
unsignedOffset)
const{
214llvm::partition_point(StateTransitions, [=](
constDiagStatePoint &
P) {
215 return P.Offset <= Offset;
217assert(OnePastIt != StateTransitions.begin() &&
"missing initial state");
218 returnOnePastIt[-1].State;
221DiagnosticsEngine::DiagStateMap::File *
222DiagnosticsEngine::DiagStateMap::getFile(
SourceManager&SrcMgr,
225 auto Range= Files.equal_range(ID);
227 return&
Range.first->second;
228 auto&F = Files.insert(
Range.first, std::make_pair(ID,
File()))->second;
232 if(
ID.isValid()) {
234F.Parent = getFile(SrcMgr, Decomp.first);
235F.ParentOffset = Decomp.second;
236F.StateTransitions.push_back({F.Parent->lookup(Decomp.second), 0});
245F.StateTransitions.push_back({FirstDiagState, 0});
250voidDiagnosticsEngine::DiagStateMap::dump(
SourceManager&SrcMgr,
251StringRef DiagName)
const{
252llvm::errs() <<
"diagnostic state at ";
253CurDiagStateLoc.print(llvm::errs(), SrcMgr);
254llvm::errs() <<
": "<< CurDiagState <<
"\n";
256 for(
auto&F : Files) {
260 boolPrintedOuterHeading =
false;
261 autoPrintOuterHeading = [&] {
262 if(PrintedOuterHeading)
return;
263PrintedOuterHeading =
true;
265llvm::errs() <<
"File "<< &
File<<
" <FileID "<<
ID.getHashValue()
268 if(F.second.Parent) {
269std::pair<FileID, unsigned> Decomp =
271assert(
File.ParentOffset == Decomp.second);
272llvm::errs() <<
" parent "<<
File.Parent <<
" <FileID " 273<< Decomp.first.getHashValue() <<
"> ";
276.
print(llvm::errs(), SrcMgr);
278 if(
File.HasLocalTransitions)
279llvm::errs() <<
" has_local_transitions";
280llvm::errs() <<
"\n";
283 if(DiagName.empty())
286 for(DiagStatePoint &Transition :
File.StateTransitions) {
287 boolPrintedInnerHeading =
false;
288 autoPrintInnerHeading = [&] {
289 if(PrintedInnerHeading)
return;
290PrintedInnerHeading =
true;
293llvm::errs() <<
" ";
296.
print(llvm::errs(), SrcMgr);
297llvm::errs() <<
": state "<< Transition.State <<
":\n";
300 if(DiagName.empty())
303 for(
auto&Mapping : *Transition.State) {
307 if(!DiagName.empty() && DiagName != Option)
311llvm::errs() <<
" ";
313llvm::errs() <<
"<unknown "<< Mapping.first <<
">";
315llvm::errs() << Option;
316llvm::errs() <<
": ";
318 switch(Mapping.second.getSeverity()) {
326 if(!Mapping.second.isUser())
327llvm::errs() <<
" default";
328 if(Mapping.second.isPragma())
329llvm::errs() <<
" pragma";
330 if(Mapping.second.hasNoWarningAsError())
331llvm::errs() <<
" no-error";
332 if(Mapping.second.hasNoErrorAsFatal())
333llvm::errs() <<
" no-fatal";
334 if(Mapping.second.wasUpgradedFromWarning())
335llvm::errs() <<
" overruled";
336llvm::errs() <<
"\n";
342voidDiagnosticsEngine::PushDiagStatePoint(DiagState *State,
344assert(
Loc.
isValid() &&
"Adding invalid loc point");
345DiagStatesByLoc.append(*SourceMgr,
Loc, State);
350assert((Diags->isWarningOrExtension(
Diag) ||
352 "Cannot map errors into warnings!");
353assert((L.
isInvalid() || SourceMgr) &&
"No SourceMgr for valid location");
357 boolWasUpgradedFromWarning =
false;
363WasUpgradedFromWarning =
true;
376 if((L.
isInvalid() || L == DiagStatesByLoc.getCurDiagStateLoc()) &&
377DiagStatesByLoc.getCurDiagState()) {
382DiagStatesByLoc.getCurDiagState()->setMapping(
Diag, Mapping);
389DiagStates.push_back(*GetCurDiagState());
390DiagStates.back().setMapping(
Diag, Mapping);
391PushDiagStatePoint(&DiagStates.back(), L);
399 if(Diags->getDiagnosticsInGroup(Flavor, Group, GroupDiags))
402Diags->setGroupSeverity(Group, Map);
486std::vector<diag::kind> AllDiags;
491 if(Diags->isWarningOrExtension(
Diag))
498classWarningsSpecialCaseList :
publicllvm::SpecialCaseList {
500 staticstd::unique_ptr<WarningsSpecialCaseList>
501create(
constllvm::MemoryBuffer &Input, std::string &Err);
516 boolglobsMatches(
constllvm::StringMap<Matcher> &CategoriesToMatchers,
517StringRef FilePath)
const;
519llvm::DenseMap<diag::kind, const Section *> DiagToSection;
523std::unique_ptr<WarningsSpecialCaseList>
524WarningsSpecialCaseList::create(
constllvm::MemoryBuffer &Input,
526 autoWarningSuppressionList = std::make_unique<WarningsSpecialCaseList>();
527 if(!WarningSuppressionList->createInternal(&Input, Err))
529 returnWarningSuppressionList;
536Sections.erase(
"*");
538std::vector<std::pair<unsigned, const llvm::StringMapEntry<Section> *>>
540LineAndSectionEntry.reserve(Sections.size());
541 for(
const auto&Entry : Sections) {
542StringRef DiagName = Entry.getKey();
545 const auto&DiagSectionMatcher = Entry.getValue().SectionMatcher;
546 unsignedDiagLine = DiagSectionMatcher->Globs.at(DiagName).second;
547LineAndSectionEntry.emplace_back(DiagLine, &Entry);
549llvm::sort(LineAndSectionEntry);
551 for(
const auto&[_, SectionEntry] : LineAndSectionEntry) {
553StringRef DiagGroup = SectionEntry->getKey();
555WarningFlavor, DiagGroup, GroupDiags)) {
556StringRef Suggestion =
558Diags.
Report(diag::warn_unknown_diag_option)
559<<
static_cast<unsigned>(WarningFlavor) << DiagGroup
560<< !Suggestion.empty() << Suggestion;
566DiagToSection[
Diag] = &SectionEntry->getValue();
572 autoWarningSuppressionList = WarningsSpecialCaseList::create(Input,
Error);
573 if(!WarningSuppressionList) {
576 Report(diag::err_drv_malformed_warning_suppression_mapping)
577<< Input.getBufferIdentifier() <<
Error;
580WarningSuppressionList->processSections(*
this);
581DiagSuppressionMapping =
582[WarningSuppressionList(std::move(WarningSuppressionList))](
584 returnWarningSuppressionList->isDiagSuppressed(DiagId, DiagLoc,
SM);
588boolWarningsSpecialCaseList::isDiagSuppressed(
diag::kindDiagId,
591 constSection *DiagSection = DiagToSection.lookup(DiagId);
594 constSectionEntries &EntityTypeToCategories = DiagSection->Entries;
595 autoSrcEntriesIt = EntityTypeToCategories.find(
"src");
596 if(SrcEntriesIt == EntityTypeToCategories.end())
598 constllvm::StringMap<llvm::SpecialCaseList::Matcher> &CategoriesToMatchers =
599SrcEntriesIt->getValue();
602 if(
PresumedLocPLoc =
SM.getPresumedLoc(DiagLoc); PLoc.isValid())
604CategoriesToMatchers,
605llvm::sys::path::remove_leading_dotslash(PLoc.getFilename()));
609boolWarningsSpecialCaseList::globsMatches(
610 constllvm::StringMap<Matcher> &CategoriesToMatchers,
611StringRef FilePath)
const{
612StringRef LongestMatch;
613 boolLongestIsPositive =
false;
614 for(
const auto&Entry : CategoriesToMatchers) {
615StringRef
Category= Entry.getKey();
616 constllvm::SpecialCaseList::Matcher &Matcher = Entry.getValue();
617 boolIsPositive =
Category!=
"emit";
618 for(
const auto&[Pattern, Glob] : Matcher.Globs) {
619 if(Pattern.size() < LongestMatch.size())
621 if(!Glob.first.match(FilePath))
623LongestMatch = Pattern;
624LongestIsPositive = IsPositive;
627 returnLongestIsPositive;
645assert(Client &&
"DiagnosticConsumer not set!");
658assert(
getClient() &&
"DiagnosticClient not set!");
671Diags->EmitDiag(*
this, DB, DiagLevel);
676Emitted = ProcessDiag(DB);
685DiagLoc(DiagLoc), DiagID(DiagID), IsActive(
true) {
686assert(DiagObj &&
"DiagnosticBuilder requires a valid DiagnosticsEngine!");
691DiagLoc =
D.DiagLoc;
693FlagValue =
D.FlagValue;
694DiagObj =
D.DiagObj;
696 D.DiagStorage =
nullptr;
698IsActive =
D.IsActive;
699IsForceEmit =
D.IsForceEmit;
705: DiagObj(DO), DiagLoc(DiagBuilder.DiagLoc), DiagID(DiagBuilder.DiagID),
706FlagValue(DiagBuilder.FlagValue), DiagStorage(*DiagBuilder.
getStorage()) {
711StringRef StoredDiagMessage)
712: DiagObj(DO), DiagLoc(DiagLoc), DiagID(DiagID), DiagStorage(DiagStorage),
713StoredDiagMessage(StoredDiagMessage) {}
729template<std::
size_tStrLen>
730static bool ModifierIs(
const char*Modifier,
unsignedModifierLen,
731 const char(&Str)[StrLen]) {
732 returnStrLen-1 == ModifierLen && memcmp(Modifier, Str, StrLen-1) == 0;
740 for( ; I !=
E; ++I) {
741 if(Depth == 0 && *I ==
Target)
returnI;
742 if(Depth != 0 && *I ==
'}') Depth--;
752 for(I++; I !=
E&& !
isDigit(*I) && *I !=
'{'; I++) ;
768 const char*Argument,
unsignedArgumentLen,
770 const char*ArgumentEnd = Argument+ArgumentLen;
774 const char*NextVal =
ScanFormat(Argument, ArgumentEnd,
'|');
775assert(NextVal != ArgumentEnd &&
"Value for integer select modifier was" 776 " larger than the number of options in the diagnostic string!");
777Argument = NextVal+1;
782 const char*EndPtr =
ScanFormat(Argument, ArgumentEnd,
'|');
794OutStr.push_back(
's');
803assert(ValNo != 0 &&
"ValNo must be strictly positive!");
805llvm::raw_svector_ostream Out(OutStr);
809Out << ValNo << llvm::getOrdinalSuffix(ValNo);
820 static constexprstd::array<std::pair<int64_t, char>, 4> Units = {
821{{1'000'000'000'000L,
'T'},
822{1'000'000'000L,
'G'},
826llvm::raw_svector_ostream Out(OutStr);
831 for(
const auto&[UnitSize, UnitSign] : Units) {
832 if(ValNo >= UnitSize) {
833Out << llvm::format(
"%0.2f%c", ValNo /
static_cast<double>(UnitSize),
845 while(Start != End && *Start >=
'0'&& *Start <=
'9') {
847Val += *Start -
'0';
855 if(*Start !=
'[') {
862assert(*Start ==
','&&
"Bad plural expression syntax: expected ,");
865assert(*Start ==
']'&&
"Bad plural expression syntax: expected )");
867 returnLow <= Val && Val <= High;
871static bool EvalPluralExpr(
unsignedValNo,
const char*Start,
const char*End) {
882assert(*Start ==
'='&&
"Bad plural expression syntax: expected =");
884 unsignedValMod = ValNo % Arg;
888assert((
C==
'['|| (
C>=
'0'&&
C<=
'9')) &&
889 "Bad plural expression syntax: unexpected character");
896Start = std::find(Start, End,
',');
938 const char*Argument,
unsignedArgumentLen,
940 const char*ArgumentEnd = Argument + ArgumentLen;
942assert(Argument < ArgumentEnd &&
"Plural expression didn't match.");
943 const char*ExprEnd = Argument;
944 while(*ExprEnd !=
':') {
945assert(ExprEnd != ArgumentEnd &&
"Plural missing expression end");
949Argument = ExprEnd + 1;
950ExprEnd =
ScanFormat(Argument, ArgumentEnd,
'|');
957Argument =
ScanFormat(Argument, ArgumentEnd - 1,
'|') + 1;
966 casetok::identifier:
967 return "identifier";
978 if(StoredDiagMessage.has_value()) {
979OutStr.append(StoredDiagMessage->begin(), StoredDiagMessage->end());
993OutStr.reserve(OutStr.size() + Str.size());
994 auto*
Begin=
reinterpret_cast<const unsigned char*
>(Str.data());
995llvm::raw_svector_ostream OutStream(OutStr);
996 const unsigned char*End =
Begin+ Str.size();
997 while(
Begin!= End) {
1000OutStream << *
Begin;
1004 if(llvm::isLegalUTF8Sequence(
Begin, End)) {
1005llvm::UTF32 CodepointValue;
1006llvm::UTF32 *CpPtr = &CodepointValue;
1007 const unsigned char*CodepointBegin =
Begin;
1008 const unsigned char*CodepointEnd =
1010llvm::ConversionResult Res = llvm::ConvertUTF8toUTF32(
1011&
Begin, CodepointEnd, &CpPtr, CpPtr + 1, llvm::strictConversion);
1014llvm::conversionOK == Res &&
1015 "the sequence is legal UTF-8 but we couldn't convert it to UTF-32");
1016assert(
Begin== CodepointEnd &&
1017 "we must be further along in the string now");
1018 if(llvm::sys::unicode::isPrintable(CodepointValue) ||
1019llvm::sys::unicode::isFormatting(CodepointValue)) {
1020OutStr.append(CodepointBegin, CodepointEnd);
1024OutStream <<
"<U+"<< llvm::format_hex_no_prefix(CodepointValue, 4,
true)
1029OutStream <<
"<"<< llvm::format_hex_no_prefix(*
Begin, 2,
true) <<
">";
1040 if(DiagEnd - DiagStr == 2 && StringRef(DiagStr, DiagEnd - DiagStr) ==
"%0"&&
1058 for(
unsignedi = 0, e =
getNumArgs(); i < e; ++i)
1062 while(DiagStr != DiagEnd) {
1063 if(DiagStr[0] !=
'%') {
1065 const char*StrEnd = std::find(DiagStr, DiagEnd,
'%');
1066OutStr.append(DiagStr, StrEnd);
1070OutStr.push_back(DiagStr[1]);
1083 const char*Modifier =
nullptr, *Argument =
nullptr;
1084 unsignedModifierLen = 0, ArgumentLen = 0;
1089 while(DiagStr[0] ==
'-'||
1090(DiagStr[0] >=
'a'&& DiagStr[0] <=
'z'))
1092ModifierLen = DiagStr-Modifier;
1095 if(DiagStr[0] ==
'{') {
1099DiagStr =
ScanFormat(DiagStr, DiagEnd,
'}');
1100assert(DiagStr != DiagEnd &&
"Mismatched {}'s in diagnostic string!");
1101ArgumentLen = DiagStr-Argument;
1106assert(
isDigit(*DiagStr) &&
"Invalid format for argument in diagnostic");
1107 unsignedArgNo = *DiagStr++ -
'0';
1110 unsignedArgNo2 = ArgNo;
1113 if(
ModifierIs(Modifier, ModifierLen,
"diff")) {
1114assert(*DiagStr ==
','&&
isDigit(*(DiagStr + 1)) &&
1115 "Invalid format for diff modifier");
1117ArgNo2 = *DiagStr++ -
'0';
1128 const char*ArgumentEnd = Argument + ArgumentLen;
1130assert(
ScanFormat(
Pipe+ 1, ArgumentEnd,
'|') == ArgumentEnd &&
1131 "Found too many '|'s in a %diff modifier!");
1133 const char*SecondDollar =
ScanFormat(FirstDollar + 1,
Pipe,
'$');
1134 const charArgStr1[] = {
'%',
static_cast<char>(
'0'+ ArgNo) };
1135 const charArgStr2[] = {
'%',
static_cast<char>(
'0'+ ArgNo2) };
1149assert(ModifierLen == 0 &&
"No modifiers for strings yet");
1155assert(ModifierLen == 0 &&
"No modifiers for strings yet");
1167 if(
ModifierIs(Modifier, ModifierLen,
"select")) {
1170}
else if(
ModifierIs(Modifier, ModifierLen,
"s")) {
1172}
else if(
ModifierIs(Modifier, ModifierLen,
"plural")) {
1175}
else if(
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
1177}
else if(
ModifierIs(Modifier, ModifierLen,
"human")) {
1180assert(ModifierLen == 0 &&
"Unknown integer modifier");
1181llvm::raw_svector_ostream(OutStr) << Val;
1188 if(
ModifierIs(Modifier, ModifierLen,
"select")) {
1190}
else if(
ModifierIs(Modifier, ModifierLen,
"s")) {
1192}
else if(
ModifierIs(Modifier, ModifierLen,
"plural")) {
1195}
else if(
ModifierIs(Modifier, ModifierLen,
"ordinal")) {
1197}
else if(
ModifierIs(Modifier, ModifierLen,
"human")) {
1200assert(ModifierLen == 0 &&
"Unknown integer modifier");
1201llvm::raw_svector_ostream(OutStr) << Val;
1208assert(ModifierLen == 0 &&
"No modifiers for token kinds yet");
1210llvm::raw_svector_ostream Out(OutStr);
1213Out <<
'\''<< S <<
'\'';
1222Out <<
'<'<< S <<
'>';
1230assert(ModifierLen == 0 &&
"No modifiers for strings yet");
1234 const char*S =
"(null)";
1235OutStr.append(S, S + strlen(S));
1239llvm::raw_svector_ostream(OutStr) <<
'\''<< II->
getName() <<
'\'';
1251StringRef(Modifier, ModifierLen),
1252StringRef(Argument, ArgumentLen),
1254OutStr, QualTypeVals);
1266 const char*ArgumentEnd = Argument + ArgumentLen;
1271 if(
getDiags()->PrintTemplateTree &&
Tree.empty()) {
1275StringRef(Modifier, ModifierLen),
1276StringRef(Argument, ArgumentLen),
1278 Tree, QualTypeVals);
1280 if(!
Tree.empty()) {
1288 const char*FirstDollar =
ScanFormat(Argument, ArgumentEnd,
'$');
1289 const char*SecondDollar =
ScanFormat(FirstDollar + 1, ArgumentEnd,
'$');
1298StringRef(Modifier, ModifierLen),
1299StringRef(Argument, ArgumentLen),
1301OutStr, QualTypeVals);
1312StringRef(Modifier, ModifierLen),
1313StringRef(Argument, ArgumentLen),
1315OutStr, QualTypeVals);
1332FormattedArgs.push_back(std::make_pair(Kind,
getRawArg(ArgNo)));
1339OutStr.append(
Tree.begin(),
Tree.end());
1344: ID(ID), Level(Level), Message(Message) {}
1348: ID(Info.getID()), Level(Level) {
1350 "Valid source location without setting a source manager for diagnostic");
1355this->Message.assign(Message.begin(), Message.end());
1364: ID(ID), Level(Level),
Loc(
Loc), Message(Message),
1365Ranges(Ranges.begin(), Ranges.end()), FixIts(FixIts.begin(), FixIts.end())
1383voidIgnoringDiagConsumer::anchor() {}
1390 Target.HandleDiagnostic(DiagLevel, Info);
1399 return Target.IncludeInDiagnosticCounts();
1403 for(
unsignedI = 0; I != NumCached; ++I)
1404FreeList[I] = Cached + I;
1405NumFreeListEntries = NumCached;
1411assert((NumFreeListEntries == NumCached ||
1412llvm::CrashRecoveryContext::isRecoveringFromCrash()) &&
1413 "A partial is on the lam");
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...
static void HandlePluralModifier(const Diagnostic &DInfo, unsigned ValNo, const char *Argument, unsigned ArgumentLen, SmallVectorImpl< char > &OutStr)
HandlePluralModifier - Handle the integer 'plural' modifier.
static void HandleIntegerSModifier(unsigned ValNo, SmallVectorImpl< char > &OutStr)
HandleIntegerSModifier - Handle the integer 's' modifier.
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)
static bool EvalPluralExpr(unsigned ValNo, const char *Start, const char *End)
EvalPluralExpr - Actual expression evaluator for HandlePluralModifier.
static void HandleIntegerHumanModifier(int64_t ValNo, SmallVectorImpl< char > &OutStr)
static unsigned PluralNumber(const char *&Start, const char *End)
PluralNumber - Parse an unsigned integer and advance Start.
static void HandleSelectModifier(const Diagnostic &DInfo, unsigned ValNo, const char *Argument, unsigned ArgumentLen, SmallVectorImpl< char > &OutStr)
HandleSelectModifier - Handle the integer 'select' modifier.
static bool ModifierIs(const char *Modifier, unsigned ModifierLen, const char(&Str)[StrLen])
ModifierIs - Return true if the specified modifier matches specified string.
static bool TestPluralRange(unsigned Val, const char *&Start, const char *End)
TestPluralRange - Test if Val is in the parsed range. Modifies Start.
static void HandleOrdinalModifier(unsigned ValNo, SmallVectorImpl< char > &OutStr)
HandleOrdinalModifier - Handle the integer 'ord' modifier.
static const char * getTokenDescForDiagnostic(tok::TokenKind Kind)
Returns the friendly description for a token kind that will appear without quotes in diagnostic messa...
Defines the Diagnostic-related interfaces.
static llvm::GlobalValue::DLLStorageClassTypes getStorage(CodeGenModule &CGM, StringRef Name)
Defines the Diagnostic IDs-related interfaces.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
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.
llvm::MachO::Target Target
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TokenKind enum and support functions.
A little helper class used to produce diagnostics.
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
virtual ~DiagnosticConsumer()
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.
unsigned NumErrors
Number of errors reported.
unsigned NumWarnings
Number of warnings reported.
virtual bool IncludeInDiagnosticCounts() const
Indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number...
static StringRef getNearestOption(diag::Flavor Flavor, StringRef Group)
Get the diagnostic option with the closest edit distance to the given group name.
static bool IsCustomDiag(diag::kind Diag)
Level
The level of the diagnostic, after it has been through mapping.
static void getAllDiagnostics(diag::Flavor Flavor, std::vector< diag::kind > &Diags)
Get the set of all diagnostic IDs.
void setNoWarningAsError(bool Value)
void setSeverity(diag::Severity Value)
diag::Severity getSeverity() const
void setUpgradedFromWarning(bool Value)
void setNoErrorAsFatal(bool Value)
bool hasNoWarningAsError() const
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...
Diagnostic(const DiagnosticsEngine *DO, const DiagnosticBuilder &DiagBuilder)
const SourceLocation & getLocation() const
const std::string & getArgStdStr(unsigned Idx) const
Return the provided argument string specified by Idx.
void FormatDiagnostic(SmallVectorImpl< char > &OutStr) const
Format this diagnostic into a string, substituting the formal arguments into the %0 slots.
uint64_t getRawArg(unsigned Idx) const
Return the specified non-string argument in an opaque form.
const char * getArgCStr(unsigned Idx) const
Return the specified C string argument.
const IdentifierInfo * getArgIdentifier(unsigned Idx) const
Return the specified IdentifierInfo argument.
SourceManager & getSourceManager() const
ArrayRef< FixItHint > getFixItHints() const
unsigned getNumArgs() const
bool hasSourceManager() const
DiagnosticsEngine::ArgumentKind getArgKind(unsigned Idx) const
Return the kind of the specified index.
int64_t getArgSInt(unsigned Idx) const
Return the specified signed integer argument.
uint64_t getArgUInt(unsigned Idx) const
Return the specified unsigned integer argument.
ArrayRef< CharSourceRange > getRanges() const
Return an array reference for this diagnostic's ranges.
const DiagnosticsEngine * getDiags() const
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
bool hasSourceManager() const
bool EmitDiagnostic(const DiagnosticBuilder &DB, bool Force=false)
Emit the diagnostic.
void setDiagSuppressionMapping(llvm::MemoryBuffer &Input)
Diagnostic suppression mappings can be used to suppress specific diagnostics in specific files.
bool isSuppressedViaMapping(diag::kind DiagId, SourceLocation DiagLoc) const
void setSeverityForAll(diag::Flavor Flavor, diag::Severity Map, SourceLocation Loc=SourceLocation())
Add the specified mapping to all diagnostics of the specified flavor.
LLVM_DUMP_METHOD void dump() const
void setClient(DiagnosticConsumer *client, bool ShouldOwnClient=true)
Set the diagnostic client associated with this diagnostic object.
SourceManager & getSourceManager() const
void pushMappings(SourceLocation Loc)
Copies the current DiagMappings and pushes the new copy onto the top of the stack.
void setSeverity(diag::kind Diag, diag::Severity Map, SourceLocation Loc)
This allows the client to specify that certain warnings are ignored.
Level
The level of the diagnostic, after it has been through mapping.
DiagnosticConsumer * getClient()
@ ak_nameddecl
NamedDecl *.
@ ak_declcontext
DeclContext *.
@ ak_addrspace
address space
@ ak_identifierinfo
IdentifierInfo.
@ ak_qualtype_pair
pair<QualType, QualType>
@ ak_c_string
const char *
@ ak_declarationname
DeclarationName.
@ ak_tokenkind
enum TokenKind : unsigned
@ ak_std_string
std::string
@ ak_nestednamespec
NestedNameSpecifier *.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
DiagnosticsEngine(IntrusiveRefCntPtr< DiagnosticIDs > Diags, IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, DiagnosticConsumer *client=nullptr, bool ShouldOwnClient=true)
bool setDiagnosticGroupErrorAsFatal(StringRef Group, bool Enabled)
Set the error-as-fatal flag for the given diagnostic group.
bool setDiagnosticGroupWarningAsError(StringRef Group, bool Enabled)
Set the warning-as-error flag for the given diagnostic group.
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.
bool setSeverityForGroup(diag::Flavor Flavor, StringRef Group, diag::Severity Map, SourceLocation Loc=SourceLocation())
Change an entire diagnostic group (e.g.
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...
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
void Reset(bool soft=false)
Reset the state of the diagnostic object to its initial configuration.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
bool IncludeInDiagnosticCounts() const override
Indicates whether the diagnostics handled by this DiagnosticConsumer should be included in the number...
~ForwardingDiagnosticConsumer() override
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.
A SourceLocation and its associated SourceManager.
bool hasManager() const
Checks whether the SourceManager is present.
const SourceManager & getManager() const
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
Represents an unpacked "presumed" location which can be presented to the user.
Encodes a location in the source.
std::string printToString(const SourceManager &SM) const
bool isValid() const
Return true if this is a valid SourceLocation object.
void print(raw_ostream &OS, const SourceManager &SM) const
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
DiagnosticsEngine & getDiagnostics() const
llvm::MemoryBufferRef getBufferOrFake(FileID FID, SourceLocation Loc=SourceLocation()) const
Return the buffer for the specified FileID.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
std::pair< FileID, unsigned > getDecomposedIncludedLoc(FileID FID) const
Returns the "included/expanded in" decomposed location of the given FileID.
Represents a diagnostic in a form that can be retained until its corresponding source manager is dest...
range_iterator range_begin() const
StoredDiagnostic()=default
DiagnosticsEngine::Level getLevel() const
fixit_iterator fixit_begin() const
const FullSourceLoc & getLocation() const
range_iterator range_end() const
StringRef getMessage() const
fixit_iterator fixit_end() const
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
DiagStorageAllocator * Allocator
Allocator used to allocate storage for this diagnostic.
DiagnosticStorage * DiagStorage
void AddString(StringRef V) const
Flavor
Flavors of diagnostics we can emit.
@ WarningOrError
A diagnostic that indicates a problem or potential problem.
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing),...
@ Warning
Present this diagnostic as a warning.
@ Fatal
Present this diagnostic as a fatal error.
@ Error
Present this diagnostic as an error.
@ Remark
Present this diagnostic as a remark.
@ Ignored
Do not present this diagnostic, ignore it.
const char * getTokenName(TokenKind Kind) LLVM_READNONE
Determines the name of a token as used within the front end.
const char * getKeywordSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple keyword and contextual keyword tokens like 'int' and 'dynamic_cast'...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
const char * getPunctuatorSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple punctuation tokens like '!' or '', and returns NULL for literal and...
The JSON file list parser is used to communicate input to InstallAPI.
LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
@ Result
The result type of a method or function.
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
void EscapeStringForDiagnostic(StringRef Str, SmallVectorImpl< char > &OutStr)
EscapeStringForDiagnostic - Append Str to the diagnostic buffer, escaping non-printable characters an...
LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
LLVM_READONLY bool isPunctuation(unsigned char c)
Return true if this character is an ASCII punctuation character.
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type,...
SmallVector< CharSourceRange, 8 > DiagRanges
The list of ranges added to this diagnostic.
SmallVector< FixItHint, 6 > FixItHints
If valid, provides a hint with some code to insert, remove, or modify at a particular position.
unsigned TemplateDiffUsed
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4