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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133993
91177308-0d34-0410-b5e6-
96231b3b80d8
std::string &CaretLine,
const std::string &SourceLine);
- void EmitCaretDiagnostic(Diagnostic::Level Level, SourceLocation Loc,
- CharSourceRange *Ranges, unsigned NumRanges,
- const SourceManager &SM,
- const FixItHint *Hints,
- unsigned NumHints,
- unsigned Columns,
- unsigned OnMacroInst,
- unsigned MacroSkipStart,
- unsigned MacroSkipEnd);
-
virtual void HandleDiagnostic(Diagnostic::Level Level,
const DiagnosticInfo &Info);
+
+private:
+ void EmitCaretDiagnostic(SourceLocation Loc, CharSourceRange *Ranges,
+ unsigned NumRanges, const SourceManager &SM,
+ const FixItHint *Hints,
+ unsigned NumHints, unsigned Columns,
+ unsigned OnMacroInst, unsigned MacroSkipStart,
+ unsigned MacroSkipEnd);
+
};
} // end namespace clang
}
}
-void TextDiagnosticPrinter::EmitCaretDiagnostic(Diagnostic::Level Level,
- SourceLocation Loc,
+void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc,
CharSourceRange *Ranges,
unsigned NumRanges,
const SourceManager &SM,
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);
}
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;
return;
}
-
+
// Decompose the location into a FID/Offset pair.
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Loc);
FileID FID = LocInfo.first;
}
}
- EmitCaretDiagnostic(Level, LastLoc, Ranges, NumRanges, LastLoc.getManager(),
+ EmitCaretDiagnostic(LastLoc, Ranges, NumRanges, LastLoc.getManager(),
Info.getFixItHints(),
Info.getNumFixItHints(),
DiagOpts->MessageLength,
void foo() {
M1(
M2);
- // CHECK: {{.*}}:6:{{[0-9]+}}: warning: expression result unused
- // CHECK: {{.*}}:7:{{[0-9]+}}: note: instantiated from:
- // CHECK: {{.*}}:4:{{[0-9]+}}: note: instantiated from:
+ // CHECK: :6:3: warning: expression result unused
+ // CHECK: :7:5: note: instantiated from:
}
+
#define A 1
#define B A
#define C B
void bar() {
C;
- // CHECK: {{.*}}:17:{{[0-9]+}}: warning: expression result unused
- // CHECK: {{.*}}:15:{{[0-9]+}}: note: instantiated from:
- // CHECK: {{.*}}:14:{{[0-9]+}}: note: instantiated from:
- // CHECK: {{.*}}:13:{{[0-9]+}}: note: instantiated from:
+ // CHECK: :17:3: warning: expression result unused
+ // CHECK: :15:11: note: instantiated from:
+ // CHECK: :14:11: note: instantiated from:
+ // CHECK: :13:11: note: instantiated from:
}
sprintf(Msg, " sizeof FoooLib : =%3u\n", 12LL);
}
+
+
+// PR9279 - Notes shouldn't print 'instantiated from' notes recursively.
+#define N1(x) int arr[x]
+#define N2(x) N1(x)
+#define N3(x) N2(x)
+N3(-1);
+
+// CHECK: :39:1: error: 'arr' declared as an array with a negative size
+// CHECK: :38:15: note: instantiated from:
+// CHECK: :37:15: note: instantiated from:
+// CHECK: :39:1: note: instantiated from: