diff options
author | Alp Toker <alp@nuanti.com> | 2014-06-12 10:15:20 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-06-12 10:15:20 +0000 |
commit | 18a9b6654286356870c6c336ad9fdc6ad7599dbe (patch) | |
tree | a5233ce6ebfd92720529dc812124197fabc124e9 /include | |
parent | 1408b3372ea1b0b84c31103a4a2f54391cc73138 (diff) | |
download | clang-18a9b6654286356870c6c336ad9fdc6ad7599dbe.tar.gz clang-18a9b6654286356870c6c336ad9fdc6ad7599dbe.tar.bz2 clang-18a9b6654286356870c6c336ad9fdc6ad7599dbe.tar.xz |
Complete the switch from mappings to declarative diagnostic severities
This begins to address cognitive dissonance caused by treating the Note
diagnostic level as a severity in the diagnostic engine.
No change in functionality.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210758 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Basic/Diagnostic.td | 46 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticIDs.h | 31 |
2 files changed, 39 insertions, 38 deletions
diff --git a/include/clang/Basic/Diagnostic.td b/include/clang/Basic/Diagnostic.td index 5bcc2d5c16..dd16a6a78c 100644 --- a/include/clang/Basic/Diagnostic.td +++ b/include/clang/Basic/Diagnostic.td @@ -12,13 +12,15 @@ // //===----------------------------------------------------------------------===// -// Define the diagnostic mappings. -class DiagMapping; -def MAP_IGNORE : DiagMapping; -def MAP_REMARK : DiagMapping; -def MAP_WARNING : DiagMapping; -def MAP_ERROR : DiagMapping; -def MAP_FATAL : DiagMapping; +// Define the diagnostic severities. +class Severity<string N> { + string Name = N; +} +def SEV_Ignored : Severity<"Ignored">; +def SEV_Remark : Severity<"Remark">; +def SEV_Warning : Severity<"Warning">; +def SEV_Error : Severity<"Error">; +def SEV_Fatal : Severity<"Fatal">; // Define the diagnostic classes. class DiagClass; @@ -59,7 +61,7 @@ include "DiagnosticGroups.td" // All diagnostics emitted by the compiler are an indirect subclass of this. -class Diagnostic<string text, DiagClass DC, DiagMapping defaultmapping> { +class Diagnostic<string text, DiagClass DC, Severity defaultmapping> { /// Component is specified by the file with a big let directive. string Component = ?; string Text = text; @@ -68,7 +70,7 @@ class Diagnostic<string text, DiagClass DC, DiagMapping defaultmapping> { bit AccessControl = 0; bit WarningNoWerror = 0; bit WarningShowInSystemHeader = 0; - DiagMapping DefaultMapping = defaultmapping; + Severity DefaultSeverity = defaultmapping; DiagGroup Group; string CategoryName = ""; } @@ -84,25 +86,25 @@ class AccessControl { } // FIXME: ExtWarn and Extension should also be SFINAEFailure by default. -class Error<string str> : Diagnostic<str, CLASS_ERROR, MAP_ERROR>, SFINAEFailure; -class Warning<string str> : Diagnostic<str, CLASS_WARNING, MAP_WARNING>; -class Remark<string str> : Diagnostic<str, CLASS_REMARK, MAP_IGNORE>; -class Extension<string str> : Diagnostic<str, CLASS_EXTENSION, MAP_IGNORE>; -class ExtWarn<string str> : Diagnostic<str, CLASS_EXTENSION, MAP_WARNING>; -class Note<string str> : Diagnostic<str, CLASS_NOTE, MAP_FATAL/*ignored*/>; - - -class DefaultIgnore { DiagMapping DefaultMapping = MAP_IGNORE; } -class DefaultWarn { DiagMapping DefaultMapping = MAP_WARNING; } -class DefaultError { DiagMapping DefaultMapping = MAP_ERROR; } -class DefaultFatal { DiagMapping DefaultMapping = MAP_FATAL; } +class Error<string str> : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure; +class Warning<string str> : Diagnostic<str, CLASS_WARNING, SEV_Warning>; +class Remark<string str> : Diagnostic<str, CLASS_REMARK, SEV_Ignored>; +class Extension<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Ignored>; +class ExtWarn<string str> : Diagnostic<str, CLASS_EXTENSION, SEV_Warning>; +class Note<string str> : Diagnostic<str, CLASS_NOTE, SEV_Fatal/*ignored*/>; + + +class DefaultIgnore { Severity DefaultSeverity = SEV_Ignored; } +class DefaultWarn { Severity DefaultSeverity = SEV_Warning; } +class DefaultError { Severity DefaultSeverity = SEV_Error; } +class DefaultFatal { Severity DefaultSeverity = SEV_Fatal; } class DefaultWarnNoWerror { bit WarningNoWerror = 1; } class DefaultWarnShowInSystemHeader { bit WarningShowInSystemHeader = 1; } -class DefaultRemark { DiagMapping DefaultMapping = MAP_REMARK; } +class DefaultRemark { Severity DefaultSeverity = SEV_Remark; } // Definitions for Diagnostics. include "DiagnosticASTKinds.td" diff --git a/include/clang/Basic/DiagnosticIDs.h b/include/clang/Basic/DiagnosticIDs.h index 9f0a03be83..8b670500cf 100644 --- a/include/clang/Basic/DiagnosticIDs.h +++ b/include/clang/Basic/DiagnosticIDs.h @@ -56,17 +56,16 @@ namespace clang { }; /// Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs - /// to either MAP_IGNORE (nothing), MAP_REMARK (emit a remark), MAP_WARNING - /// (emit a warning), MAP_ERROR (emit as an error). It allows clients to - /// map errors to MAP_ERROR/MAP_DEFAULT or MAP_FATAL (stop emitting - /// diagnostics after this one). - enum Severity { + /// to either Ignore (nothing), Remark (emit a remark), Warning + /// (emit a warning) or Error (emit as an error). It allows clients to + /// map ERRORs to Error or Fatal (stop emitting diagnostics after this one). + enum class Severity { // NOTE: 0 means "uncomputed". - MAP_IGNORE = 1, ///< Map this diagnostic to nothing, ignore it. - MAP_REMARK = 2, ///< Map this diagnostic to a remark. - MAP_WARNING = 3, ///< Map this diagnostic to a warning. - MAP_ERROR = 4, ///< Map this diagnostic to an error. - MAP_FATAL = 5 ///< Map this diagnostic to a fatal error. + Ignored = 1, ///< Do not present this diagnostic, ignore it. + Remark = 2, ///< Present this diagnostic as a remark. + Warning = 3, ///< Present this diagnostic as a warning. + Error = 4, ///< Present this diagnostic as an error. + Fatal = 5 ///< Present this diagnostic as a fatal error. }; } @@ -81,7 +80,7 @@ public: static DiagnosticMapping Make(diag::Severity Severity, bool IsUser, bool IsPragma) { DiagnosticMapping Result; - Result.Severity = Severity; + Result.Severity = (unsigned)Severity; Result.IsUser = IsUser; Result.IsPragma = IsPragma; Result.HasNoWarningAsError = 0; @@ -89,8 +88,8 @@ public: return Result; } - diag::Severity getSeverity() const { return diag::Severity(Severity); } - void setSeverity(diag::Severity Value) { Severity = Value; } + diag::Severity getSeverity() const { return (diag::Severity)Severity; } + void setSeverity(diag::Severity Value) { Severity = (unsigned)Value; } bool isUser() const { return IsUser; } bool isPragma() const { return IsPragma; } @@ -257,9 +256,9 @@ private: /// \brief An internal implementation helper used when \p DiagClass is /// already known. - DiagnosticIDs::Level - getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, SourceLocation Loc, - const DiagnosticsEngine &Diag) const LLVM_READONLY; + diag::Severity + getDiagnosticSeverity(unsigned DiagID, unsigned DiagClass, SourceLocation Loc, + const DiagnosticsEngine &Diag) const LLVM_READONLY; /// \brief Used to report a diagnostic that is finally fully formed. /// |