]> granicus.if.org Git - clang/commitdiff
implement compiler support for -fno-diagnostics-fixit-info,
authorChris Lattner <sabre@nondot.org>
Sun, 19 Apr 2009 07:44:08 +0000 (07:44 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 19 Apr 2009 07:44:08 +0000 (07:44 +0000)
rdar://6805442

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69525 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/TextDiagnosticPrinter.h
lib/Frontend/TextDiagnosticPrinter.cpp
tools/clang-cc/clang-cc.cpp

index afdafb2b34a95570a41114476f3d576e2b5035ee..ef8dae5e35b3167e1879129da831c013e276013e 100644 (file)
@@ -38,17 +38,20 @@ class TextDiagnosticPrinter : public DiagnosticClient {
   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;
index 9583780870489953cd67ae59e06ace9c937f5231..7d3c4c23ffd6a9b06c895321a135ec0a455f8a96 100644 (file)
@@ -207,10 +207,9 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc,
   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
index 4e5ff5d2595794380d8a92d686c65a9e94fdad47..e69c62bb39766558ea73b8f117b3d2e663856aaa 100644 (file)
@@ -299,6 +299,11 @@ NoCaretDiagnostics("fno-caret-diagnostics",
                    llvm::cl::desc("Do not include source line and caret with"
                                   " 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 @@ public:
                                            !NoCaretDiagnostics,
                                            !NoShowLocation,
                                            PrintSourceRangeInfo,
-                                           PrintDiagnosticOption));
+                                           PrintDiagnosticOption,
+                                           !NoDiagnosticsFixIt));
   }
   
   virtual void setLangOptions(const LangOptions *LO) {
@@ -2329,7 +2335,8 @@ int main(int argc, char **argv) {
                                                !NoCaretDiagnostics,
                                                !NoShowLocation,
                                                PrintSourceRangeInfo,
-                                               PrintDiagnosticOption));
+                                               PrintDiagnosticOption,
+                                               !NoDiagnosticsFixIt));
   } else {
     DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag));
   }