Skip to content

Commit f35f599

Browse files
committed
[c-index-test] Always retrieve source-file contents from the top-level diag set
1 parent 0cf7518 commit f35f599

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
@@ -4716,7 +4716,8 @@ static void printFixIts(CXDiagnostic D, unsigned indent) {
47164716
}
47174717
}
47184718

4719-
static void printDiagnosticSet(CXDiagnosticSet Diags, unsigned indent) {
4719+
static void printDiagnosticSet(
4720+
CXDiagnosticSet Diags, unsigned indent, CXDiagnosticSet TopDiags) {
47204721
unsigned i, n;
47214722

47224723
if (!Diags)
@@ -4766,15 +4767,15 @@ static void printDiagnosticSet(CXDiagnosticSet Diags, unsigned indent) {
47664767
printFixIts(D, indent);
47674768

47684769
// If we have the source file contents for this file, print them now.
4769-
FileContents = clang_getDiagnosticFileContents(Diags, File, 0);
4770+
FileContents = clang_getDiagnosticFileContents(TopDiags, File, 0);
47704771
if (FileContents) {
47714772
CXSourceRange OriginalSourceRange;
47724773

47734774
fprintf(stderr, "CONTENTS OF FILE %s:\n",
47744775
FileNameStr ? FileNameStr : "(null)");
47754776

47764777
OriginalSourceRange = clang_getDiagnosticFileOriginalSourceRange(
4777-
Diags, File);
4778+
TopDiags, File);
47784779
if (!clang_equalRanges(clang_getNullRange(), OriginalSourceRange)) {
47794780
printIndent(indent);
47804781
fprintf(stderr, "Original source range: ");
@@ -4788,7 +4789,7 @@ static void printDiagnosticSet(CXDiagnosticSet Diags, unsigned indent) {
47884789
}
47894790

47904791
/* Print subdiagnostics. */
4791-
printDiagnosticSet(clang_getChildDiagnostics(D), indent+2);
4792+
printDiagnosticSet(clang_getChildDiagnostics(D), indent+2, TopDiags);
47924793

47934794
clang_disposeString(FileName);
47944795
clang_disposeString(DiagSpelling);
@@ -4811,7 +4812,7 @@ static int read_diagnostics(const char *filename) {
48114812
return 1;
48124813
}
48134814

4814-
printDiagnosticSet(Diags, 0);
4815+
printDiagnosticSet(Diags, 0, Diags);
48154816
fprintf(stderr, "Number of diagnostics: %d\n",
48164817
clang_getNumDiagnosticsInSet(Diags));
48174818
clang_disposeDiagnosticSet(Diags);

0 commit comments

Comments
 (0)