implement compiler support for -fno-diagnostics-fixit-info,
rdar://6805442
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69525 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Frontend/TextDiagnosticPrinter.h b/include/clang/Frontend/TextDiagnosticPrinter.h
index afdafb2..ef8dae5 100644
--- a/include/clang/Frontend/TextDiagnosticPrinter.h
+++ b/include/clang/Frontend/TextDiagnosticPrinter.h
@@ -38,17 +38,20 @@
bool ShowLocation;
bool PrintRangeInfo;
bool PrintDiagnosticOption;
+ bool PrintFixItInfo;
public:
TextDiagnosticPrinter(llvm::raw_ostream &os,
bool showColumn = true,
bool caretDiagnistics = true, bool showLocation = true,
bool printRangeInfo = true,
- bool printDiagnosticOption = true)
+ bool printDiagnosticOption = true,
+ bool printFixItInfo = true)
: OS(os), LangOpts(0),
LastCaretDiagnosticWasNote(false), ShowColumn(showColumn),
CaretDiagnostics(caretDiagnistics), ShowLocation(showLocation),
PrintRangeInfo(printRangeInfo),
- PrintDiagnosticOption(printDiagnosticOption) {}
+ PrintDiagnosticOption(printDiagnosticOption),
+ PrintFixItInfo(printFixItInfo) {}
void setLangOptions(const LangOptions *LO) {
LangOpts = LO;
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index 9583780..7d3c4c2 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -207,10 +207,9 @@
OS << SourceLine << '\n';
OS << CaretLine << '\n';
- if (NumHints) {
+ if (NumHints && PrintFixItInfo) {
std::string InsertionLine;
- for (const CodeModificationHint *Hint = Hints,
- *LastHint = Hints + NumHints;
+ for (const CodeModificationHint *Hint = Hints, *LastHint = Hints + NumHints;
Hint != LastHint; ++Hint) {
if (Hint->InsertionLoc.isValid()) {
// We have an insertion hint. Determine whether the inserted
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 4e5ff5d..e69c62b 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -300,6 +300,11 @@
" 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>
PrintSourceRangeInfo("fprint-source-range-info",
llvm::cl::desc("Print source range spans in numeric form"));
@@ -1873,7 +1878,8 @@
!NoCaretDiagnostics,
!NoShowLocation,
PrintSourceRangeInfo,
- PrintDiagnosticOption));
+ PrintDiagnosticOption,
+ !NoDiagnosticsFixIt));
}
virtual void setLangOptions(const LangOptions *LO) {
@@ -2329,7 +2335,8 @@
!NoCaretDiagnostics,
!NoShowLocation,
PrintSourceRangeInfo,
- PrintDiagnosticOption));
+ PrintDiagnosticOption,
+ !NoDiagnosticsFixIt));
} else {
DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag));
}