diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Basic/Diagnostic.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Frontend/TextDiagnosticPrinter.cpp | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index 31f56e99bf4..16cb111e2c2 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -65,6 +65,13 @@ static unsigned GetDefaultDiagMapping(unsigned DiagID) { return diag::MAP_FATAL; } +/// getWarningOptionForDiag - Return the lowest-level warning option that +/// enables the specified diagnostic. If there is no -Wfoo flag that controls +/// the diagnostic, this returns null. +const char *Diagnostic::getWarningOptionForDiag(unsigned DiagID) { + return 0; //"Wfoo"; +} + // Diagnostic classes. enum { diff --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp index c472a140cbf..24f66dac7f4 100644 --- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/clang/lib/Frontend/TextDiagnosticPrinter.cpp @@ -308,6 +308,11 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, llvm::SmallString<100> OutStr; Info.FormatDiagnostic(OutStr); OS.write(OutStr.begin(), OutStr.size()); + + if (PrintDiagnosticOption) + if (const char *Option = Diagnostic::getWarningOptionForDiag(Info.getID())) + OS << " [-" << Option << ']'; + OS << '\n'; // If caret diagnostics are enabled and we have location, we want to |