Yet more CIndex API cleanup:
- Added more routines to manipulate/compare source locations and ranges
- Switched clang_getCursor() over to take a CXSourceLocation rather
than file/line/column.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94226 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 473773e..98ed772 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -161,7 +161,9 @@
clang_getInstantiationLocation(Loc, &file, 0, 0);
source = clang_getFileName(file);
if (source) {
- Ref = clang_getCursor(Data->TU, source, curLine, curColumn);
+ CXSourceLocation RefLoc
+ = clang_getLocation(Data->TU, file, curLine, curColumn);
+ Ref = clang_getCursor(Data->TU, RefLoc);
if (Ref.kind == CXCursor_NoDeclFound) {
/* Nothing found here; that's fine. */
} else if (Ref.kind != CXCursor_FunctionDecl) {
@@ -296,6 +298,7 @@
FILE *fp;
unsigned line;
CXCursor prevCursor;
+ CXFile file;
unsigned printed;
unsigned start_line, start_col, last_line, last_col;
size_t i;
@@ -320,6 +323,7 @@
start_line = last_line = 1;
start_col = last_col = 1;
+ file = clang_getFile(TU, source_file);
while (!feof(fp)) {
size_t len = 0;
int c;
@@ -334,7 +338,7 @@
for (i = 0; i < len ; ++i) {
CXCursor cursor;
- cursor = clang_getCursor(TU, source_file, line, i+1);
+ cursor = clang_getCursor(TU, clang_getLocation(TU, file, line, i+1));
if (!clang_equalCursors(cursor, prevCursor) &&
prevCursor.kind != CXCursor_InvalidFile) {
@@ -656,8 +660,13 @@
}
for (Loc = 0; Loc < NumLocations; ++Loc) {
- Cursor = clang_getCursor(TU, Locations[Loc].filename,
- Locations[Loc].line, Locations[Loc].column);
+ CXFile file = clang_getFile(TU, Locations[Loc].filename);
+ if (!file)
+ continue;
+
+ Cursor = clang_getCursor(TU,
+ clang_getLocation(TU, file, Locations[Loc].line,
+ Locations[Loc].column));
PrintCursor(Cursor);
printf("\n");
free(Locations[Loc].filename);