|
clang 24.0.0git
|
Used for handling and querying diagnostic IDs. More...
#include "clang/Basic/DiagnosticIDs.h"
Classes | |
| class | CustomDiagDesc |
| struct | GroupInfo |
Public Types | |
| enum | Level : uint8_t { Ignored , Note , Remark , Warning , Error , Fatal } |
| The level of the diagnostic, after it has been through mapping. More... | |
| enum | Class { CLASS_INVALID = 0x00 , CLASS_NOTE = 0x01 , CLASS_REMARK = 0x02 , CLASS_WARNING = 0x03 , CLASS_EXTENSION = 0x04 , CLASS_ERROR = 0x05 , CLASS_TRAP = 0x06 } |
| enum | SFINAEResponse { SFINAE_SubstitutionFailure , SFINAE_Suppress , SFINAE_Report , SFINAE_AccessControl } |
| Enumeration describing how the emission of a diagnostic should be treated when it occurs during C++ template argument deduction. More... | |
Public Member Functions | |
| DiagnosticIDs () | |
| ~DiagnosticIDs () | |
| unsigned | getCustomDiagID (CustomDiagDesc Diag) |
| Return an ID for a diagnostic with the specified format string and level. | |
| unsigned | getCustomDiagID (Level Level, StringRef Message) |
| StringRef | getDescription (unsigned DiagID) const |
| Given a diagnostic ID, return a description of the issue. | |
| std::string | getStableID (unsigned DiagID) const |
| Given a diagnostic ID, return the stable ID of the diagnostic. | |
| llvm::SmallVector< StringRef, 4 > | getLegacyStableIDs (unsigned DiagID) const |
| Given a diagnostic ID, return the previous stable IDs of the diagnostic. | |
| bool | isWarningOrExtension (unsigned DiagID) const |
| Return true if the unmapped diagnostic levelof the specified diagnostic ID is a Warning or Extension. | |
| bool | isDefaultMappingAsError (unsigned DiagID) const |
| Return true if the specified diagnostic is mapped to errors by default. | |
| DiagnosticMapping | getDefaultMapping (unsigned DiagID) const |
| Get the default mapping for this diagnostic. | |
| void | initCustomDiagMapping (DiagnosticMapping &, unsigned DiagID) |
| bool | isNote (unsigned DiagID) const |
| Determine whether the given diagnostic ID is a Note. | |
| bool | isExtensionDiag (unsigned DiagID) const |
| Determine whether the given diagnostic ID is for an extension of some sort. | |
| bool | isExtensionDiag (unsigned DiagID, bool &EnabledByDefault) const |
| Determine whether the given diagnostic ID is for an extension of some sort, and whether it is enabled by default. | |
| bool | isTrapDiag (unsigned DiagID) const |
| void | setGroupSeverity (StringRef Group, diag::Severity) |
| void | setGroupNoWarningsAsError (StringRef Group, bool) |
| std::optional< diag::Group > | getGroupForDiag (unsigned DiagID) const |
| Return the lowest-level group that contains the specified diagnostic. | |
| StringRef | getWarningOptionForDiag (unsigned DiagID) |
| Return the lowest-level warning option that enables the specified diagnostic. | |
| bool | getDiagnosticsInGroup (diag::Flavor Flavor, StringRef Group, SmallVectorImpl< diag::kind > &Diags) const |
| Get the set of all diagnostic IDs in the group with the given name. | |
| bool | shouldSuppressAsSystemWarning (unsigned DiagID, SourceLocation Loc, const DiagnosticsEngine &Diag) const |
| Return true if either of the following two conditions hold: | |
Static Public Member Functions | |
| static bool | IsCustomDiag (diag::kind Diag) |
| static llvm::IntrusiveRefCntPtr< DiagnosticIDs > | create () |
| static StringRef | getWarningOptionForGroup (diag::Group) |
| Given a group ID, returns the flag that toggles the group. | |
| static StringRef | getWarningOptionDocumentation (diag::Group GroupID) |
| Given a diagnostic group ID, return its documentation. | |
| static std::optional< diag::Group > | getGroupForWarningOption (StringRef) |
| Given a group ID, returns the flag that toggles the group. | |
| static unsigned | getCategoryNumberForDiag (unsigned DiagID) |
Return the category number that a specified DiagID belongs to, or 0 if no category. | |
| static unsigned | getNumberOfCategories () |
| Return the number of diagnostic categories. | |
| static StringRef | getCategoryNameFromID (unsigned CategoryID) |
| Given a category ID, return the name of the category. | |
| static bool | isARCDiagnostic (unsigned DiagID) |
| Return true if a given diagnostic falls into an ARC diagnostic category. | |
| static bool | isCodegenABICheckDiagnostic (unsigned DiagID) |
| Return true if a given diagnostic is a codegen-time ABI check. | |
| static SFINAEResponse | getDiagnosticSFINAEResponse (unsigned DiagID) |
| Determines whether the given built-in diagnostic ID is for an error that is suppressed if it occurs during C++ template argument deduction. | |
| static bool | isDeferrable (unsigned DiagID) |
| Whether the diagnostic message can be deferred. | |
| static std::vector< std::string > | getDiagnosticFlags () |
| Get the string of all diagnostic flags. | |
| static void | getAllDiagnostics (diag::Flavor Flavor, std::vector< diag::kind > &Diags) |
| Get the set of all diagnostic IDs. | |
| static StringRef | getNearestOption (diag::Flavor Flavor, StringRef Group) |
| Get the diagnostic option with the closest edit distance to the given group name. | |
| static unsigned | getCompatDiagId (const LangOptions &LangOpts, unsigned CompatDiagId) |
| Get the appropriate diagnostic Id to use for issuing a compatibility diagnostic. | |
Friends | |
| class | DiagnosticsEngine |
Used for handling and querying diagnostic IDs.
Can be used and shared by multiple Diagnostics for multiple translation units.
Definition at line 184 of file DiagnosticIDs.h.
| Enumerator | |
|---|---|
| CLASS_INVALID | |
| CLASS_NOTE | |
| CLASS_REMARK | |
| CLASS_WARNING | |
| CLASS_EXTENSION | |
| CLASS_ERROR | |
| CLASS_TRAP | |
Definition at line 190 of file DiagnosticIDs.h.
The level of the diagnostic, after it has been through mapping.
| Enumerator | |
|---|---|
| Ignored | |
| Note | |
| Remark | |
| Warning | |
| Error | |
| Fatal | |
Definition at line 187 of file DiagnosticIDs.h.
Enumeration describing how the emission of a diagnostic should be treated when it occurs during C++ template argument deduction.
Definition at line 425 of file DiagnosticIDs.h.
| DiagnosticIDs::DiagnosticIDs | ( | ) |
Definition at line 428 of file DiagnosticIDs.cpp.
| DiagnosticIDs::~DiagnosticIDs | ( | ) |
Definition at line 430 of file DiagnosticIDs.cpp.
|
inlinestatic |
Definition at line 284 of file DiagnosticIDs.h.
Referenced by clang::tooling::applyAllReplacements(), clang::createChainedIncludesSource(), clang::CompilerInstance::createDiagnostics(), clang::CompilerInstance::createVirtualFileSystem(), RoundTrip(), clang::tooling::RefactoringTool::runAndSave(), clang::SourceManagerForFile::SourceManagerForFile(), and stripPositionalArgs().
|
static |
Get the set of all diagnostic IDs.
Definition at line 844 of file DiagnosticIDs.cpp.
References StaticDiagInfoSize.
Referenced by clang::DiagnosticsEngine::setSeverityForAll().
|
static |
Given a category ID, return the name of the category.
getCategoryNameFromID - Given a category ID, return the name of the category, an empty string if CategoryID is zero, or null if CategoryID is invalid.
Definition at line 403 of file DiagnosticIDs.cpp.
References CategoryNameTable, and getNumberOfCategories().
Referenced by isARCDiagnostic(), isCodegenABICheckDiagnostic(), PrintDiagnosticCategories(), and printDiagnosticOptions().
Return the category number that a specified DiagID belongs to, or 0 if no category.
getCategoryNumberForDiag - Return the category number that a specified DiagID belongs to, or 0 if no category.
Definition at line 369 of file DiagnosticIDs.cpp.
References GetDiagInfo().
Referenced by isARCDiagnostic(), isCodegenABICheckDiagnostic(), and printDiagnosticOptions().
|
static |
Get the appropriate diagnostic Id to use for issuing a compatibility diagnostic.
For use by the various DiagCompat() helpers.
Definition at line 882 of file DiagnosticIDs.cpp.
Referenced by clang::Parser::DiagCompat(), clang::SemaBase::DiagCompat(), and diagnoseMathematicalNotationInIdentifier().
| unsigned DiagnosticIDs::getCustomDiagID | ( | CustomDiagDesc | Diag | ) |
Return an ID for a diagnostic with the specified format string and level.
getCustomDiagID - Return an ID for a diagnostic with the specified message and level.
If this is the first request for this diagnostic, it is registered and created, otherwise the existing ID is returned.
If this is the first request for this diagnostic, it is registered and created, otherwise the existing ID is returned.
| FormatString | A fixed diagnostic format string that will be hashed and mapped to a unique DiagID. |
Definition at line 438 of file DiagnosticIDs.cpp.
References Diag().
Referenced by getCustomDiagID().
Definition at line 304 of file DiagnosticIDs.h.
References CLASS_ERROR, CLASS_NOTE, CLASS_REMARK, CLASS_WARNING, clang::diag::Error, Error, clang::diag::Fatal, Fatal, getCustomDiagID(), clang::diag::Ignored, Ignored, Note, clang::diag::Remark, Remark, clang::diag::Warning, and Warning.
| DiagnosticMapping DiagnosticIDs::getDefaultMapping | ( | unsigned | DiagID | ) | const |
Get the default mapping for this diagnostic.
Definition at line 331 of file DiagnosticIDs.cpp.
References clang::diag::Fatal, GetDiagInfo(), clang::DiagnosticMapping::getSeverity(), IsCustomDiag(), clang::DiagnosticMapping::Make(), clang::DiagnosticMapping::setNoWarningAsError(), clang::DiagnosticMapping::setSeverity(), and clang::diag::Warning.
Referenced by isDefaultMappingAsError(), and isExtensionDiag().
| StringRef DiagnosticIDs::getDescription | ( | unsigned | DiagID | ) | const |
Given a diagnostic ID, return a description of the issue.
getDescription - Given a diagnostic ID, return a description of the issue.
Definition at line 477 of file DiagnosticIDs.cpp.
References GetDiagInfo().
|
static |
Get the string of all diagnostic flags.
Definition at line 749 of file DiagnosticIDs.cpp.
Referenced by clang::driver::Driver::HandleAutocompletions(), and clang::driver::Driver::HandleImmediateArgs().
|
static |
Determines whether the given built-in diagnostic ID is for an error that is suppressed if it occurs during C++ template argument deduction.
When an error is suppressed due to SFINAE, the template argument deduction fails but no diagnostic is emitted. Certain classes of errors, such as those errors that involve C++ access control, are not SFINAE errors.
Definition at line 412 of file DiagnosticIDs.cpp.
References GetDiagInfo(), and SFINAE_Report.
Referenced by clang::Sema::EmitDiagnostic().
| bool DiagnosticIDs::getDiagnosticsInGroup | ( | diag::Flavor | Flavor, |
| StringRef | Group, | ||
| SmallVectorImpl< diag::kind > & | Diags ) const |
Get the set of all diagnostic IDs in the group with the given name.
| [out] | Diags | - On return, the diagnostics in the group. |
true if the given group is unknown, false otherwise. Definition at line 799 of file DiagnosticIDs.cpp.
References getGroupForWarningOption(), and OptionTable.
Referenced by getNearestOption().
| std::optional< diag::Group > DiagnosticIDs::getGroupForDiag | ( | unsigned | DiagID | ) | const |
Return the lowest-level group that contains the specified diagnostic.
Definition at line 730 of file DiagnosticIDs.cpp.
References GetDiagInfo(), and IsCustomDiag().
Referenced by getWarningOptionForDiag().
|
static |
Given a group ID, returns the flag that toggles the group.
For example, for "deprecated-declarations", returns Group::DeprecatedDeclarations.
Definition at line 721 of file DiagnosticIDs.cpp.
References clang::Found, and OptionTable.
Referenced by getDiagnosticsInGroup(), setGroupNoWarningsAsError(), and setGroupSeverity().
| SmallVector< StringRef, 4 > DiagnosticIDs::getLegacyStableIDs | ( | unsigned | DiagID | ) | const |
Given a diagnostic ID, return the previous stable IDs of the diagnostic.
getLegacyStableIDs - Given a diagnostic ID, return the previous stable IDs of the diagnostic.
Definition at line 498 of file DiagnosticIDs.cpp.
References GetDiagInfo().
Referenced by clang::SARIFDiagnostic::emitDiagnosticMessage().
|
static |
Get the diagnostic option with the closest edit distance to the given group name.
Definition at line 851 of file DiagnosticIDs.cpp.
References getDiagnosticsInGroup(), and OptionTable.
Referenced by EmitUnknownDiagWarning().
|
static |
Return the number of diagnostic categories.
getNumberOfCategories - Return the number of categories
Definition at line 396 of file DiagnosticIDs.cpp.
References CategoryNameTable.
Referenced by getCategoryNameFromID(), and PrintDiagnosticCategories().
| std::string DiagnosticIDs::getStableID | ( | unsigned | DiagID | ) | const |
Given a diagnostic ID, return the stable ID of the diagnostic.
getStableID - Given a diagnostic ID, return the stable ID of the diagnostic.
Definition at line 485 of file DiagnosticIDs.cpp.
References GetDiagInfo().
Referenced by clang::SARIFDiagnostic::emitDiagnosticMessage().
|
static |
Given a diagnostic group ID, return its documentation.
Definition at line 712 of file DiagnosticIDs.cpp.
References OptionTable.
| StringRef DiagnosticIDs::getWarningOptionForDiag | ( | unsigned | DiagID | ) |
Return the lowest-level warning option that enables the specified diagnostic.
getWarningOptionForDiag - Return the lowest-level warning option that enables the specified diagnostic.
If there is no -Wfoo flag that controls the diagnostic, this returns null.
Definition at line 743 of file DiagnosticIDs.cpp.
References getGroupForDiag(), and getWarningOptionForGroup().
|
static |
Given a group ID, returns the flag that toggles the group.
For example, for Group::DeprecatedDeclarations, returns "deprecated-declarations".
Definition at line 716 of file DiagnosticIDs.cpp.
References OptionTable.
Referenced by clang::driver::tools::Clang::ConstructJob(), and getWarningOptionForDiag().
| void DiagnosticIDs::initCustomDiagMapping | ( | DiagnosticMapping & | Mapping, |
| unsigned | DiagID ) |
Definition at line 351 of file DiagnosticIDs.cpp.
References Diag(), clang::DiagnosticIDs::GroupInfo::HasNoWarningAsError, IsCustomDiag(), clang::DiagnosticMapping::setNoErrorAsFatal(), clang::DiagnosticMapping::setNoWarningAsError(), clang::DiagnosticMapping::setSeverity(), and clang::DiagnosticIDs::GroupInfo::Severity.
Return true if a given diagnostic falls into an ARC diagnostic category.
Definition at line 973 of file DiagnosticIDs.cpp.
References getCategoryNameFromID(), and getCategoryNumberForDiag().
Return true if a given diagnostic is a codegen-time ABI check.
Definition at line 978 of file DiagnosticIDs.cpp.
References getCategoryNameFromID(), and getCategoryNumberForDiag().
|
inlinestatic |
Definition at line 200 of file DiagnosticIDs.h.
References Diag(), and clang::diag::DIAG_UPPER_LIMIT.
Referenced by getDefaultMapping(), getGroupForDiag(), initCustomDiagMapping(), isExtensionDiag(), and shouldSuppressAsSystemWarning().
Return true if the specified diagnostic is mapped to errors by default.
Definition at line 471 of file DiagnosticIDs.cpp.
References clang::diag::Error, getDefaultMapping(), and clang::DiagnosticMapping::getSeverity().
Whether the diagnostic message can be deferred.
For single source offloading languages, a diagnostic message occurred in a device host function may be deferred until the function is sure to be emitted.
Definition at line 418 of file DiagnosticIDs.cpp.
References GetDiagInfo().
Referenced by clang::SemaBase::Diag().
Determine whether the given diagnostic ID is for an extension of some sort.
Definition at line 363 of file DiagnosticIDs.h.
References isExtensionDiag().
Referenced by isExtensionDiag().
Determine whether the given diagnostic ID is for an extension of some sort, and whether it is enabled by default.
isExtensionDiag - Determine whether the given built-in diagnostic ID is for an extension of some sort.
This also returns EnabledByDefault, which is set to indicate whether the diagnostic is ignored by default (in which case -pedantic enables it) or treated as a warning/error by default.
Definition at line 461 of file DiagnosticIDs.cpp.
References CLASS_EXTENSION, getDefaultMapping(), clang::DiagnosticMapping::getSeverity(), clang::diag::Ignored, and IsCustomDiag().
Determine whether the given diagnostic ID is a Note.
Determine whether the given built-in diagnostic ID is a Note.
Definition at line 452 of file DiagnosticIDs.cpp.
References CLASS_NOTE, and clang::diag::DIAG_UPPER_LIMIT.
Definition at line 377 of file DiagnosticIDs.h.
References CLASS_TRAP.
Return true if the unmapped diagnostic levelof the specified diagnostic ID is a Warning or Extension.
This is not legal to call on NOTEs.
Definition at line 444 of file DiagnosticIDs.cpp.
References CLASS_ERROR, and clang::diag::DIAG_UPPER_LIMIT.
| void DiagnosticIDs::setGroupNoWarningsAsError | ( | StringRef | Group, |
| bool | Val ) |
Definition at line 836 of file DiagnosticIDs.cpp.
References forEachSubGroup(), and getGroupForWarningOption().
| void DiagnosticIDs::setGroupSeverity | ( | StringRef | Group, |
| diag::Severity | Sev ) |
Definition at line 828 of file DiagnosticIDs.cpp.
References forEachSubGroup(), and getGroupForWarningOption().
| bool DiagnosticIDs::shouldSuppressAsSystemWarning | ( | unsigned | DiagID, |
| SourceLocation | Loc, | ||
| const DiagnosticsEngine & | Diag ) const |
Return true if either of the following two conditions hold:
Loc is in a system header and the diagnostic kind DiagID does not have the property 'ShowInSystemHeader'.Loc is in the expansion of a macro defined in a system header and the diagnostic kind DiagID does not have the property 'ShowInSystemMacro'. Definition at line 643 of file DiagnosticIDs.cpp.
References Diag(), DiagnosticsEngine, GetDiagInfo(), IsCustomDiag(), and clang::SourceLocation::isValid().
|
friend |
Definition at line 525 of file DiagnosticIDs.h.
References DiagnosticsEngine.
Referenced by DiagnosticsEngine, and shouldSuppressAsSystemWarning().