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 | 76b8f13fcb7b97d2bd927be91fee6096fb373204 (patch) | |
tree | 6bb4175f0936e72456af4c77758cbf8f11f573bf /clang/tools/c-index-test | |
parent | e4e8181111004013f63ebcfd08d20e1b792837dd (diff) | |
download | bcm5719-llvm-76b8f13fcb7b97d2bd927be91fee6096fb373204.tar.gz bcm5719-llvm-76b8f13fcb7b97d2bd927be91fee6096fb373204.zip |
More work to enable more exhaustive testing of the indexing API.
Next step: Add actual some test cases:-)
llvm-svn: 82636
Diffstat (limited to 'clang/tools/c-index-test')
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index e7043c14820..b4038639929 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/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); } } |