Skip to content

Commit 237d6c2

Browse files
DougGregoretcwilde
authored andcommitted
[c-index-test] Always retrieve source-file contents from the top-level diag set
(cherry picked from commit f35f599)
1 parent 32db4c2 commit 237d6c2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

clang/tools/c-index-test/c-index-test.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4746,7 +4746,8 @@ static void printFixIts(CXDiagnostic D, unsigned indent) {
47464746
}
47474747
}
47484748

4749-
static void printDiagnosticSet(CXDiagnosticSet Diags, unsigned indent) {
4749+
static void printDiagnosticSet(
4750+
CXDiagnosticSet Diags, unsigned indent, CXDiagnosticSet TopDiags) {
47504751
unsigned i, n;
47514752

47524753
if (!Diags)
@@ -4796,15 +4797,15 @@ static void printDiagnosticSet(CXDiagnosticSet Diags, unsigned indent) {
47964797
printFixIts(D, indent);
47974798

47984799
// If we have the source file contents for this file, print them now.
4799-
FileContents = clang_getDiagnosticFileContents(Diags, File, 0);
4800+
FileContents = clang_getDiagnosticFileContents(TopDiags, File, 0);
48004801
if (FileContents) {
48014802
CXSourceRange OriginalSourceRange;
48024803

48034804
fprintf(stderr, "CONTENTS OF FILE %s:\n",
48044805
FileNameStr ? FileNameStr : "(null)");
48054806

48064807
OriginalSourceRange = clang_getDiagnosticFileOriginalSourceRange(
4807-
Diags, File);
4808+
TopDiags, File);
48084809
if (!clang_equalRanges(clang_getNullRange(), OriginalSourceRange)) {
48094810
printIndent(indent);
48104811
fprintf(stderr, "Original source range: ");
@@ -4818,7 +4819,7 @@ static void printDiagnosticSet(CXDiagnosticSet Diags, unsigned indent) {
48184819
}
48194820

48204821
/* Print subdiagnostics. */
4821-
printDiagnosticSet(clang_getChildDiagnostics(D), indent+2);
4822+
printDiagnosticSet(clang_getChildDiagnostics(D), indent+2, TopDiags);
48224823

48234824
clang_disposeString(FileName);
48244825
clang_disposeString(DiagSpelling);
@@ -4841,7 +4842,7 @@ static int read_diagnostics(const char *filename) {
48414842
return 1;
48424843
}
48434844

4844-
printDiagnosticSet(Diags, 0);
4845+
printDiagnosticSet(Diags, 0, Diags);
48454846
fprintf(stderr, "Number of diagnostics: %d\n",
48464847
clang_getNumDiagnosticsInSet(Diags));
48474848
clang_disposeDiagnosticSet(Diags);

0 commit comments

Comments
 (0)