summaryrefslogtreecommitdiffstats
path: root/clang/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
commit33c34ac19afe3bc0de3ea64d589d5307af733f03 (patch)
tree4a0f7286034824a85f034df0ad3cdd4012492e62 /clang/tools/c-index-test/c-index-test.c
parent757daca99c9b005f1a54e6268cac877204ae968b (diff)
downloadbcm5719-llvm-33c34ac19afe3bc0de3ea64d589d5307af733f03.tar.gz
bcm5719-llvm-33c34ac19afe3bc0de3ea64d589d5307af733f03.zip
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. llvm-svn: 93823
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r--clang/tools/c-index-test/c-index-test.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index a2d4fe98081..2f113cfadaa 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/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);
}
OpenPOWER on IntegriCloud