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. =]

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142121 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/TextDiagnostic.cpp b/lib/Frontend/TextDiagnostic.cpp
index 346443d..7b3ebc4 100644
--- a/lib/Frontend/TextDiagnostic.cpp
+++ b/lib/Frontend/TextDiagnostic.cpp
@@ -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.