From 938ef249e9e5b5e3b7065c7f92b2578aa2dd971b Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 16 Oct 2011 07:36:11 +0000 Subject: [PATCH] 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 --- lib/Frontend/TextDiagnostic.cpp | 41 ++++++++++----------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/lib/Frontend/TextDiagnostic.cpp b/lib/Frontend/TextDiagnostic.cpp index 346443d109..7b3ebc4cd6 100644 --- a/lib/Frontend/TextDiagnostic.cpp +++ b/lib/Frontend/TextDiagnostic.cpp @@ -714,39 +714,22 @@ void TextDiagnostic::emitMacroExpansionsAndCarets( 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()); 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()); } /// \brief Emit a code snippet and caret line. -- 2.40.0