aboutsummaryrefslogtreecommitdiff
path: root/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-09-01 15:55:40 +0000
committerSteve Naroff <snaroff@apple.com>2009-09-01 15:55:40 +0000
commit2b8ee6c2994f738e5162ff46b638974870f51662 (patch)
treee190491b93274ab2bdf97ba48caf1bc6413ead67 /tools/c-index-test/c-index-test.c
parentc4c65f2b696cf7a29e31f98fad6b00493f724217 (diff)
Add explicit "blind" client data to callback function (since we aren't using blocks).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80673 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.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index 1ef8e924bc..30700d8ae3 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -1,14 +1,18 @@
+/* c-index-test.c */
#include "clang-c/Index.h"
#include <stdio.h>
-static void PrintDecls(CXTranslationUnit Unit, CXCursor Cursor) {
+static void PrintDecls(CXTranslationUnit Unit, CXCursor Cursor,
+ CXClientData Filter) {
if (clang_isDeclaration(Cursor.kind)) {
- printf("%s => %s", clang_getKindSpelling(Cursor.kind),
- clang_getDeclSpelling(Cursor.decl));
- printf(" (%s,%d:%d)\n", clang_getCursorSource(Cursor),
- clang_getCursorLine(Cursor),
- clang_getCursorColumn(Cursor));
+ if (Cursor.kind == *(enum CXCursorKind *)Filter) {
+ printf("%s => %s", clang_getKindSpelling(Cursor.kind),
+ clang_getDeclSpelling(Cursor.decl));
+ printf(" (%s,%d:%d)\n", clang_getCursorSource(Cursor),
+ clang_getCursorLine(Cursor),
+ clang_getCursorColumn(Cursor));
+ }
}
}
@@ -18,6 +22,9 @@ static void PrintDecls(CXTranslationUnit Unit, CXCursor Cursor) {
int main(int argc, char **argv) {
CXIndex Idx = clang_createIndex();
CXTranslationUnit TU = clang_createTranslationUnit(Idx, argv[1]);
- clang_loadTranslationUnit(TU, PrintDecls);
+
+ /* Use client data to only print ObjC interfaces */
+ enum CXCursorKind filterData = CXCursor_ObjCInterfaceDecl;
+ clang_loadTranslationUnit(TU, PrintDecls, &filterData);
return 1;
}