diff options
author | Chris Lattner <sabre@nondot.org> | 2011-06-28 05:11:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-06-28 05:11:33 +0000 |
commit | ac57f21cd157bd9620b8bf037d6028774b93a9a9 (patch) | |
tree | 15865d71573bac46e86a9e45182d824eee5aae07 /clang/lib/Frontend | |
parent | 411daa5e8170bd0c3d3309e4ca01e42fb5a6e726 (diff) | |
download | bcm5719-llvm-ac57f21cd157bd9620b8bf037d6028774b93a9a9.tar.gz bcm5719-llvm-ac57f21cd157bd9620b8bf037d6028774b93a9a9.zip |
Fix PR9279 - Macro expansion stack trace seriously broken with function-style macros, by not recursively printing notes for other 'instantiated from' notes.
This is a one line fix here:
+ // Don't print recursive instantiation notes from an instantiation note.
+ Loc = SM.getSpellingLoc(Loc);
While here, fix the testcase to be more precise (it got filecheck'ized
brutally), and fix EmitCaretDiagnostic to be private and to not pass down
the unused 'Level' argument.
llvm-svn: 133993
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r-- | clang/lib/Frontend/TextDiagnosticPrinter.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp index 76f2f3ea7d7..affa12babe5 100644 --- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/clang/lib/Frontend/TextDiagnosticPrinter.cpp @@ -292,8 +292,7 @@ static void SelectInterestingSourceRegion(std::string &SourceLine, } } -void TextDiagnosticPrinter::EmitCaretDiagnostic(Diagnostic::Level Level, - SourceLocation Loc, +void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, CharSourceRange *Ranges, unsigned NumRanges, const SourceManager &SM, @@ -314,10 +313,10 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(Diagnostic::Level Level, bool Suppressed = OnMacroInst >= MacroSkipStart && OnMacroInst < MacroSkipEnd; - SourceLocation OneLevelUp = SM.getImmediateInstantiationRange(Loc).first; + // FIXME: Map ranges? - EmitCaretDiagnostic(Level, OneLevelUp, Ranges, NumRanges, SM, + EmitCaretDiagnostic(OneLevelUp, Ranges, NumRanges, SM, Hints, NumHints, Columns, OnMacroInst + 1, MacroSkipStart, MacroSkipEnd); @@ -356,7 +355,10 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(Diagnostic::Level Level, } OS << "note: instantiated from:\n"; - EmitCaretDiagnostic(Level, Loc, Ranges, NumRanges, SM, 0, 0, + // Don't print recursive instantiation notes from an instantiation note. + Loc = SM.getSpellingLoc(Loc); + + EmitCaretDiagnostic(Loc, Ranges, NumRanges, SM, 0, 0, Columns, OnMacroInst + 1, MacroSkipStart, MacroSkipEnd); return; @@ -371,7 +373,7 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(Diagnostic::Level Level, return; } - + // Decompose the location into a FID/Offset pair. std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Loc); FileID FID = LocInfo.first; @@ -1059,7 +1061,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, } } - EmitCaretDiagnostic(Level, LastLoc, Ranges, NumRanges, LastLoc.getManager(), + EmitCaretDiagnostic(LastLoc, Ranges, NumRanges, LastLoc.getManager(), Info.getFixItHints(), Info.getNumFixItHints(), DiagOpts->MessageLength, |