diff options
Diffstat (limited to 'contrib/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h')
-rw-r--r-- | contrib/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h index 288504def5eb..0cdda42793f6 100644 --- a/contrib/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h +++ b/contrib/llvm-project/clang/include/clang/Basic/DiagnosticIDs.h @@ -17,6 +17,7 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringRef.h" +#include <optional> #include <vector> namespace clang { @@ -25,15 +26,17 @@ namespace clang { // Import the diagnostic enums themselves. namespace diag { + enum class Group; + // Size of each of the diagnostic categories. enum { DIAG_SIZE_COMMON = 300, - DIAG_SIZE_DRIVER = 250, + DIAG_SIZE_DRIVER = 400, DIAG_SIZE_FRONTEND = 150, DIAG_SIZE_SERIALIZATION = 120, DIAG_SIZE_LEX = 400, - DIAG_SIZE_PARSE = 600, - DIAG_SIZE_AST = 250, + DIAG_SIZE_PARSE = 700, + DIAG_SIZE_AST = 300, DIAG_SIZE_COMMENT = 100, DIAG_SIZE_CROSSTU = 100, DIAG_SIZE_SEMA = 4500, @@ -43,18 +46,18 @@ namespace clang { // Start position for diagnostics. enum { DIAG_START_COMMON = 0, - DIAG_START_DRIVER = DIAG_START_COMMON + DIAG_SIZE_COMMON, - DIAG_START_FRONTEND = DIAG_START_DRIVER + DIAG_SIZE_DRIVER, - DIAG_START_SERIALIZATION = DIAG_START_FRONTEND + DIAG_SIZE_FRONTEND, - DIAG_START_LEX = DIAG_START_SERIALIZATION + DIAG_SIZE_SERIALIZATION, - DIAG_START_PARSE = DIAG_START_LEX + DIAG_SIZE_LEX, - DIAG_START_AST = DIAG_START_PARSE + DIAG_SIZE_PARSE, - DIAG_START_COMMENT = DIAG_START_AST + DIAG_SIZE_AST, - DIAG_START_CROSSTU = DIAG_START_COMMENT + DIAG_SIZE_COMMENT, - DIAG_START_SEMA = DIAG_START_CROSSTU + DIAG_SIZE_CROSSTU, - DIAG_START_ANALYSIS = DIAG_START_SEMA + DIAG_SIZE_SEMA, - DIAG_START_REFACTORING = DIAG_START_ANALYSIS + DIAG_SIZE_ANALYSIS, - DIAG_UPPER_LIMIT = DIAG_START_REFACTORING + DIAG_SIZE_REFACTORING + DIAG_START_DRIVER = DIAG_START_COMMON + static_cast<int>(DIAG_SIZE_COMMON), + DIAG_START_FRONTEND = DIAG_START_DRIVER + static_cast<int>(DIAG_SIZE_DRIVER), + DIAG_START_SERIALIZATION = DIAG_START_FRONTEND + static_cast<int>(DIAG_SIZE_FRONTEND), + DIAG_START_LEX = DIAG_START_SERIALIZATION + static_cast<int>(DIAG_SIZE_SERIALIZATION), + DIAG_START_PARSE = DIAG_START_LEX + static_cast<int>(DIAG_SIZE_LEX), + DIAG_START_AST = DIAG_START_PARSE + static_cast<int>(DIAG_SIZE_PARSE), + DIAG_START_COMMENT = DIAG_START_AST + static_cast<int>(DIAG_SIZE_AST), + DIAG_START_CROSSTU = DIAG_START_COMMENT + static_cast<int>(DIAG_SIZE_COMMENT), + DIAG_START_SEMA = DIAG_START_CROSSTU + static_cast<int>(DIAG_SIZE_CROSSTU), + DIAG_START_ANALYSIS = DIAG_START_SEMA + static_cast<int>(DIAG_SIZE_SEMA), + DIAG_START_REFACTORING = DIAG_START_ANALYSIS + static_cast<int>(DIAG_SIZE_ANALYSIS), + DIAG_UPPER_LIMIT = DIAG_START_REFACTORING + static_cast<int>(DIAG_SIZE_REFACTORING) }; class CustomDiagInfo; @@ -65,7 +68,7 @@ namespace clang { // Get typedefs for common diagnostics. enum { #define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, CATEGORY, \ - NOWERROR, SHOWINSYSHEADER, DEFFERABLE) \ + NOWERROR, SHOWINSYSHEADER, SHOWINSYSMACRO, DEFFERABLE) \ ENUM, #define COMMONSTART #include "clang/Basic/DiagnosticCommonKinds.inc" @@ -97,11 +100,17 @@ namespace clang { } class DiagnosticMapping { + LLVM_PREFERRED_TYPE(diag::Severity) unsigned Severity : 3; + LLVM_PREFERRED_TYPE(bool) unsigned IsUser : 1; + LLVM_PREFERRED_TYPE(bool) unsigned IsPragma : 1; + LLVM_PREFERRED_TYPE(bool) unsigned HasNoWarningAsError : 1; + LLVM_PREFERRED_TYPE(bool) unsigned HasNoErrorAsFatal : 1; + LLVM_PREFERRED_TYPE(bool) unsigned WasUpgradedFromWarning : 1; public: @@ -156,6 +165,10 @@ public: Result.Severity = Bits & 0x7; return Result; } + + bool operator==(DiagnosticMapping Other) const { + return serialize() == Other.serialize(); + } }; /// Used for handling and querying diagnostic IDs. @@ -205,6 +218,9 @@ public: /// default. static bool isDefaultMappingAsError(unsigned DiagID); + /// Get the default mapping for this diagnostic. + static DiagnosticMapping getDefaultMapping(unsigned DiagID); + /// Determine whether the given built-in diagnostic ID is a Note. static bool isBuiltinNote(unsigned DiagID); @@ -224,6 +240,21 @@ public: /// static bool isBuiltinExtensionDiag(unsigned DiagID, bool &EnabledByDefault); + /// Given a group ID, returns the flag that toggles the group. + /// For example, for Group::DeprecatedDeclarations, returns + /// "deprecated-declarations". + static StringRef getWarningOptionForGroup(diag::Group); + + /// Given a diagnostic group ID, return its documentation. + static StringRef getWarningOptionDocumentation(diag::Group GroupID); + + /// Given a group ID, returns the flag that toggles the group. + /// For example, for "deprecated-declarations", returns + /// Group::DeprecatedDeclarations. + static std::optional<diag::Group> getGroupForWarningOption(StringRef); + + /// Return the lowest-level group that contains the specified diagnostic. + static std::optional<diag::Group> getGroupForDiag(unsigned DiagID); /// Return the lowest-level warning option that enables the specified /// diagnostic. |