diff options
| author | Alp Toker <alp@nuanti.com> | 2014-06-16 13:56:47 +0000 |
|---|---|---|
| committer | Alp Toker <alp@nuanti.com> | 2014-06-16 13:56:47 +0000 |
| commit | 04278ece9e3162fa72421dd13de366fa67c8ff88 (patch) | |
| tree | 4388c6652518c045895cbf03f85bdbd18b8337bf /clang | |
| parent | 998d991b2d9ade805aeeb863bf85e93cb91d16f7 (diff) | |
| download | bcm5719-llvm-04278ece9e3162fa72421dd13de366fa67c8ff88.tar.gz bcm5719-llvm-04278ece9e3162fa72421dd13de366fa67c8ff88.zip | |
Use the ShowInSystemHeader bit consistently for all diagnostics
By describing system header suppressions directly in tablegen we eliminate
special cases in getDiagnosticSeverity().
Dropping the reliance on builtin diagnostic classes when mapping also gets us
closer to the goal of reusing the diagnostic machinery for custom diagnostics.
No change in functionality.
llvm-svn: 211023
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/Basic/Diagnostic.h | 4 | ||||
| -rw-r--r-- | clang/include/clang/Basic/Diagnostic.td | 13 | ||||
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticFrontendKinds.td | 2 | ||||
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticIDs.h | 4 | ||||
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticLexKinds.td | 4 | ||||
| -rw-r--r-- | clang/lib/Basic/DiagnosticIDs.cpp | 14 | ||||
| -rw-r--r-- | clang/utils/TableGen/ClangDiagnosticsEmitter.cpp | 3 |
7 files changed, 22 insertions, 22 deletions
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h index b0f52165bb2..b9da131de38 100644 --- a/clang/include/clang/Basic/Diagnostic.h +++ b/clang/include/clang/Basic/Diagnostic.h @@ -651,8 +651,8 @@ public: /// \param Loc The source location we are interested in finding out the /// diagnostic state. Can be null in order to query the latest state. bool isIgnored(unsigned DiagID, SourceLocation Loc) const { - return Diags->getDiagnosticLevel(DiagID, Loc, *this) == - DiagnosticIDs::Ignored; + return Diags->getDiagnosticSeverity(DiagID, Loc, *this) == + diag::Severity::Ignored; } /// \brief Based on the way the client configured the DiagnosticsEngine diff --git a/clang/include/clang/Basic/Diagnostic.td b/clang/include/clang/Basic/Diagnostic.td index dd16a6a78ce..978fd59ad85 100644 --- a/clang/include/clang/Basic/Diagnostic.td +++ b/clang/include/clang/Basic/Diagnostic.td @@ -69,7 +69,7 @@ class Diagnostic<string text, DiagClass DC, Severity defaultmapping> { SFINAEResponse SFINAE = SFINAE_Suppress; bit AccessControl = 0; bit WarningNoWerror = 0; - bit WarningShowInSystemHeader = 0; + bit ShowInSystemHeader = 0; Severity DefaultSeverity = defaultmapping; DiagGroup Group; string CategoryName = ""; @@ -85,8 +85,14 @@ class AccessControl { SFINAEResponse SFINAE = SFINAE_AccessControl; } +class ShowInSystemHeader { + bit ShowInSystemHeader = 1; +} + // FIXME: ExtWarn and Extension should also be SFINAEFailure by default. -class Error<string str> : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure; +class Error<string str> : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure { + bit ShowInSystemHeader = 1; +} 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>; @@ -101,9 +107,6 @@ class DefaultFatal { Severity DefaultSeverity = SEV_Fatal; } class DefaultWarnNoWerror { bit WarningNoWerror = 1; } -class DefaultWarnShowInSystemHeader { - bit WarningShowInSystemHeader = 1; -} class DefaultRemark { Severity DefaultSeverity = SEV_Remark; } // Definitions for Diagnostics. diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index c084254b0f4..2d6ca696955 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -class BackendInfo : CatBackend, DefaultWarnShowInSystemHeader; +class BackendInfo : CatBackend, ShowInSystemHeader; let Component = "Frontend" in { diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h index 8b670500cf3..c28f195b226 100644 --- a/clang/include/clang/Basic/DiagnosticIDs.h +++ b/clang/include/clang/Basic/DiagnosticIDs.h @@ -254,10 +254,8 @@ private: getDiagnosticLevel(unsigned DiagID, SourceLocation Loc, const DiagnosticsEngine &Diag) const LLVM_READONLY; - /// \brief An internal implementation helper used when \p DiagClass is - /// already known. diag::Severity - getDiagnosticSeverity(unsigned DiagID, unsigned DiagClass, SourceLocation Loc, + getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc, const DiagnosticsEngine &Diag) const LLVM_READONLY; /// \brief Used to report a diagnostic that is finally fully formed. diff --git a/clang/include/clang/Basic/DiagnosticLexKinds.td b/clang/include/clang/Basic/DiagnosticLexKinds.td index 88b4da5d37c..4aceaf5e4f0 100644 --- a/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -247,7 +247,7 @@ def err_invalid_pth_file : Error< let CategoryName = "User Defined Issues" in { def pp_hash_warning : Warning<"%0">, - InGroup<PoundWarning>, DefaultWarnShowInSystemHeader; + InGroup<PoundWarning>, ShowInSystemHeader; def err_pp_hash_error : Error<"%0">; } @@ -544,7 +544,7 @@ def err_pp_eof_in_arc_cf_code_audited : Error< def warn_pp_date_time : Warning< "expansion of date or time macro is not reproducible">, - DefaultWarnShowInSystemHeader, DefaultIgnore, InGroup<DiagGroup<"date-time">>; + ShowInSystemHeader, DefaultIgnore, InGroup<DiagGroup<"date-time">>; // Module map parsing def err_mmap_unknown_token : Error<"skipping stray token">; diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp index 6bc230a33ca..8fae207e8ea 100644 --- a/clang/lib/Basic/DiagnosticIDs.cpp +++ b/clang/lib/Basic/DiagnosticIDs.cpp @@ -394,7 +394,7 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, SourceLocation Loc, unsigned DiagClass = getBuiltinDiagClass(DiagID); if (DiagClass == CLASS_NOTE) return DiagnosticIDs::Note; - return toLevel(getDiagnosticSeverity(DiagID, DiagClass, Loc, Diag)); + return toLevel(getDiagnosticSeverity(DiagID, Loc, Diag)); } /// \brief Based on the way the client configured the Diagnostic @@ -404,10 +404,9 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, SourceLocation Loc, /// \param Loc The source location we are interested in finding out the /// diagnostic state. Can be null in order to query the latest state. diag::Severity -DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, unsigned DiagClass, - SourceLocation Loc, +DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc, const DiagnosticsEngine &Diag) const { - assert(DiagClass != CLASS_NOTE); + assert(getBuiltinDiagClass(DiagID) != CLASS_NOTE); // Specific non-error diagnostics may be mapped to various levels from ignored // to error. Errors can only be mapped to fatal. @@ -431,7 +430,9 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, unsigned DiagClass, // Diagnostics of class REMARK are either printed as remarks or in case they // have been added to -Werror they are printed as errors. - if (DiagClass == CLASS_REMARK && Result == diag::Severity::Warning) + // FIXME: Disregarding user-requested remark mappings like this is bogus. + if (Result == diag::Severity::Warning && + getBuiltinDiagClass(DiagID) == CLASS_REMARK) Result = diag::Severity::Remark; // Ignore -pedantic diagnostics inside __extension__ blocks. @@ -491,8 +492,7 @@ DiagnosticIDs::getDiagnosticSeverity(unsigned DiagID, unsigned DiagClass, // If we are in a system header, we ignore it. We look at the diagnostic class // because we also want to ignore extensions and warnings in -Werror and // -pedantic-errors modes, which *map* warnings/extensions to errors. - if (Result >= diag::Severity::Warning && DiagClass != CLASS_ERROR && - !ShowInSystemHeader && Diag.SuppressSystemWarnings && Loc.isValid() && + if (Diag.SuppressSystemWarnings && !ShowInSystemHeader && Loc.isValid() && Diag.getSourceManager().isInSystemHeader( Diag.getSourceManager().getExpansionLoc(Loc))) return diag::Severity::Ignored; diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 76b484e7837..e5177554177 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -571,8 +571,7 @@ void EmitClangDiagsDefs(RecordKeeper &Records, raw_ostream &OS, else OS << ", false"; - // Default warning show in system header bit. - if (R.getValueAsBit("WarningShowInSystemHeader")) + if (R.getValueAsBit("ShowInSystemHeader")) OS << ", true"; else OS << ", false"; |

