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 | 46df1c0db8a3265009f5b315247b657708883fe8 (patch) | |
tree | b8c65f5bf61b4484ce3184f34265c0ec8815ea63 /clang/lib/Lex/Pragma.cpp | |
parent | 789ba735703c70c928b8753b80280eecb374050a (diff) | |
download | bcm5719-llvm-46df1c0db8a3265009f5b315247b657708883fe8.tar.gz bcm5719-llvm-46df1c0db8a3265009f5b315247b657708883fe8.zip |
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.
llvm-svn: 210758
Diffstat (limited to 'clang/lib/Lex/Pragma.cpp')
-rw-r--r-- | clang/lib/Lex/Pragma.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp index ea3a10d5369..f1b96f8b558 100644 --- a/clang/lib/Lex/Pragma.cpp +++ b/clang/lib/Lex/Pragma.cpp @@ -954,16 +954,7 @@ public: IdentifierInfo *II = Tok.getIdentifierInfo(); PPCallbacks *Callbacks = PP.getPPCallbacks(); - diag::Severity Map; - if (II->isStr("warning")) - Map = diag::MAP_WARNING; - else if (II->isStr("error")) - Map = diag::MAP_ERROR; - else if (II->isStr("ignored")) - Map = diag::MAP_IGNORE; - else if (II->isStr("fatal")) - Map = diag::MAP_FATAL; - else if (II->isStr("pop")) { + if (II->isStr("pop")) { if (!PP.getDiagnostics().popMappings(DiagLoc)) PP.Diag(Tok, diag::warn_pragma_diagnostic_cannot_pop); else if (Callbacks) @@ -974,7 +965,16 @@ public: if (Callbacks) Callbacks->PragmaDiagnosticPush(DiagLoc, Namespace); return; - } else { + } + + diag::Severity SV = llvm::StringSwitch<diag::Severity>(II->getName()) + .Case("ignored", diag::Severity::Ignored) + .Case("warning", diag::Severity::Warning) + .Case("error", diag::Severity::Error) + .Case("fatal", diag::Severity::Fatal) + .Default(diag::Severity()); + + if (SV == diag::Severity()) { PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid); return; } @@ -998,12 +998,12 @@ public: return; } - if (PP.getDiagnostics().setDiagnosticGroupMapping(WarningName.substr(2), - Map, DiagLoc)) + if (PP.getDiagnostics().setDiagnosticGroupMapping(WarningName.substr(2), SV, + DiagLoc)) PP.Diag(StringLoc, diag::warn_pragma_diagnostic_unknown_warning) << WarningName; else if (Callbacks) - Callbacks->PragmaDiagnostic(DiagLoc, Namespace, Map, WarningName); + Callbacks->PragmaDiagnostic(DiagLoc, Namespace, SV, WarningName); } }; |