diff options
author | Steve Naroff <snaroff@apple.com> | 2009-09-23 17:52:52 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2009-09-23 17:52:52 +0000 |
commit | 4ade6d6eae934f796ca43c81a5aa185e456dde9b (patch) | |
tree | 57bd80cf23ece29a3c24cce9700604e3bcf67d3a /tools/c-index-test/c-index-test.c | |
parent | a4d4c019bf477ce6ff7b01517e690f6c5fd6ad71 (diff) |
More work to enable more exhaustive testing of the indexing API.
Next step: Add actual some test cases:-)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82636 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.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index e7043c1482..b403863992 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -32,6 +32,32 @@ static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor, clang_getCursorLine(Cursor), clang_getCursorColumn(Cursor)); + if (Cursor.kind == CXCursor_FunctionDefn) { + const char *startBuf, *endBuf; + unsigned startLine, startColumn, endLine, endColumn; + clang_getDefinitionSpellingAndExtent(Cursor, &startBuf, &endBuf, + &startLine, &startColumn, + &endLine, &endColumn); + /* Probe the entire body, looking for "refs". */ + unsigned curLine = startLine, curColumn = startColumn; + while (startBuf <= endBuf) { + if (*startBuf == '\n') { + startBuf++; + curLine++; + curColumn = 1; + } + CXCursor Ref = clang_getCursor(Unit, clang_getCursorSource(Cursor), + curLine, curColumn); + if (Ref.kind != CXCursor_FunctionDecl) { + PrintCursor(Ref); + printf("(Context: %s", clang_getDeclSpelling(Ref.decl)); + printf(" Source: %s (%d:%d))\n", clang_getCursorSource(Ref), + curLine, curColumn); + } + startBuf++; + curColumn++; + } + } clang_loadDeclaration(Cursor.decl, DeclVisitor, 0); } } |