Lines Matching +full:clang +full:- +full:format

1 //===--- DiagnosticIDs.cpp - Diagnostic IDs Handling ----------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the Diagnostic IDs-related interfaces.
11 //===----------------------------------------------------------------------===//
13 #include "clang/Basic/DiagnosticIDs.h"
14 #include "clang/Basic/AllDiagnostics.h"
15 #include "clang/Basic/DiagnosticCategories.h"
16 #include "clang/Basic/SourceManager.h"
22 using namespace clang;
24 //===----------------------------------------------------------------------===//
26 //===----------------------------------------------------------------------===//
33 // be relocated, and also decrease the amount of data needed on 64-bit
39 // clang-format off
40 #include "clang/Basic/DiagnosticCommonKinds.inc"
41 #include "clang/Basic/DiagnosticDriverKinds.inc"
42 #include "clang/Basic/DiagnosticFrontendKinds.inc"
43 #include "clang/Basic/DiagnosticSerializationKinds.inc"
44 #include "clang/Basic/DiagnosticLexKinds.inc"
45 #include "clang/Basic/DiagnosticParseKinds.inc"
46 #include "clang/Basic/DiagnosticASTKinds.inc"
47 #include "clang/Basic/DiagnosticCommentKinds.inc"
48 #include "clang/Basic/DiagnosticCrossTUKinds.inc"
49 #include "clang/Basic/DiagnosticSemaKinds.inc"
50 #include "clang/Basic/DiagnosticAnalysisKinds.inc"
51 #include "clang/Basic/DiagnosticRefactoringKinds.inc"
52 #include "clang/Basic/DiagnosticInstallAPIKinds.inc"
53 // clang-format on
61 // clang-format off
62 #include "clang/Basic/DiagnosticCommonKinds.inc"
63 #include "clang/Basic/DiagnosticDriverKinds.inc"
64 #include "clang/Basic/DiagnosticFrontendKinds.inc"
65 #include "clang/Basic/DiagnosticSerializationKinds.inc"
66 #include "clang/Basic/DiagnosticLexKinds.inc"
67 #include "clang/Basic/DiagnosticParseKinds.inc"
68 #include "clang/Basic/DiagnosticASTKinds.inc"
69 #include "clang/Basic/DiagnosticCommentKinds.inc"
70 #include "clang/Basic/DiagnosticCrossTUKinds.inc"
71 #include "clang/Basic/DiagnosticSemaKinds.inc"
72 #include "clang/Basic/DiagnosticAnalysisKinds.inc"
73 #include "clang/Basic/DiagnosticRefactoringKinds.inc"
74 #include "clang/Basic/DiagnosticInstallAPIKinds.inc"
75 // clang-format on
82 // StaticDiagInfoRec would have extra padding on 64-bit platforms.
87 // clang-format off
88 #include "clang/Basic/DiagnosticCommonKinds.inc"
89 #include "clang/Basic/DiagnosticDriverKinds.inc"
90 #include "clang/Basic/DiagnosticFrontendKinds.inc"
91 #include "clang/Basic/DiagnosticSerializationKinds.inc"
92 #include "clang/Basic/DiagnosticLexKinds.inc"
93 #include "clang/Basic/DiagnosticParseKinds.inc"
94 #include "clang/Basic/DiagnosticASTKinds.inc"
95 #include "clang/Basic/DiagnosticCommentKinds.inc"
96 #include "clang/Basic/DiagnosticCrossTUKinds.inc"
97 #include "clang/Basic/DiagnosticSemaKinds.inc"
98 #include "clang/Basic/DiagnosticAnalysisKinds.inc"
99 #include "clang/Basic/DiagnosticRefactoringKinds.inc"
100 #include "clang/Basic/DiagnosticInstallAPIKinds.inc"
101 // clang-format on
141 size_t MyIndex = this - &StaticDiagInfo[0]; in getDescription()
184 // clang-format off
199 #include "clang/Basic/DiagnosticCommonKinds.inc"
200 #include "clang/Basic/DiagnosticDriverKinds.inc"
201 #include "clang/Basic/DiagnosticFrontendKinds.inc"
202 #include "clang/Basic/DiagnosticSerializationKinds.inc"
203 #include "clang/Basic/DiagnosticLexKinds.inc"
204 #include "clang/Basic/DiagnosticParseKinds.inc"
205 #include "clang/Basic/DiagnosticASTKinds.inc"
206 #include "clang/Basic/DiagnosticCommentKinds.inc"
207 #include "clang/Basic/DiagnosticCrossTUKinds.inc"
208 #include "clang/Basic/DiagnosticSemaKinds.inc"
209 #include "clang/Basic/DiagnosticAnalysisKinds.inc"
210 #include "clang/Basic/DiagnosticRefactoringKinds.inc"
211 #include "clang/Basic/DiagnosticInstallAPIKinds.inc"
212 // clang-format on
220 /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
237 unsigned ID = DiagID - DIAG_START_COMMON - 1; in GetDiagInfo()
240 Offset += NUM_BUILTIN_##PREV##_DIAGNOSTICS - DIAG_START_##PREV - 1; \ in GetDiagInfo()
241 ID -= DIAG_START_##NAME - DIAG_START_##PREV; \ in GetDiagInfo()
267 if (Found->DiagID != DiagID) in GetDiagInfo()
277 Info.setSeverity((diag::Severity)StaticInfo->DefaultSeverity); in getDefaultMapping()
279 if (StaticInfo->WarnNoWerror) { in getDefaultMapping()
281 "Unexpected mapping with no-Werror bit!"); in getDefaultMapping()
289 /// getCategoryNumberForDiag - Return the category number that a specified
293 return Info->Category; in getCategoryNumberForDiag()
312 #include "clang/Basic/DiagnosticGroups.inc"
317 /// getNumberOfCategories - Return the number of categories
319 return std::size(CategoryNameTable) - 1; in getNumberOfCategories()
322 /// getCategoryNameFromID - Given a category ID, return the name of the
336 return static_cast<DiagnosticIDs::SFINAEResponse>(Info->SFINAE); in getDiagnosticSFINAEResponse()
342 return Info->Deferrable; in isDeferrable()
346 /// getBuiltinDiagClass - Return the class field of the diagnostic.
350 return Info->Class; in getBuiltinDiagClass()
354 //===----------------------------------------------------------------------===//
356 //===----------------------------------------------------------------------===//
358 namespace clang { namespace
366 /// getDescription - Return the description of the specified custom
369 assert(DiagID - DIAG_UPPER_LIMIT < DiagInfo.size() && in getDescription()
371 return DiagInfo[DiagID-DIAG_UPPER_LIMIT].second; in getDescription()
374 /// getLevel - Return the level of the specified custom diagnostic.
376 assert(DiagID - DIAG_UPPER_LIMIT < DiagInfo.size() && in getLevel()
378 return DiagInfo[DiagID-DIAG_UPPER_LIMIT].first; in getLevel()
386 if (I != DiagIDs.end() && I->first == D) in getOrCreateDiagID()
387 return I->second; in getOrCreateDiagID()
398 } // end clang namespace
401 //===----------------------------------------------------------------------===//
403 //===----------------------------------------------------------------------===//
409 /// getCustomDiagID - Return an ID for a diagnostic with the specified message
413 /// \param FormatString A fixed diagnostic format string that will be hashed and
418 return CustomDiagInfo->getOrCreateDiagID(L, FormatString, *this); in getCustomDiagID()
422 /// isBuiltinWarningOrExtension - Return true if the unmapped diagnostic
431 /// Determine whether the given built-in diagnostic ID is a
438 /// isBuiltinExtensionDiag - Determine whether the given built-in diagnostic
441 /// which case -pedantic enables it) or treated as a warning/error by default.
461 /// getDescription - Given a diagnostic ID, return a description of the
465 return Info->getDescription(); in getDescription()
467 return CustomDiagInfo->getDescription(DiagID); in getDescription()
486 /// getDiagnosticLevel - Based on the way the client configured the
495 return CustomDiagInfo->getLevel(DiagID); in getDiagnosticLevel()
514 // Specific non-error diagnostics may be mapped to various levels from ignored in getDiagnosticSeverity()
520 DiagnosticMapping &Mapping = State->getOrAddMapping((diag::kind)DiagID); in getDiagnosticSeverity()
526 // Upgrade ignored diagnostics if -Weverything is enabled. in getDiagnosticSeverity()
527 if (State->EnableAllWarnings && Result == diag::Severity::Ignored && in getDiagnosticSeverity()
531 // Ignore -pedantic diagnostics inside __extension__ blocks. in getDiagnosticSeverity()
532 // (The diagnostics controlled by -pedantic are the extension diagnostics in getDiagnosticSeverity()
542 Result = std::max(Result, State->ExtBehavior); in getDiagnosticSeverity()
548 // Honor -w: this disables all messages which are not Error/Fatal by in getDiagnosticSeverity()
551 // (whether by default or downgraded from Error via e.g. -Wno-error or #pragma in getDiagnosticSeverity()
553 if (State->IgnoreAllWarnings) { in getDiagnosticSeverity()
560 // If -Werror is enabled, map warnings to errors unless explicitly disabled. in getDiagnosticSeverity()
562 if (State->WarningsAsErrors && !Mapping.hasNoWarningAsError()) in getDiagnosticSeverity()
566 // If -Wfatal-errors is enabled, map errors to fatal unless explicitly in getDiagnosticSeverity()
569 if (State->ErrorsAsFatal && !Mapping.hasNoErrorAsFatal()) in getDiagnosticSeverity()
580 !GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader; in getDiagnosticSeverity()
583 // because we also want to ignore extensions and warnings in -Werror and in getDiagnosticSeverity()
584 // -pedantic-errors modes, which *map* warnings/extensions to errors. in getDiagnosticSeverity()
585 if (State->SuppressSystemWarnings && !ShowInSystemHeader && Loc.isValid() && in getDiagnosticSeverity()
592 !GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemMacro; in getDiagnosticSeverity()
593 if (State->SuppressSystemWarnings && !ShowInSystemMacro && Loc.isValid() && in getDiagnosticSeverity()
601 #include "clang/Basic/DiagnosticGroups.inc"
611 // String is stored with a pascal-style length byte.
623 #include "clang/Basic/DiagnosticGroups.inc"
640 if (Found == std::end(OptionTable) || Found->getName() != Name) in getGroupForWarningOption()
642 return static_cast<diag::Group>(Found - OptionTable); in getGroupForWarningOption()
647 return static_cast<diag::Group>(Info->getOptionGroupIndex()); in getGroupForDiag()
651 /// getWarningOptionForDiag - Return the lowest-level warning option that
652 /// enables the specified diagnostic. If there is no -Wfoo flag that controls
661 std::vector<std::string> Res{"-W", "-Wno-"}; in getDiagnosticFlags()
665 Res.push_back("-W" + Diag); in getDiagnosticFlags()
666 Res.push_back("-Wno-" + Diag); in getDiagnosticFlags()
679 if (!Group->Members && !Group->SubGroups) in getDiagnosticsInGroup()
685 const int16_t *Member = DiagArrays + Group->Members; in getDiagnosticsInGroup()
686 for (; *Member != -1; ++Member) { in getDiagnosticsInGroup()
687 if (GetDiagInfo(*Member)->getFlavor() == Flavor) { in getDiagnosticsInGroup()
694 const int16_t *SubGroups = DiagSubGroups + Group->SubGroups; in getDiagnosticsInGroup()
695 for (; *SubGroups != (int16_t)-1; ++SubGroups) in getDiagnosticsInGroup()
749 /// ProcessDiag - This is the method used to report a diagnostic that is
774 // non-note diagnostic. This allows notes to be attached to the in ProcessDiag()
787 Diag.Client->IncludeInDiagnosticCounts()) { in ProcessDiag()
810 if (Diag.Client->IncludeInDiagnosticCounts()) { in ProcessDiag()
836 Diag.Client->HandleDiagnostic((DiagnosticsEngine::Level)DiagLevel, Info); in EmitDiag()
837 if (Diag.Client->IncludeInDiagnosticCounts()) { in EmitDiag()
849 return CustomDiagInfo->getLevel(DiagID) >= DiagnosticIDs::Error; in isUnrecoverable()