///
static bool isBuiltinExtensionDiag(unsigned DiagID);
+ /// 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.
+ static const char *getWarningOptionForDiag(unsigned DiagID);
/// getDiagnosticLevel - Based on the way the client configured the Diagnostic
/// object, classify the specified diagnostic ID into a Level, consumable by
bool CaretDiagnostics;
bool ShowLocation;
bool PrintRangeInfo;
+ bool PrintDiagnosticOption;
public:
TextDiagnosticPrinter(llvm::raw_ostream &os,
bool showColumn = true,
bool caretDiagnistics = true, bool showLocation = true,
- bool printRangeInfo = true)
+ bool printRangeInfo = true,
+ bool printDiagnosticOption = true)
: OS(os), LangOpts(0),
LastCaretDiagnosticWasNote(false), ShowColumn(showColumn),
CaretDiagnostics(caretDiagnistics), ShowLocation(showLocation),
- PrintRangeInfo(printRangeInfo) {}
+ PrintRangeInfo(printRangeInfo),
+ PrintDiagnosticOption(printDiagnosticOption) {}
void SetLangOpts(const LangOptions &LO) {
LangOpts = &LO;
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 {
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
else
Diags.setExtensionHandlingBehavior(Diagnostic::Ext_Ignore);
- // FIXME: -fdiagnostics-show-option
// FIXME: -Wfatal-errors / -Wfatal-errors=foo
for (unsigned i = 0, e = OptWarnings.size(); i != e; ++i) {
PrintSourceRangeInfo("fprint-source-range-info",
llvm::cl::desc("Print source range spans in numeric form"));
+static llvm::cl::opt<bool>
+PrintDiagnosticOption("fdiagnostics-show-option",
+ llvm::cl::desc("Print diagnostic name with mappable diagnostics"));
//===----------------------------------------------------------------------===//
// C++ Visualization.
!NoShowColumn,
!NoCaretDiagnostics,
!NoShowLocation,
- PrintSourceRangeInfo);
+ PrintSourceRangeInfo,
+ PrintDiagnosticOption);
} else {
// When checking diagnostics, just buffer them up.
TextDiagClient = new TextDiagnosticBuffer();