implement compiler support for -fno-diagnostics-fixit-info,

rdar://6805442

llvm-svn: 69525
This commit is contained in:
Chris Lattner 2009-04-19 07:44:08 +00:00
parent 30b55dc946
commit 29d34cabc5
3 changed files with 16 additions and 7 deletions

View File

@ -38,17 +38,20 @@ class TextDiagnosticPrinter : public DiagnosticClient {
bool ShowLocation; bool ShowLocation;
bool PrintRangeInfo; bool PrintRangeInfo;
bool PrintDiagnosticOption; bool PrintDiagnosticOption;
bool PrintFixItInfo;
public: public:
TextDiagnosticPrinter(llvm::raw_ostream &os, TextDiagnosticPrinter(llvm::raw_ostream &os,
bool showColumn = true, bool showColumn = true,
bool caretDiagnistics = true, bool showLocation = true, bool caretDiagnistics = true, bool showLocation = true,
bool printRangeInfo = true, bool printRangeInfo = true,
bool printDiagnosticOption = true) bool printDiagnosticOption = true,
bool printFixItInfo = true)
: OS(os), LangOpts(0), : OS(os), LangOpts(0),
LastCaretDiagnosticWasNote(false), ShowColumn(showColumn), LastCaretDiagnosticWasNote(false), ShowColumn(showColumn),
CaretDiagnostics(caretDiagnistics), ShowLocation(showLocation), CaretDiagnostics(caretDiagnistics), ShowLocation(showLocation),
PrintRangeInfo(printRangeInfo), PrintRangeInfo(printRangeInfo),
PrintDiagnosticOption(printDiagnosticOption) {} PrintDiagnosticOption(printDiagnosticOption),
PrintFixItInfo(printFixItInfo) {}
void setLangOptions(const LangOptions *LO) { void setLangOptions(const LangOptions *LO) {
LangOpts = LO; LangOpts = LO;

View File

@ -207,10 +207,9 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc,
OS << SourceLine << '\n'; OS << SourceLine << '\n';
OS << CaretLine << '\n'; OS << CaretLine << '\n';
if (NumHints) { if (NumHints && PrintFixItInfo) {
std::string InsertionLine; std::string InsertionLine;
for (const CodeModificationHint *Hint = Hints, for (const CodeModificationHint *Hint = Hints, *LastHint = Hints + NumHints;
*LastHint = Hints + NumHints;
Hint != LastHint; ++Hint) { Hint != LastHint; ++Hint) {
if (Hint->InsertionLoc.isValid()) { if (Hint->InsertionLoc.isValid()) {
// We have an insertion hint. Determine whether the inserted // We have an insertion hint. Determine whether the inserted

View File

@ -299,6 +299,11 @@ NoCaretDiagnostics("fno-caret-diagnostics",
llvm::cl::desc("Do not include source line and caret with" llvm::cl::desc("Do not include source line and caret with"
" diagnostics")); " diagnostics"));
static llvm::cl::opt<bool>
NoDiagnosticsFixIt("fno-diagnostics-fixit-info",
llvm::cl::desc("Do not include fixit information in"
" diagnostics"));
static llvm::cl::opt<bool> static llvm::cl::opt<bool>
PrintSourceRangeInfo("fprint-source-range-info", PrintSourceRangeInfo("fprint-source-range-info",
llvm::cl::desc("Print source range spans in numeric form")); llvm::cl::desc("Print source range spans in numeric form"));
@ -1873,7 +1878,8 @@ public:
!NoCaretDiagnostics, !NoCaretDiagnostics,
!NoShowLocation, !NoShowLocation,
PrintSourceRangeInfo, PrintSourceRangeInfo,
PrintDiagnosticOption)); PrintDiagnosticOption,
!NoDiagnosticsFixIt));
} }
virtual void setLangOptions(const LangOptions *LO) { virtual void setLangOptions(const LangOptions *LO) {
@ -2329,7 +2335,8 @@ int main(int argc, char **argv) {
!NoCaretDiagnostics, !NoCaretDiagnostics,
!NoShowLocation, !NoShowLocation,
PrintSourceRangeInfo, PrintSourceRangeInfo,
PrintDiagnosticOption)); PrintDiagnosticOption,
!NoDiagnosticsFixIt));
} else { } else {
DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag)); DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag));
} }