summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-09-29 01:01:08 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-09-29 01:01:08 +0000
commitaa11138543d419a5152b35564d59a853687fa7fc (patch)
tree9f7a159e6c4490c8265e87f4499dfe3c94afa485 /clang/lib/Frontend
parentcc5f8d45173668385d047c7538acd92ba501e2df (diff)
downloadbcm5719-llvm-aa11138543d419a5152b35564d59a853687fa7fc.tar.gz
bcm5719-llvm-aa11138543d419a5152b35564d59a853687fa7fc.zip
Basic/Diagnostics: Add an isDefaultMappingAsError method, and switch TextDiagnosticPrinter to use that instead of extracting the current mapping via getDiagnosticLevel, which fixes one class of corner cases w.r.t. printing the "-Werror" diagnostic option marker.
- The TextDiagnosticPrinter code is still fragile as it is just "reverse engineering" what the diagnostic engine is doing. Not my current priority to fix though. llvm-svn: 140752
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/TextDiagnosticPrinter.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp
index 378e673812d..6af66c797a9 100644
--- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/clang/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -942,16 +942,20 @@ static void printDiagnosticOptions(raw_ostream &OS,
return;
}
- // Was this a warning mapped to an error using -Werror or pragma?
+ // The code below is somewhat fragile because we are essentially trying to
+ // report to the user what happened by inferring what the diagnostic engine
+ // did. Eventually it might make more sense to have the diagnostic engine
+ // include some "why" information in the diagnostic.
+
+ // If this is a warning which has been mapped to an error by the user (as
+ // inferred by checking whether the default mapping is to an error) then
+ // flag it as such. Note that diagnostics could also have been mapped by a
+ // pragma, but we don't currently have a way to distinguish this.
if (Level == DiagnosticsEngine::Error &&
- DiagnosticIDs::isBuiltinWarningOrExtension(Info.getID())) {
- diag::Mapping mapping = diag::MAP_IGNORE;
- Info.getDiags()->getDiagnosticLevel(Info.getID(), Info.getLocation(),
- &mapping);
- if (mapping == diag::MAP_WARNING) {
- OS << " [-Werror";
- Started = true;
- }
+ DiagnosticIDs::isBuiltinWarningOrExtension(Info.getID()) &&
+ !DiagnosticIDs::isDefaultMappingAsError(Info.getID())) {
+ OS << " [-Werror";
+ Started = true;
}
// If the diagnostic is an extension diagnostic and not enabled by default
OpenPOWER on IntegriCloud