[cfe-commits] r93618 - in /cfe/trunk: test/Index/TestClassDecl.m test/Index/TestClassForwardDecl.m test/Index/c-index-api-loadTU-test.m test/Index/c-index-getCursor-test.m test/Index/resolve-loc.c tools/CIndex/CIndex.cpp tools/CIndex/CXCursor.cpp tools/c-index-test/c-index-test.c

Ted Kremenek kremenek at apple.com
Fri Jan 15 17:44:12 PST 2010


Author: kremenek
Date: Fri Jan 15 19:44:12 2010
New Revision: 93618

URL: http://llvm.org/viewvc/llvm-project?rev=93618&view=rev
Log:
Remove TranslateKind and centralize Decl -> CXCursorKind in GetCursorKind().  This revealed a bunch of inconsistencies in how CXCursorKinds were being computed.

Modified:
    cfe/trunk/test/Index/TestClassDecl.m
    cfe/trunk/test/Index/TestClassForwardDecl.m
    cfe/trunk/test/Index/c-index-api-loadTU-test.m
    cfe/trunk/test/Index/c-index-getCursor-test.m
    cfe/trunk/test/Index/resolve-loc.c
    cfe/trunk/tools/CIndex/CIndex.cpp
    cfe/trunk/tools/CIndex/CXCursor.cpp
    cfe/trunk/tools/c-index-test/c-index-test.c

Modified: cfe/trunk/test/Index/TestClassDecl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/TestClassDecl.m?rev=93618&r1=93617&r2=93618&view=diff

==============================================================================
--- cfe/trunk/test/Index/TestClassDecl.m (original)
+++ cfe/trunk/test/Index/TestClassDecl.m Fri Jan 15 19:44:12 2010
@@ -21,18 +21,18 @@
 // CHECK-scan: {start_line=8 start_col=11 end_line=9 end_col=1} Invalid Cursor => NoDeclFound
 // CHECK-scan: {start_line=10 start_col=1 end_line=11 end_col=4} ObjCInterfaceDecl=Foo:10:1
 // CHECK-scan: {start_line=11 start_col=5 end_line=12 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK-scan: {start_line=13 start_col=1 end_line=13 end_col=4} FunctionDecl=function:13:6
+// CHECK-scan: {start_line=13 start_col=1 end_line=13 end_col=4} FunctionDefn=function:13:6
 // CHECK-scan: {start_line=13 start_col=5 end_line=13 end_col=5} Invalid Cursor => NoDeclFound
-// CHECK-scan: {start_line=13 start_col=6 end_line=13 end_col=14} FunctionDecl=function:13:6
+// CHECK-scan: {start_line=13 start_col=6 end_line=13 end_col=14} FunctionDefn=function:13:6
 // CHECK-scan: {start_line=13 start_col=15 end_line=13 end_col=17} ObjCClassRef=Foo:13:21
-// CHECK-scan: {start_line=13 start_col=18 end_line=13 end_col=18} FunctionDecl=function:13:6
+// CHECK-scan: {start_line=13 start_col=18 end_line=13 end_col=18} FunctionDefn=function:13:6
 // CHECK-scan: {start_line=13 start_col=19 end_line=13 end_col=19} ParmDecl=arg:13:21
-// CHECK-scan: {start_line=13 start_col=20 end_line=13 end_col=20} FunctionDecl=function:13:6
+// CHECK-scan: {start_line=13 start_col=20 end_line=13 end_col=20} FunctionDefn=function:13:6
 // CHECK-scan: {start_line=13 start_col=21 end_line=13 end_col=23} ParmDecl=arg:13:21
-// CHECK-scan: {start_line=13 start_col=24 end_line=16 end_col=1} FunctionDecl=function:13:6
+// CHECK-scan: {start_line=13 start_col=24 end_line=16 end_col=1} FunctionDefn=function:13:6
 // CHECK-scan: {start_line=16 start_col=2 end_line=38 end_col=1} Invalid Cursor => NoDeclFound
 
 // CHECK-load: TestClassDecl.m:10:12: ObjCInterfaceDecl=Foo:10:1 [Context=TestClassDecl.m] [Extent=10:1:11:4]
-// CHECK-load: TestClassDecl.m:13:6: FunctionDefn=function [Context=TestClassDecl.m] [Extent=13:6:16:1]
+// CHECK-load: TestClassDecl.m:13:6: FunctionDefn=function:13:6 [Context=TestClassDecl.m] [Extent=13:6:16:1]
 // CHECK-load: TestClassDecl.m:13:21: ParmDecl=arg:13:21 [Context=function] [Extent=13:21:13:23]
 

Modified: cfe/trunk/test/Index/TestClassForwardDecl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/TestClassForwardDecl.m?rev=93618&r1=93617&r2=93618&view=diff

==============================================================================
--- cfe/trunk/test/Index/TestClassForwardDecl.m (original)
+++ cfe/trunk/test/Index/TestClassForwardDecl.m Fri Jan 15 19:44:12 2010
@@ -16,15 +16,15 @@
 // CHECK-scan: {start_line=8 start_col=1 end_line=8 end_col=7} Invalid Cursor => NotImplemented
 // CHECK-scan: {start_line=8 start_col=8 end_line=8 end_col=10} ObjCClassRef=Foo:8:1
 // CHECK-scan: {start_line=8 start_col=11 end_line=9 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK-scan: {start_line=10 start_col=1 end_line=10 end_col=4} FunctionDecl=function:10:6
+// CHECK-scan: {start_line=10 start_col=1 end_line=10 end_col=4} FunctionDefn=function:10:6
 // CHECK-scan: {start_line=10 start_col=5 end_line=10 end_col=5} Invalid Cursor => NoDeclFound
-// CHECK-scan: {start_line=10 start_col=6 end_line=10 end_col=14} FunctionDecl=function:10:6
+// CHECK-scan: {start_line=10 start_col=6 end_line=10 end_col=14} FunctionDefn=function:10:6
 // CHECK-scan: {start_line=10 start_col=15 end_line=10 end_col=17} ObjCClassRef=Foo:10:21
-// CHECK-scan: {start_line=10 start_col=18 end_line=10 end_col=18} FunctionDecl=function:10:6
+// CHECK-scan: {start_line=10 start_col=18 end_line=10 end_col=18} FunctionDefn=function:10:6
 // CHECK-scan: {start_line=10 start_col=19 end_line=10 end_col=19} ParmDecl=arg:10:21
-// CHECK-scan: {start_line=10 start_col=20 end_line=10 end_col=20} FunctionDecl=function:10:6
+// CHECK-scan: {start_line=10 start_col=20 end_line=10 end_col=20} FunctionDefn=function:10:6
 // CHECK-scan: {start_line=10 start_col=21 end_line=10 end_col=23} ParmDecl=arg:10:21
-// CHECK-scan: {start_line=10 start_col=24 end_line=13 end_col=1} FunctionDecl=function:10:6
+// CHECK-scan: {start_line=10 start_col=24 end_line=13 end_col=1} FunctionDefn=function:10:6
 // CHECK-scan: {start_line=13 start_col=2 end_line=46 end_col=1} Invalid Cursor => NoDeclFound
 
 
@@ -41,6 +41,6 @@
 
 
 
-// CHECK-load: TestClassForwardDecl.m:10:6: FunctionDefn=function [Context=TestClassForwardDecl.m]
+// CHECK-load: TestClassForwardDecl.m:10:6: FunctionDefn=function:10:6 [Context=TestClassForwardDecl.m]
 // CHECK-load: TestClassForwardDecl.m:10:21: ParmDecl=arg:10:21 [Context=function]
 

Modified: cfe/trunk/test/Index/c-index-api-loadTU-test.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/c-index-api-loadTU-test.m?rev=93618&r1=93617&r2=93618&view=diff

==============================================================================
--- cfe/trunk/test/Index/c-index-api-loadTU-test.m (original)
+++ cfe/trunk/test/Index/c-index-api-loadTU-test.m Fri Jan 15 19:44:12 2010
@@ -74,7 +74,7 @@
 // CHECK: c-index-api-loadTU-test.m:37:1: ObjCInstanceMethodDecl=bazMethod:37:1 [Context=Baz] [Extent=37:1:37:20]
 // CHECK: c-index-api-loadTU-test.m:41:1: EnumDecl=:41:1 [Context=c-index-api-loadTU-test.m] [Extent=41:1:43:1]
 // CHECK: c-index-api-loadTU-test.m:42:3: EnumConstantDecl=someEnum:42:3 [Context=] [Extent=42:3:42:10]
-// CHECK: c-index-api-loadTU-test.m:45:5: FunctionDefn=main [Context=c-index-api-loadTU-test.m] [Extent=45:5:54:1]
+// CHECK: c-index-api-loadTU-test.m:45:5: FunctionDefn=main:45:5 [Context=c-index-api-loadTU-test.m] [Extent=45:5:54:1]
 // CHECK: c-index-api-loadTU-test.m:45:15: ParmDecl=argc:45:15 [Context=main] [Extent=45:15:45:18]
 // CHECK: c-index-api-loadTU-test.m:45:34: ParmDecl=argv:45:34 [Context=main] [Extent=45:34:45:37]
 // CHECK: c-index-api-loadTU-test.m:46:8: VarDecl=bee:46:8 [Context=main] [Extent=46:8:46:10]

Modified: cfe/trunk/test/Index/c-index-getCursor-test.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/c-index-getCursor-test.m?rev=93618&r1=93617&r2=93618&view=diff

==============================================================================
--- cfe/trunk/test/Index/c-index-getCursor-test.m (original)
+++ cfe/trunk/test/Index/c-index-getCursor-test.m Fri Jan 15 19:44:12 2010
@@ -80,9 +80,9 @@
 // CHECK: {start_line=28 start_col=12 end_line=29 end_col=4} ObjCProtocolDecl=SubP:27:1
 // CHECK: {start_line=29 start_col=5 end_line=30 end_col=1} Invalid Cursor => NoDeclFound
 // CHECK: {start_line=31 start_col=1 end_line=33 end_col=4} ObjCInterfaceDecl=Baz:31:1
-// CHECK: {start_line=33 start_col=5 end_line=33 end_col=7} Invalid Cursor => NotImplemented
+// CHECK: {start_line=33 start_col=5 end_line=33 end_col=7} ObjCIvarDecl=_anIVar:33:9
 // CHECK: {start_line=33 start_col=8 end_line=33 end_col=8} ObjCInterfaceDecl=Baz:31:1
-// CHECK: {start_line=33 start_col=9 end_line=33 end_col=15} Invalid Cursor => NotImplemented
+// CHECK: {start_line=33 start_col=9 end_line=33 end_col=15} ObjCIvarDecl=_anIVar:33:9
 // CHECK: {start_line=33 start_col=16 end_line=35 end_col=1} ObjCInterfaceDecl=Baz:31:1
 // CHECK: {start_line=36 start_col=1 end_line=36 end_col=20} ObjCInstanceMethodDecl=bazMethod:36:1
 // CHECK: {start_line=36 start_col=21 end_line=38 end_col=4} ObjCInterfaceDecl=Baz:31:1
@@ -91,57 +91,57 @@
 // CHECK: {start_line=41 start_col=3 end_line=41 end_col=10} EnumConstantDecl=someEnum:41:3
 // CHECK: {start_line=41 start_col=11 end_line=42 end_col=1} EnumDecl=:40:1
 // CHECK: {start_line=42 start_col=2 end_line=43 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK: {start_line=44 start_col=1 end_line=44 end_col=3} FunctionDecl=main:44:5
+// CHECK: {start_line=44 start_col=1 end_line=44 end_col=3} FunctionDefn=main:44:5
 // CHECK: {start_line=44 start_col=4 end_line=44 end_col=4} Invalid Cursor => NoDeclFound
-// CHECK: {start_line=44 start_col=5 end_line=44 end_col=10} FunctionDecl=main:44:5
+// CHECK: {start_line=44 start_col=5 end_line=44 end_col=10} FunctionDefn=main:44:5
 // CHECK: {start_line=44 start_col=11 end_line=44 end_col=13} ParmDecl=argc:44:15
-// CHECK: {start_line=44 start_col=14 end_line=44 end_col=14} FunctionDecl=main:44:5
+// CHECK: {start_line=44 start_col=14 end_line=44 end_col=14} FunctionDefn=main:44:5
 // CHECK: {start_line=44 start_col=15 end_line=44 end_col=18} ParmDecl=argc:44:15
-// CHECK: {start_line=44 start_col=19 end_line=44 end_col=26} FunctionDecl=main:44:5
+// CHECK: {start_line=44 start_col=19 end_line=44 end_col=26} FunctionDefn=main:44:5
 // CHECK: {start_line=44 start_col=27 end_line=44 end_col=30} ParmDecl=argv:44:34
-// CHECK: {start_line=44 start_col=31 end_line=44 end_col=31} FunctionDecl=main:44:5
+// CHECK: {start_line=44 start_col=31 end_line=44 end_col=31} FunctionDefn=main:44:5
 // CHECK: {start_line=44 start_col=32 end_line=44 end_col=32} ParmDecl=argv:44:34
-// CHECK: {start_line=44 start_col=33 end_line=44 end_col=33} FunctionDecl=main:44:5
+// CHECK: {start_line=44 start_col=33 end_line=44 end_col=33} FunctionDefn=main:44:5
 // CHECK: {start_line=44 start_col=34 end_line=44 end_col=39} ParmDecl=argv:44:34
-// CHECK: {start_line=44 start_col=40 end_line=45 end_col=1} FunctionDecl=main:44:5
+// CHECK: {start_line=44 start_col=40 end_line=45 end_col=1} FunctionDefn=main:44:5
 // CHECK: {start_line=45 start_col=2 end_line=45 end_col=4} ObjCClassRef=Baz:45:8
-// CHECK: {start_line=45 start_col=5 end_line=45 end_col=5} FunctionDecl=main:44:5
+// CHECK: {start_line=45 start_col=5 end_line=45 end_col=5} FunctionDefn=main:44:5
 // CHECK: {start_line=45 start_col=6 end_line=45 end_col=6} VarDecl=bee:45:8
-// CHECK: {start_line=45 start_col=7 end_line=45 end_col=7} FunctionDecl=main:44:5
+// CHECK: {start_line=45 start_col=7 end_line=45 end_col=7} FunctionDefn=main:44:5
 // CHECK: {start_line=45 start_col=8 end_line=45 end_col=10} VarDecl=bee:45:8
-// CHECK: {start_line=45 start_col=11 end_line=46 end_col=1} FunctionDecl=main:44:5
+// CHECK: {start_line=45 start_col=11 end_line=46 end_col=1} FunctionDefn=main:44:5
 // CHECK: {start_line=46 start_col=2 end_line=46 end_col=3} TypedefDecl=id:0:0
-// CHECK: {start_line=46 start_col=4 end_line=46 end_col=4} FunctionDecl=main:44:5
+// CHECK: {start_line=46 start_col=4 end_line=46 end_col=4} FunctionDefn=main:44:5
 // CHECK: {start_line=46 start_col=5 end_line=46 end_col=8} VarDecl=a:46:5
 // CHECK: {start_line=46 start_col=9 end_line=46 end_col=9} ObjCSelectorRef=foo:7:1
 // CHECK: {start_line=46 start_col=10 end_line=46 end_col=12} VarRef=bee:45:8
 // CHECK: {start_line=46 start_col=13 end_line=46 end_col=17} ObjCSelectorRef=foo:7:1
-// CHECK: {start_line=46 start_col=18 end_line=47 end_col=1} FunctionDecl=main:44:5
+// CHECK: {start_line=46 start_col=18 end_line=47 end_col=1} FunctionDefn=main:44:5
 // CHECK: {start_line=47 start_col=2 end_line=47 end_col=3} TypedefDecl=id:0:0
-// CHECK: {start_line=47 start_col=4 end_line=47 end_col=4} FunctionDecl=main:44:5
+// CHECK: {start_line=47 start_col=4 end_line=47 end_col=4} FunctionDefn=main:44:5
 // CHECK: {start_line=47 start_col=5 end_line=47 end_col=5} VarDecl=c:47:12
 // CHECK: {start_line=47 start_col=6 end_line=47 end_col=9} ObjCProtocolRef=SubP:47:12
 // CHECK: {start_line=47 start_col=10 end_line=47 end_col=10} VarDecl=c:47:12
-// CHECK: {start_line=47 start_col=11 end_line=47 end_col=11} FunctionDecl=main:44:5
+// CHECK: {start_line=47 start_col=11 end_line=47 end_col=11} FunctionDefn=main:44:5
 // CHECK: {start_line=47 start_col=12 end_line=47 end_col=15} VarDecl=c:47:12
 // CHECK: {start_line=47 start_col=16 end_line=47 end_col=25} ObjCSelectorRef=fooC:8:1
-// CHECK: {start_line=47 start_col=26 end_line=48 end_col=1} FunctionDecl=main:44:5
+// CHECK: {start_line=47 start_col=26 end_line=48 end_col=1} FunctionDefn=main:44:5
 // CHECK: {start_line=48 start_col=2 end_line=48 end_col=3} TypedefDecl=id:0:0
-// CHECK: {start_line=48 start_col=4 end_line=48 end_col=4} FunctionDecl=main:44:5
+// CHECK: {start_line=48 start_col=4 end_line=48 end_col=4} FunctionDefn=main:44:5
 // CHECK: {start_line=48 start_col=5 end_line=48 end_col=5} VarDecl=d:48:13
 // CHECK: {start_line=48 start_col=6 end_line=48 end_col=10} ObjCProtocolRef=Proto:48:13
 // CHECK: {start_line=48 start_col=11 end_line=48 end_col=11} VarDecl=d:48:13
-// CHECK: {start_line=48 start_col=12 end_line=48 end_col=12} FunctionDecl=main:44:5
+// CHECK: {start_line=48 start_col=12 end_line=48 end_col=12} FunctionDefn=main:44:5
 // CHECK: {start_line=48 start_col=13 end_line=48 end_col=13} VarDecl=d:48:13
-// CHECK: {start_line=48 start_col=14 end_line=49 end_col=1} FunctionDecl=main:44:5
+// CHECK: {start_line=48 start_col=14 end_line=49 end_col=1} FunctionDefn=main:44:5
 // CHECK: {start_line=49 start_col=2 end_line=49 end_col=2} VarRef=d:48:13
-// CHECK: {start_line=49 start_col=3 end_line=49 end_col=5} FunctionDecl=main:44:5
+// CHECK: {start_line=49 start_col=3 end_line=49 end_col=5} FunctionDefn=main:44:5
 // CHECK: {start_line=49 start_col=6 end_line=49 end_col=6} VarRef=c:47:12
-// CHECK: {start_line=49 start_col=7 end_line=50 end_col=1} FunctionDecl=main:44:5
+// CHECK: {start_line=49 start_col=7 end_line=50 end_col=1} FunctionDefn=main:44:5
 // CHECK: {start_line=50 start_col=2 end_line=50 end_col=2} ObjCSelectorRef=pMethod:24:1
 // CHECK: {start_line=50 start_col=3 end_line=50 end_col=3} VarRef=d:48:13
 // CHECK: {start_line=50 start_col=4 end_line=50 end_col=12} ObjCSelectorRef=pMethod:24:1
-// CHECK: {start_line=50 start_col=13 end_line=51 end_col=1} FunctionDecl=main:44:5
+// CHECK: {start_line=50 start_col=13 end_line=51 end_col=1} FunctionDefn=main:44:5
 // CHECK: {start_line=51 start_col=2 end_line=51 end_col=2} ObjCSelectorRef=catMethodWithFloat::19:1
 // CHECK: {start_line=51 start_col=3 end_line=51 end_col=5} VarRef=bee:45:8
 // CHECK: {start_line=51 start_col=6 end_line=51 end_col=25} ObjCSelectorRef=catMethodWithFloat::19:1
@@ -149,12 +149,12 @@
 // CHECK: {start_line=51 start_col=27 end_line=51 end_col=29} VarRef=bee:45:8
 // CHECK: {start_line=51 start_col=30 end_line=51 end_col=42} ObjCSelectorRef=floatMethod:20:1
 // CHECK: {start_line=51 start_col=43 end_line=51 end_col=43} ObjCSelectorRef=catMethodWithFloat::19:1
-// CHECK: {start_line=51 start_col=44 end_line=52 end_col=2} FunctionDecl=main:44:5
+// CHECK: {start_line=51 start_col=44 end_line=52 end_col=2} FunctionDefn=main:44:5
 // CHECK: {start_line=52 start_col=3 end_line=52 end_col=6} FunctionRef=main:44:5
-// CHECK: {start_line=52 start_col=7 end_line=52 end_col=7} FunctionDecl=main:44:5
+// CHECK: {start_line=52 start_col=7 end_line=52 end_col=7} FunctionDefn=main:44:5
 // CHECK: {start_line=52 start_col=8 end_line=52 end_col=15} EnumConstantRef=someEnum:41:3
-// CHECK: {start_line=52 start_col=16 end_line=52 end_col=32} FunctionDecl=main:44:5
+// CHECK: {start_line=52 start_col=16 end_line=52 end_col=32} FunctionDefn=main:44:5
 // CHECK: {start_line=52 start_col=33 end_line=52 end_col=35} VarRef=bee:45:8
-// CHECK: {start_line=52 start_col=36 end_line=53 end_col=1} FunctionDecl=main:44:5
+// CHECK: {start_line=52 start_col=36 end_line=53 end_col=1} FunctionDefn=main:44:5
 // CHECK: {start_line=53 start_col=2 end_line=160 end_col=1} Invalid Cursor => NoDeclFound
 

Modified: cfe/trunk/test/Index/resolve-loc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/resolve-loc.c?rev=93618&r1=93617&r2=93618&view=diff

==============================================================================
--- cfe/trunk/test/Index/resolve-loc.c (original)
+++ cfe/trunk/test/Index/resolve-loc.c Fri Jan 15 19:44:12 2010
@@ -24,7 +24,7 @@
 // CHECK: VarDecl=top_var
 // CHECK: FunctionDecl=top_func_decl
 // CHECK: ParmDecl=param1
-// CHECK: FunctionDecl=top_func_def
+// CHECK: FunctionDefn=top_func_def
 // CHECK: ParmDecl=param2
 // CHECK: VarDecl=local_var1
 // CHECK: VarDecl=for_var

Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=93618&r1=93617&r2=93618&view=diff

==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Fri Jan 15 19:44:12 2010
@@ -146,6 +146,9 @@
   unsigned MaxPCHLevel;
 
   void Call(const CXCursor &C) {
+    if (clang_isInvalid(C.kind))
+      return;
+    
     if (const Decl *D = getCursorDecl(C)) {
       // Filter any declarations that have a PCH level greater than what 
       // we allow.
@@ -165,9 +168,6 @@
     Root(root), Callback(cback), CData(D), MaxPCHLevel(MaxPCHLevel) {}
 
   void VisitDecl(Decl *D);
-  void VisitObjCClassDecl(ObjCClassDecl *D) {
-    // FIXME: Do something.
-  }
   void VisitDeclContext(DeclContext *DC);
   void VisitTranslationUnitDecl(TranslationUnitDecl *D);
 };
@@ -736,30 +736,6 @@
 // CXCursor Operations.
 //===----------------------------------------------------------------------===//
 
-static enum CXCursorKind TranslateKind(Decl *D) {
-  switch (D->getKind()) {
-    case Decl::Function: return CXCursor_FunctionDecl;
-    case Decl::Typedef: return CXCursor_TypedefDecl;
-    case Decl::Enum: return CXCursor_EnumDecl;
-    case Decl::EnumConstant: return CXCursor_EnumConstantDecl;
-    case Decl::Record: return CXCursor_StructDecl; // FIXME: union/class
-    case Decl::Field: return CXCursor_FieldDecl;
-    case Decl::Var: return CXCursor_VarDecl;
-    case Decl::ParmVar: return CXCursor_ParmDecl;
-    case Decl::ObjCInterface: return CXCursor_ObjCInterfaceDecl;
-    case Decl::ObjCCategory: return CXCursor_ObjCCategoryDecl;
-    case Decl::ObjCProtocol: return CXCursor_ObjCProtocolDecl;
-    case Decl::ObjCMethod: {
-      ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D);
-      if (MD->isInstanceMethod())
-        return CXCursor_ObjCInstanceMethodDecl;
-      return CXCursor_ObjCClassMethodDecl;
-    }
-    default: break;
-  }
-  return CXCursor_NotImplemented;
-}
-
 static Decl *getDeclFromExpr(Stmt *E) {
   if (DeclRefExpr *RefExpr = dyn_cast<DeclRefExpr>(E))
     return RefExpr->getDecl();
@@ -910,7 +886,7 @@
         return C;
       }
     }
-    return MakeCXCursor(TranslateKind(Dcl), Dcl);
+    return MakeCXCursor(Dcl);
   }
   return MakeCXCursor(CXCursor_NoDeclFound, 0);
 }
@@ -926,7 +902,7 @@
 CXCursor clang_getCursorFromDecl(CXDecl AnonDecl) {
   assert(AnonDecl && "Passed null CXDecl");
   NamedDecl *ND = static_cast<NamedDecl *>(AnonDecl);
-  return MakeCXCursor(TranslateKind(ND), ND);
+  return MakeCXCursor(ND);
 }
 
 unsigned clang_isInvalid(enum CXCursorKind K) {
@@ -950,7 +926,7 @@
 }
 
 CXDecl clang_getCursorDecl(CXCursor C) {
-  if (clang_isDeclaration(C.kind))
+  if (clang_isDeclaration(C.kind) || clang_isDefinition(C.kind))
     return getCursorDecl(C);
 
   if (clang_isReference(C.kind)) {

Modified: cfe/trunk/tools/CIndex/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CXCursor.cpp?rev=93618&r1=93617&r2=93618&view=diff

==============================================================================
--- cfe/trunk/tools/CIndex/CXCursor.cpp (original)
+++ cfe/trunk/tools/CIndex/CXCursor.cpp Fri Jan 15 19:44:12 2010
@@ -32,14 +32,25 @@
 
 static CXCursorKind GetCursorKind(Decl *D) {
   switch (D->getKind()) {
+    case Decl::Enum:               return CXCursor_EnumDecl;
+    case Decl::EnumConstant:       return CXCursor_EnumConstantDecl;
+    case Decl::Field:              return CXCursor_FieldDecl;
     case Decl::Function:  
       return cast<FunctionDecl>(D)->isThisDeclarationADefinition()
               ? CXCursor_FunctionDefn : CXCursor_FunctionDecl;
     case Decl::ObjCCategory:       return CXCursor_ObjCCategoryDecl;
     case Decl::ObjCCategoryImpl:   return CXCursor_ObjCCategoryDefn;
+    case Decl::ObjCClass:
+      // FIXME
+      return CXCursor_NotImplemented;
     case Decl::ObjCImplementation: return CXCursor_ObjCClassDefn;
     case Decl::ObjCInterface:      return CXCursor_ObjCInterfaceDecl;
+    case Decl::ObjCIvar:           return CXCursor_ObjCIvarDecl; 
+    case Decl::ObjCMethod:
+      return cast<ObjCMethodDecl>(D)->isInstanceMethod()
+              ? CXCursor_ObjCInstanceMethodDecl : CXCursor_ObjCClassMethodDecl;
     case Decl::ObjCProtocol:       return CXCursor_ObjCProtocolDecl;
+    case Decl::ParmVar:            return CXCursor_ParmDecl;
     case Decl::Typedef:            return CXCursor_TypedefDecl;
     case Decl::Var:                return CXCursor_VarDecl;
     default:

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=93618&r1=93617&r2=93618&view=diff

==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Fri Jan 15 19:44:12 2010
@@ -74,7 +74,10 @@
 static const char *FileCheckPrefix = "CHECK";
 
 static void PrintDeclExtent(CXDecl Dcl) {
-  CXSourceExtent extent = clang_getDeclExtent(Dcl);
+  CXSourceExtent extent; 
+  if (!Dcl)
+    return;
+  extent = clang_getDeclExtent(Dcl);
   printf(" [Extent=%d:%d:%d:%d]", extent.begin.line, extent.begin.column,
          extent.end.line, extent.end.column);
 }
@@ -101,6 +104,7 @@
 static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor,
                                    CXClientData Filter) {
   if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) {
+    CXDecl D;
     CXString string;
     printf("// %s: %s:%d:%d: ", FileCheckPrefix,
            GetCursorSource(Cursor), clang_getCursorLine(Cursor),
@@ -111,11 +115,15 @@
           basename(clang_getCString(string)));
     clang_disposeString(string);
     
-    PrintDeclExtent(Cursor.data[0]);
-
-    printf("\n");
+    D = clang_getCursorDecl(Cursor);
+    if (!D) {
+      printf("\n");
+      return;
+    }
     
-    clang_loadDeclaration(Cursor.data[0], DeclVisitor, 0);
+    PrintDeclExtent(D);
+    printf("\n");    
+    clang_loadDeclaration(D, DeclVisitor, 0);
   }
 }
 
@@ -179,10 +187,11 @@
 }
 
 static void USRVisitor(CXTranslationUnit Unit, CXCursor Cursor,
-                       CXClientData Filter) {  
-  if (Cursor.data[0]) {
+                       CXClientData Filter) {
+  CXDecl D = clang_getCursorDecl(Cursor);
+  if (D) {
     /* USRDeclVisitor(Unit, Cursor.decl, Cursor, Filter);*/
-    clang_loadDeclaration(Cursor.data[0], USRDeclVisitor, 0);
+    clang_loadDeclaration(D, USRDeclVisitor, 0);
   }
 }
 





More information about the cfe-commits mailing list