diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-02-25 01:28:26 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-02-25 01:28:26 +0000 |
commit | b6f9ab63781f0b63079e8ec0fbd2745296e425f1 (patch) | |
tree | 1c649074f0f1cf612455ec270de1837d0f1fb17a /clang/lib/Frontend | |
parent | 4c82cd21ed47db332cbf74627f6a761d2a6326d2 (diff) | |
download | bcm5719-llvm-b6f9ab63781f0b63079e8ec0fbd2745296e425f1.tar.gz bcm5719-llvm-b6f9ab63781f0b63079e8ec0fbd2745296e425f1.zip |
Teach TextDiagnosticPrinter to print out '-Werror' in addition to the warning flag for a warning mapped to an error.
For example:
t.c:7:9: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses]
llvm-svn: 126466
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r-- | clang/lib/Frontend/TextDiagnosticPrinter.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp index 04c6a68023d..084915311dc 100644 --- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/clang/lib/Frontend/TextDiagnosticPrinter.cpp @@ -905,9 +905,21 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, std::string OptionName; if (DiagOpts->ShowOptionNames) { + // Was this a warning mapped to an error using -Werror or pragma? + if (Level == Diagnostic::Error && + DiagnosticIDs::isBuiltinWarningOrExtension(Info.getID())) { + diag::Mapping mapping = diag::MAP_IGNORE; + Info.getDiags()->getDiagnosticLevel(Info.getID(), Info.getLocation(), + &mapping); + if (mapping == diag::MAP_WARNING) + OptionName += "-Werror"; + } + if (const char * Opt = DiagnosticIDs::getWarningOptionForDiag(Info.getID())) { - OptionName = "-W"; + if (!OptionName.empty()) + OptionName += ','; + OptionName += "-W"; OptionName += Opt; } else if (Info.getID() == diag::fatal_too_many_errors) { OptionName = "-ferror-limit="; |