implement framework for -fdiagnostics-show-option, but tblgen isn't

passing down the right info yet.

llvm-svn: 69268
This commit is contained in:
Chris Lattner 2009-04-16 05:44:38 +00:00
parent 805ab5a746
commit 22cb818913
6 changed files with 26 additions and 4 deletions

View File

@ -302,6 +302,10 @@ public:
///
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

View File

@ -37,15 +37,18 @@ class TextDiagnosticPrinter : public DiagnosticClient {
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;

View File

@ -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 {

View File

@ -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

View File

@ -93,7 +93,6 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags) {
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) {

View File

@ -303,6 +303,9 @@ static llvm::cl::opt<bool>
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.
@ -2227,7 +2230,8 @@ int main(int argc, char **argv) {
!NoShowColumn,
!NoCaretDiagnostics,
!NoShowLocation,
PrintSourceRangeInfo);
PrintSourceRangeInfo,
PrintDiagnosticOption);
} else {
// When checking diagnostics, just buffer them up.
TextDiagClient = new TextDiagnosticBuffer();