From 33c34ac19afe3bc0de3ea64d589d5307af733f03 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 19 Jan 2010 00:34:46 +0000 Subject: 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 --- clang/tools/c-index-test/c-index-test.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'clang/tools/c-index-test/c-index-test.c') 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 = ""; 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); } -- cgit v1.2.3