aboutsummaryrefslogtreecommitdiff
path: root/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-09-02 13:28:54 +0000
committerSteve Naroff <snaroff@apple.com>2009-09-02 13:28:54 +0000
commitc857ea4d22e1e6dd9ede1f0e84d48b157c6924fd (patch)
tree4b62f114667b1a4d1900e4d3b65f932dc3223485 /tools/c-index-test/c-index-test.c
parent6403b57eda05a22273d920ad0bd2991d11eaa7b8 (diff)
Flesh out CXCursorKind...
- More declaration types (distinguish between struct/union/class, instance/class methods). - Add definition types (class, category, function, instance/class method, etc.). Add client data to clang_loadDeclaration() and implement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80787 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.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index 30700d8ae3..d96468f8c4 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -3,16 +3,28 @@
#include "clang-c/Index.h"
#include <stdio.h>
-static void PrintDecls(CXTranslationUnit Unit, CXCursor Cursor,
- CXClientData Filter) {
- if (clang_isDeclaration(Cursor.kind)) {
- 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));
- }
+static void DeclVisitor(CXDecl Dcl, CXCursor Cursor, CXClientData Filter)
+{
+ if (!Filter || (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));
+ }
+}
+static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor,
+ CXClientData Filter)
+{
+ if (!Filter || (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));
+
+ enum CXCursorKind filterData = CXCursor_FieldDecl;
+ clang_loadDeclaration(Cursor.decl, DeclVisitor, 0);
}
}
@@ -23,8 +35,7 @@ int main(int argc, char **argv) {
CXIndex Idx = clang_createIndex();
CXTranslationUnit TU = clang_createTranslationUnit(Idx, argv[1]);
- /* Use client data to only print ObjC interfaces */
- enum CXCursorKind filterData = CXCursor_ObjCInterfaceDecl;
- clang_loadTranslationUnit(TU, PrintDecls, &filterData);
+ enum CXCursorKind filterData = CXCursor_StructDecl;
+ clang_loadTranslationUnit(TU, TranslationUnitVisitor, 0);
return 1;
}