aboutsummaryrefslogtreecommitdiff
path: root/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-09-03 00:32:06 +0000
committerSteve Naroff <snaroff@apple.com>2009-09-03 00:32:06 +0000
commit23d8bea7056e7f474ce7f42042021a148feee8f7 (patch)
treea1f4809005ebc0f65ac04a3b49bd6d58a7f07beb /tools/c-index-test/c-index-test.c
parent2700dcde044893642b9b77638e052aa90be7cd51 (diff)
Visit function/method bodies and issue callback for parameters and local variables.
Add clang_getTranslationUnitSpelling(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80859 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.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index 2d2be158d0..8df2fc261d 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -3,25 +3,27 @@
#include "clang-c/Index.h"
#include <stdio.h>
+static void PrintCursor(CXCursor Cursor) {
+ printf("%s => %s", clang_getCursorKindSpelling(Cursor.kind),
+ clang_getCursorSpelling(Cursor));
+ printf(" (%s,%d:%d)\n", clang_getCursorSource(Cursor),
+ clang_getCursorLine(Cursor),
+ clang_getCursorColumn(Cursor));
+}
+
static void DeclVisitor(CXDecl Dcl, CXCursor Cursor, CXClientData Filter)
{
- if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) {
- printf("%s => %s", clang_getCursorKindSpelling(Cursor.kind),
- clang_getCursorSpelling(Cursor));
- printf(" (%s,%d:%d)\n", clang_getCursorSource(Cursor),
- clang_getCursorLine(Cursor),
- clang_getCursorColumn(Cursor));
- }
+ printf("%s: ", clang_getDeclSpelling(Dcl));
+ if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter))
+ PrintCursor(Cursor);
}
+
static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor,
CXClientData Filter)
{
+ printf("%s: ", clang_getTranslationUnitSpelling(Unit));
if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) {
- printf("%s => %s", clang_getCursorKindSpelling(Cursor.kind),
- clang_getCursorSpelling(Cursor));
- printf(" (%s,%d:%d)\n", clang_getCursorSource(Cursor),
- clang_getCursorLine(Cursor),
- clang_getCursorColumn(Cursor));
+ PrintCursor(Cursor);
clang_loadDeclaration(Cursor.decl, DeclVisitor, 0);
}