Clean up the CIndex interface to diagnostic ranges. Thanks, Daniel!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95602 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index 658412c..423fa93 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -196,20 +196,20 @@
clang_getInstantiationLocation(clang_getDiagnosticLocation(Diagnostic),
&file, &line, &column, 0);
if (file) {
- CXSourceRange *ranges = 0;
- unsigned num_ranges;
- unsigned i;
+ unsigned i, n;
unsigned printed_any_ranges = 0;
fprintf(out, "%s:%d:%d:", clang_getFileName(file), line, column);
- clang_getDiagnosticRanges(Diagnostic, &ranges, &num_ranges);
- for (i = 0; i != num_ranges; ++i) {
+ n = clang_getDiagnosticNumRanges(Diagnostic);
+ for (i = 0; i != n; ++i) {
CXFile start_file, end_file;
+ CXSourceRange range = clang_getDiagnosticRange(Diagnostic, i);
+
unsigned start_line, start_column, end_line, end_column;
- clang_getInstantiationLocation(clang_getRangeStart(ranges[i]),
+ clang_getInstantiationLocation(clang_getRangeStart(range),
&start_file, &start_line, &start_column,0);
- clang_getInstantiationLocation(clang_getRangeEnd(ranges[i]),
+ clang_getInstantiationLocation(clang_getRangeEnd(range),
&end_file, &end_line, &end_column, 0);
if (start_file != end_file || start_file != file)
@@ -219,7 +219,6 @@
end_column+1);
printed_any_ranges = 1;
}
- clang_disposeDiagnosticRanges(ranges, num_ranges);
if (printed_any_ranges)
fprintf(out, ":");