aboutsummaryrefslogtreecommitdiff
path: root/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-09-04 15:44:05 +0000
committerSteve Naroff <snaroff@apple.com>2009-09-04 15:44:05 +0000
commit9efa767be8e9f2dae509d3a0be93ade01bfa1560 (patch)
tree8d4b7b97cae9b872b3060e6ea4b1521547f4b449 /tools/c-index-test/c-index-test.c
parentd93bacf13bda3055a51a1160bca5e8d851d67eb7 (diff)
Implement accessors clang_getCursorKind(), clang_getCursorDecl().
Implement clang_getCursor() - wired up to Argiris's work. Implement callbacks for CXCursor_ObjCProtocolRef. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81004 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.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index dbf31bea5a..6db4898b08 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -39,12 +39,21 @@ static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor,
int main(int argc, char **argv) {
CXIndex Idx = clang_createIndex();
CXTranslationUnit TU = clang_createTranslationUnit(Idx, argv[1]);
-
- if (argc == 2)
- clang_loadTranslationUnit(TU, TranslationUnitVisitor, 0);
- else if (argc == 3) {
+
+ if (argc == 2) {
+ /* malloc - returns a cursor of type CXCursor_FunctionDecl */
+ CXCursor C = clang_getCursor(TU, "/usr/include/stdlib.h", 169, 7);
+ PrintCursor(C);
+ /* methodSignature - returns a cursor of type ObjCInstanceMethodDecl */
+ C = clang_getCursor(TU, "/System/Library/Frameworks/Foundation.framework/Headers/NSInvocation.h", 22, 1);
+ PrintCursor(C);
+ } else if (argc == 3) {
enum CXCursorKind K = CXCursor_Invalid;
+ if (!strcmp(argv[2], "all")) {
+ clang_loadTranslationUnit(TU, TranslationUnitVisitor, 0);
+ return 1;
+ }
if (!strcmp(argv[2], "category")) K = CXCursor_ObjCCategoryDecl;
else if (!strcmp(argv[2], "interface")) K = CXCursor_ObjCInterfaceDecl;
else if (!strcmp(argv[2], "protocol")) K = CXCursor_ObjCProtocolDecl;