diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-01-22 21:44:22 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-01-22 21:44:22 +0000 |
commit | 816fd363161f4468bd61596cdfa8c3c7b6f91812 (patch) | |
tree | 7f07fddc252500b6c17604ef21353974a49aa7d1 /clang/tools/c-index-test/c-index-test.c | |
parent | 00562558ab1563d3a492af2068c3e9c9ab76d33a (diff) | |
download | bcm5719-llvm-816fd363161f4468bd61596cdfa8c3c7b6f91812.tar.gz bcm5719-llvm-816fd363161f4468bd61596cdfa8c3c7b6f91812.zip |
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.
llvm-svn: 94226
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index 473773e0801..98ed772ec6e 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -161,7 +161,9 @@ static enum CXChildVisitResult FunctionScanVisitor(CXCursor Cursor, 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 @@ static int perform_file_scan(const char *ast_file, const char *source_file, 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 @@ static int perform_file_scan(const char *ast_file, const char *source_file, 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 @@ static int perform_file_scan(const char *ast_file, const char *source_file, 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 @@ int inspect_cursor_at(int argc, const char **argv) { } 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); |