aboutsummaryrefslogtreecommitdiff
path: root/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-01-19 00:34:46 +0000
committerDouglas Gregor <dgregor@apple.com>2010-01-19 00:34:46 +0000
commita7bde20f8c6334ccc3a7ef4dd77243d0921a8497 (patch)
tree6c7f598dd9a98de2c102ab35bcdefda7f245d6e6 /tools/c-index-test/c-index-test.c
parent17584204c2f527d4ed06ddb74afdd7622e70545d (diff)
Implement clang_getCursorExtent, which provides a source range for the
cursor itself. In particular, for references this returns the source range of the reference rather than the source range of the thing it refers to. Switch c-index-test from clang_getDeclExtent (which will eventually be deprecated and removed) over to clang_getCursorExtent. The source ranges we print for references now make sense; fix up the tests appropriately. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93823 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/c-index-test/c-index-test.c')
-rw-r--r--tools/c-index-test/c-index-test.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index a2d4fe9808..2f113cfada 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -73,11 +73,11 @@ static const char* GetCursorSource(CXCursor Cursor) {
static const char *FileCheckPrefix = "CHECK";
-static void PrintDeclExtent(CXDecl Dcl) {
- CXSourceRange extent;
- if (!Dcl)
+static void PrintCursorExtent(CXCursor C) {
+ CXSourceRange extent = clang_getCursorExtent(C);
+ /* FIXME: Better way to check for empty extents? */
+ if (!extent.begin.file)
return;
- extent = clang_getDeclExtent(Dcl);
printf(" [Extent=%d:%d:%d:%d]", extent.begin.line, extent.begin.column,
extent.end.line, extent.end.column);
}
@@ -89,8 +89,8 @@ static void DeclVisitor(CXDecl Dcl, CXCursor Cursor, CXClientData Filter) {
if (!source)
source = "<invalid loc>";
printf("// %s: %s:%d:%d: ", FileCheckPrefix, source, Loc.line, Loc.column);
- PrintCursor(Cursor);
- PrintDeclExtent(clang_getCursorDecl(Cursor));
+ PrintCursor(Cursor);
+ PrintCursorExtent(Cursor);
printf("\n");
}
@@ -111,7 +111,7 @@ static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor,
return;
}
- PrintDeclExtent(D);
+ PrintCursorExtent(Cursor);
printf("\n");
clang_loadDeclaration(D, DeclVisitor, 0);
}
@@ -173,7 +173,7 @@ static void USRDeclVisitor(CXDecl D, CXCursor C, CXClientData Filter) {
return;
}
printf("// %s: %s %s", FileCheckPrefix, GetCursorSource(C), USR.Spelling);
- PrintDeclExtent(clang_getCursorDecl(C));
+ PrintCursorExtent(C);
printf("\n");
clang_disposeString(USR);
}