implement framework for -fdiagnostics-show-option, but tblgen isn't
passing down the right info yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69268 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index 31f56e9..16cb111 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -65,6 +65,13 @@
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/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index c472a14..24f66da 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -308,6 +308,11 @@
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