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
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index a2d4fe9..2f113cf 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 *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 @@
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 @@
return;
}
- PrintDeclExtent(D);
+ PrintCursorExtent(Cursor);
printf("\n");
clang_loadDeclaration(D, DeclVisitor, 0);
}
@@ -173,7 +173,7 @@
return;
}
printf("// %s: %s %s", FileCheckPrefix, GetCursorSource(C), USR.Spelling);
- PrintDeclExtent(clang_getCursorDecl(C));
+ PrintCursorExtent(C);
printf("\n");
clang_disposeString(USR);
}