[cfe-commits] r142121 - /cfe/trunk/lib/Frontend/TextDiagnostic.cpp

Chandler Carruth chandlerc at gmail.com
Sun Oct 16 00:36:11 PDT 2011


Author: chandlerc
Date: Sun Oct 16 02:36:11 2011
New Revision: 142121

URL: http://llvm.org/viewvc/llvm-project?rev=142121&view=rev
Log:
Fix the original bug in our diagnostic printing that got me started on
this long quest: actually use the note printing machinery for each macro
expansion note rather than a hacky version of it. This will colorize and
format the notes the same as any other. There is still some stuff to fix
here, but it's one step closer.

No test case changes because currently we don't do anything differently
that I can FileCheck for -- I don't really want to try matching the
color escape codes... Suggestions for how to test this are welcome. =]

Modified:
    cfe/trunk/lib/Frontend/TextDiagnostic.cpp

Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=142121&r1=142120&r2=142121&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Sun Oct 16 02:36:11 2011
@@ -714,39 +714,22 @@
       I->setEnd(getImmediateMacroCalleeLoc(SM, End));
   }
 
-  if (!Suppressed) {
-    // Don't print recursive expansion notes from an expansion note.
-    Loc = SM.getSpellingLoc(Loc);
-
-    // Get the pretty name, according to #line directives etc.
-    PresumedLoc PLoc = SM.getPresumedLoc(Loc);
-    if (PLoc.isInvalid())
-      return;
-
-    // If this diagnostic is not in the main file, print out the
-    // "included from" lines.
-    emitIncludeStack(PLoc.getIncludeLoc(), DiagnosticsEngine::Note);
-
-    if (DiagOpts.ShowLocation) {
-      // Emit the file/line/column that this expansion came from.
-      OS << PLoc.getFilename() << ':' << PLoc.getLine() << ':';
-      if (DiagOpts.ShowColumn)
-        OS << PLoc.getColumn() << ':';
-      OS << ' ';
+  if (Suppressed) {
+    // Tell the user that we've skipped contexts.
+    if (OnMacroInst == MacroSkipStart) {
+      // FIXME: Emit this as a real note diagnostic.
+      // FIXME: Format an actual diagnostic rather than a hard coded string.
+      OS << "note: (skipping " << (MacroSkipEnd - MacroSkipStart)
+         << " expansions in backtrace; use -fmacro-backtrace-limit=0 to see "
+            "all)\n";
     }
-    OS << "note: expanded from:\n";
-
-    emitSnippetAndCaret(Loc, DiagnosticsEngine::Note, Ranges,
-                        ArrayRef<FixItHint>());
     return;
   }
 
-  if (OnMacroInst == MacroSkipStart) {
-    // Tell the user that we've skipped contexts.
-    OS << "note: (skipping " << (MacroSkipEnd - MacroSkipStart) 
-    << " expansions in backtrace; use -fmacro-backtrace-limit=0 to see "
-    "all)\n";
-  }
+  // FIXME: Format an actual diagnostic rather than a hard coded string.
+  emitDiagnostic(SM.getSpellingLoc(Loc), DiagnosticsEngine::Note,
+                 "expanded from:",
+                 Ranges, ArrayRef<FixItHint>());
 }
 
 /// \brief Emit a code snippet and caret line.





More information about the cfe-commits mailing list