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 | 7decebfc7b9dc841f228c93cc2e41e3e62911ff8 (patch) | |
tree | 3888e867aa445da37081eecea528019eef96b900 /lib/Frontend/TextDiagnosticPrinter.cpp | |
parent | 9e63d4aed8ce544ab105623ad8e36d43e1e11314 (diff) |
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]
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126466 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/TextDiagnosticPrinter.cpp')
-rw-r--r-- | lib/Frontend/TextDiagnosticPrinter.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index 04c6a68023..084915311d 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/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="; |