[cfe-commits] r94426 - 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/load-stmts.cpp tools/CIndex/CIndex.cpp

Douglas Gregor dgregor at apple.com
Mon Jan 25 08:56:17 PST 2010


Author: dgregor
Date: Mon Jan 25 10:56:17 2010
New Revision: 94426

URL: http://llvm.org/viewvc/llvm-project?rev=94426&view=rev
Log:
Loosen preconditions for clang_getCursorSpelling(), returning an empty
string when given a cursor that does not have a name. Also, don't give
silly names for statements and non-reference expressions.


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/load-stmts.cpp
    cfe/trunk/tools/CIndex/CIndex.cpp

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

==============================================================================
--- cfe/trunk/test/Index/TestClassDecl.m (original)
+++ cfe/trunk/test/Index/TestClassDecl.m Mon Jan 25 10:56:17 2010
@@ -25,7 +25,7 @@
 // CHECK-scan: {start_line=13 start_col=15 end_line=13 end_col=17} ObjCClassRef=Foo:10:12
 // CHECK-scan: {start_line=13 start_col=18 end_line=13 end_col=23} ParmDecl=arg:13:21 (Definition)
 // CHECK-scan: {start_line=13 start_col=24 end_line=13 end_col=25} FunctionDecl=function:13:6 (Definition)
-// CHECK-scan: {start_line=14 start_col=1 end_line=16 end_col=1} UnexposedStmt=function
+// CHECK-scan: {start_line=14 start_col=1 end_line=16 end_col=1} UnexposedStmt=
 
 // CHECK-load: TestClassDecl.m:10:12: ObjCInterfaceDecl=Foo:10:12 [Extent=10:1:11:4]
 // CHECK-load: TestClassDecl.m:13:6: FunctionDecl=function:13:6 (Definition) [Extent=13:6:16:1]

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

==============================================================================
--- cfe/trunk/test/Index/TestClassForwardDecl.m (original)
+++ cfe/trunk/test/Index/TestClassForwardDecl.m Mon Jan 25 10:56:17 2010
@@ -20,7 +20,7 @@
 // CHECK-scan: {start_line=10 start_col=15 end_line=10 end_col=17} ObjCClassRef=Foo:8:8
 // CHECK-scan: {start_line=10 start_col=18 end_line=10 end_col=23} ParmDecl=arg:10:21 (Definition)
 // CHECK-scan: {start_line=10 start_col=24 end_line=10 end_col=25} FunctionDecl=function:10:6 (Definition)
-// CHECK-scan: {start_line=11 start_col=1 end_line=13 end_col=1} UnexposedStmt=function
+// CHECK-scan: {start_line=11 start_col=1 end_line=13 end_col=1} UnexposedStmt=
 
 
 

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=94426&r1=94425&r2=94426&view=diff

==============================================================================
--- cfe/trunk/test/Index/c-index-api-loadTU-test.m (original)
+++ cfe/trunk/test/Index/c-index-api-loadTU-test.m Mon Jan 25 10:56:17 2010
@@ -94,22 +94,22 @@
 // CHECK: c-index-api-loadTU-test.m:45:5: FunctionDecl=main:45:5 (Definition) [Extent=45:5:54:1]
 // CHECK: c-index-api-loadTU-test.m:45:15: ParmDecl=argc:45:15 (Definition) [Extent=45:11:45:18]
 // CHECK: c-index-api-loadTU-test.m:45:34: ParmDecl=argv:45:34 (Definition) [Extent=45:27:45:37]
-// CHECK: c-index-api-loadTU-test.m:45:5: UnexposedStmt=main [Extent=45:42:54:1]
-// CHECK: c-index-api-loadTU-test.m:45:5: UnexposedStmt=main [Extent=46:2:46:11]
+// CHECK: c-index-api-loadTU-test.m:45:5: UnexposedStmt= [Extent=45:42:54:1]
+// CHECK: c-index-api-loadTU-test.m:45:5: UnexposedStmt= [Extent=46:2:46:11]
 // CHECK: c-index-api-loadTU-test.m:46:8: VarDecl=bee:46:8 (Definition) [Extent=46:2:46:10]
 // CHECK: c-index-api-loadTU-test.m:46:2: ObjCClassRef=Baz:32:12 [Extent=46:2:46:4]
-// CHECK: c-index-api-loadTU-test.m:46:8: UnexposedStmt=bee [Extent=47:2:47:18]
+// CHECK: c-index-api-loadTU-test.m:46:8: UnexposedStmt= [Extent=47:2:47:18]
 // CHECK: c-index-api-loadTU-test.m:47:5: VarDecl=a:47:5 (Definition) [Extent=47:2:47:17]
 // CHECK: c-index-api-loadTU-test.m:47:2: TypeRef=id:0:0 [Extent=47:2:47:3]
 // CHECK: c-index-api-loadTU-test.m:47:9: ObjCMessageExpr=foo:8:1 [Extent=47:9:47:17]
 // CHECK: c-index-api-loadTU-test.m:47:10: DeclRefExpr=bee:46:8 [Extent=47:10:47:12]
-// CHECK: c-index-api-loadTU-test.m:47:5: UnexposedStmt=a [Extent=48:2:48:26]
+// CHECK: c-index-api-loadTU-test.m:47:5: UnexposedStmt= [Extent=48:2:48:26]
 // CHECK: c-index-api-loadTU-test.m:48:12: VarDecl=c:48:12 (Definition) [Extent=48:2:48:25]
 // CHECK: c-index-api-loadTU-test.m:48:2: TypeRef=id:0:0 [Extent=48:2:48:3]
 // CHECK: c-index-api-loadTU-test.m:48:6: ObjCProtocolRef=SubP:28:1 [Extent=48:6:48:9]
 // CHECK: c-index-api-loadTU-test.m:48:16: UnexposedExpr=fooC:9:1 [Extent=48:16:48:25]
 // CHECK: c-index-api-loadTU-test.m:48:16: ObjCMessageExpr=fooC:9:1 [Extent=48:16:48:25]
-// CHECK: c-index-api-loadTU-test.m:48:12: UnexposedStmt=c [Extent=49:2:49:14]
+// CHECK: c-index-api-loadTU-test.m:48:12: UnexposedStmt= [Extent=49:2:49:14]
 // CHECK: c-index-api-loadTU-test.m:49:13: VarDecl=d:49:13 (Definition) [Extent=49:2:49:13]
 // CHECK: c-index-api-loadTU-test.m:49:2: TypeRef=id:0:0 [Extent=49:2:49:3]
 // CHECK: c-index-api-loadTU-test.m:49:6: ObjCProtocolRef=Proto:24:1 [Extent=49:6:49: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=94426&r1=94425&r2=94426&view=diff

==============================================================================
--- cfe/trunk/test/Index/c-index-getCursor-test.m (original)
+++ cfe/trunk/test/Index/c-index-getCursor-test.m Mon Jan 25 10:56:17 2010
@@ -102,39 +102,39 @@
 // CHECK: {start_line=44 start_col=19 end_line=44 end_col=26} FunctionDecl=main:44:5 (Definition)
 // CHECK: {start_line=44 start_col=27 end_line=44 end_col=37} ParmDecl=argv:44:34 (Definition)
 // CHECK: {start_line=44 start_col=38 end_line=44 end_col=41} FunctionDecl=main:44:5 (Definition)
-// CHECK: {start_line=44 start_col=42 end_line=45 end_col=1} UnexposedStmt=main
+// CHECK: {start_line=44 start_col=42 end_line=45 end_col=1} UnexposedStmt=
 // CHECK: {start_line=45 start_col=2 end_line=45 end_col=4} ObjCClassRef=Baz:31:12
 // CHECK: {start_line=45 start_col=5 end_line=45 end_col=10} VarDecl=bee:45:8 (Definition)
-// CHECK: {start_line=45 start_col=11 end_line=45 end_col=11} UnexposedStmt=main
-// CHECK: {start_line=45 start_col=12 end_line=46 end_col=1} UnexposedStmt=main
+// CHECK: {start_line=45 start_col=11 end_line=45 end_col=11} UnexposedStmt=
+// CHECK: {start_line=45 start_col=12 end_line=46 end_col=1} UnexposedStmt=
 // CHECK: {start_line=46 start_col=2 end_line=46 end_col=3} TypeRef=id:0:0
 // CHECK: {start_line=46 start_col=4 end_line=46 end_col=8} VarDecl=a:46:5 (Definition)
 // CHECK: {start_line=46 start_col=9 end_line=46 end_col=9} ObjCMessageExpr=foo:7:1
 // CHECK: {start_line=46 start_col=10 end_line=46 end_col=12} DeclRefExpr=bee:45:8
 // CHECK: {start_line=46 start_col=13 end_line=46 end_col=17} ObjCMessageExpr=foo:7:1
-// CHECK: {start_line=46 start_col=18 end_line=46 end_col=18} UnexposedStmt=main
-// CHECK: {start_line=46 start_col=19 end_line=47 end_col=1} UnexposedStmt=main
+// CHECK: {start_line=46 start_col=18 end_line=46 end_col=18} UnexposedStmt=
+// CHECK: {start_line=46 start_col=19 end_line=47 end_col=1} UnexposedStmt=
 // CHECK: {start_line=47 start_col=2 end_line=47 end_col=3} TypeRef=id:0:0
 // CHECK: {start_line=47 start_col=4 end_line=47 end_col=5} VarDecl=c:47:12 (Definition)
 // CHECK: {start_line=47 start_col=6 end_line=47 end_col=9} ObjCProtocolRef=SubP:27:1
 // CHECK: {start_line=47 start_col=10 end_line=47 end_col=15} VarDecl=c:47:12 (Definition)
 // CHECK: {start_line=47 start_col=16 end_line=47 end_col=25} ObjCMessageExpr=fooC:8:1
-// CHECK: {start_line=47 start_col=26 end_line=47 end_col=26} UnexposedStmt=main
-// CHECK: {start_line=47 start_col=27 end_line=48 end_col=1} UnexposedStmt=main
+// CHECK: {start_line=47 start_col=26 end_line=47 end_col=26} UnexposedStmt=
+// CHECK: {start_line=47 start_col=27 end_line=48 end_col=1} UnexposedStmt=
 // CHECK: {start_line=48 start_col=2 end_line=48 end_col=3} TypeRef=id:0:0
 // CHECK: {start_line=48 start_col=4 end_line=48 end_col=5} VarDecl=d:48:13 (Definition)
 // CHECK: {start_line=48 start_col=6 end_line=48 end_col=10} ObjCProtocolRef=Proto:23:1
 // CHECK: {start_line=48 start_col=11 end_line=48 end_col=13} VarDecl=d:48:13 (Definition)
-// CHECK: {start_line=48 start_col=14 end_line=48 end_col=14} UnexposedStmt=main
-// CHECK: {start_line=48 start_col=15 end_line=49 end_col=1} UnexposedStmt=main
+// CHECK: {start_line=48 start_col=14 end_line=48 end_col=14} UnexposedStmt=
+// CHECK: {start_line=48 start_col=15 end_line=49 end_col=1} UnexposedStmt=
 // CHECK: {start_line=49 start_col=2 end_line=49 end_col=2} DeclRefExpr=d:48:13
 // CHECK: {start_line=49 start_col=3 end_line=49 end_col=5} UnexposedExpr=
 // CHECK: {start_line=49 start_col=6 end_line=49 end_col=6} DeclRefExpr=c:47:12
-// CHECK: {start_line=49 start_col=7 end_line=50 end_col=1} UnexposedStmt=main
+// CHECK: {start_line=49 start_col=7 end_line=50 end_col=1} UnexposedStmt=
 // CHECK: {start_line=50 start_col=2 end_line=50 end_col=2} ObjCMessageExpr=pMethod:24:1
 // CHECK: {start_line=50 start_col=3 end_line=50 end_col=3} DeclRefExpr=d:48:13
 // CHECK: {start_line=50 start_col=4 end_line=50 end_col=12} ObjCMessageExpr=pMethod:24:1
-// CHECK: {start_line=50 start_col=13 end_line=51 end_col=1} UnexposedStmt=main
+// CHECK: {start_line=50 start_col=13 end_line=51 end_col=1} UnexposedStmt=
 // CHECK: {start_line=51 start_col=2 end_line=51 end_col=2} ObjCMessageExpr=catMethodWithFloat::19:1
 // CHECK: {start_line=51 start_col=3 end_line=51 end_col=5} DeclRefExpr=bee:45:8
 // CHECK: {start_line=51 start_col=6 end_line=51 end_col=25} ObjCMessageExpr=catMethodWithFloat::19:1
@@ -142,7 +142,7 @@
 // CHECK: {start_line=51 start_col=27 end_line=51 end_col=29} DeclRefExpr=bee:45:8
 // CHECK: {start_line=51 start_col=30 end_line=51 end_col=42} ObjCMessageExpr=floatMethod:20:1
 // CHECK: {start_line=51 start_col=43 end_line=51 end_col=43} ObjCMessageExpr=catMethodWithFloat::19:1
-// CHECK: {start_line=51 start_col=44 end_line=52 end_col=2} UnexposedStmt=main
+// CHECK: {start_line=51 start_col=44 end_line=52 end_col=2} UnexposedStmt=
 // CHECK: {start_line=52 start_col=3 end_line=52 end_col=6} DeclRefExpr=main:44:5
 // CHECK: {start_line=52 start_col=7 end_line=52 end_col=7} CallExpr=main:44:5
 // CHECK: {start_line=52 start_col=8 end_line=52 end_col=15} DeclRefExpr=someEnum:41:3
@@ -150,4 +150,4 @@
 // CHECK: {start_line=52 start_col=18 end_line=52 end_col=32} UnexposedExpr=bee:45:8
 // CHECK: {start_line=52 start_col=33 end_line=52 end_col=35} DeclRefExpr=bee:45:8
 // CHECK: {start_line=52 start_col=36 end_line=52 end_col=36} CallExpr=main:44:5
-// CHECK: {start_line=52 start_col=37 end_line=53 end_col=1} UnexposedStmt=main
+// CHECK: {start_line=52 start_col=37 end_line=53 end_col=1} UnexposedStmt=

Modified: cfe/trunk/test/Index/load-stmts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/load-stmts.cpp?rev=94426&r1=94425&r2=94426&view=diff

==============================================================================
--- cfe/trunk/test/Index/load-stmts.cpp (original)
+++ cfe/trunk/test/Index/load-stmts.cpp Mon Jan 25 10:56:17 2010
@@ -11,9 +11,9 @@
 }
 
 // RUN: c-index-test -test-load-source all %s | FileCheck %s
-// CHECK: load-stmts.cpp:3:6: UnexposedStmt=f [Extent=3:15:11:1]
-// CHECK: load-stmts.cpp:3:6: UnexposedStmt=f [Extent=4:3:5:3]
-// CHECK: load-stmts.cpp:3:6: UnexposedStmt=f [Extent=4:8:4:15]
+// CHECK: load-stmts.cpp:3:6: UnexposedStmt= [Extent=3:15:11:1]
+// CHECK: load-stmts.cpp:3:6: UnexposedStmt= [Extent=4:3:5:3]
+// CHECK: load-stmts.cpp:3:6: UnexposedStmt= [Extent=4:8:4:15]
 // CHECK: load-stmts.cpp:4:10: VarDecl=y:4:10 (Definition) [Extent=4:8:4:14]
 // CHECK: load-stmts.cpp:4:8: TypeRef=T:1:13 [Extent=4:8:4:8]
 // CHECK: load-stmts.cpp:4:14: DeclRefExpr=x:3:12 [Extent=4:14:4:14]
@@ -24,29 +24,29 @@
 // CHECK: load-stmts.cpp:4:19: DeclRefExpr=z:4:19 [Extent=4:19:4:19]
 // CHECK: load-stmts.cpp:4:26: UnexposedExpr= [Extent=4:26:4:28]
 // CHECK: load-stmts.cpp:4:28: DeclRefExpr=x:3:12 [Extent=4:28:4:28]
-// CHECK: load-stmts.cpp:4:19: UnexposedStmt=z [Extent=4:31:5:3]
-// CHECK: load-stmts.cpp:4:19: UnexposedStmt=z [Extent=6:3:6:21]
+// CHECK: load-stmts.cpp:4:19: UnexposedStmt= [Extent=4:31:5:3]
+// CHECK: load-stmts.cpp:4:19: UnexposedStmt= [Extent=6:3:6:21]
 // CHECK: load-stmts.cpp:6:10: VarDecl=z2:6:10 (Definition) [Extent=6:7:6:16]
 // CHECK: load-stmts.cpp:6:7: TypeRef=T:1:13 [Extent=6:7:6:7]
 // CHECK: load-stmts.cpp:6:15: UnexposedExpr= [Extent=6:15:6:16]
 // CHECK: load-stmts.cpp:6:16: DeclRefExpr=x:3:12 [Extent=6:16:6:16]
 // CHECK: load-stmts.cpp:6:10: UnexposedExpr=z2:6:10 [Extent=6:10:6:11]
 // CHECK: load-stmts.cpp:6:10: DeclRefExpr=z2:6:10 [Extent=6:10:6:11]
-// CHECK: load-stmts.cpp:6:10: UnexposedStmt=z2 [Extent=6:19:6:21]
-// CHECK: load-stmts.cpp:6:10: UnexposedStmt=z2 [Extent=7:3:7:24]
+// CHECK: load-stmts.cpp:6:10: UnexposedStmt= [Extent=6:19:6:21]
+// CHECK: load-stmts.cpp:6:10: UnexposedStmt= [Extent=7:3:7:24]
 // CHECK: load-stmts.cpp:7:13: VarDecl=z3:7:13 (Definition) [Extent=7:10:7:19]
 // CHECK: load-stmts.cpp:7:10: TypeRef=T:1:13 [Extent=7:10:7:10]
 // CHECK: load-stmts.cpp:7:18: UnexposedExpr= [Extent=7:18:7:19]
 // CHECK: load-stmts.cpp:7:19: DeclRefExpr=x:3:12 [Extent=7:19:7:19]
 // CHECK: load-stmts.cpp:7:13: UnexposedExpr=z3:7:13 [Extent=7:13:7:14]
 // CHECK: load-stmts.cpp:7:13: DeclRefExpr=z3:7:13 [Extent=7:13:7:14]
-// CHECK: load-stmts.cpp:7:13: UnexposedStmt=z3 [Extent=7:22:7:24]
-// CHECK: load-stmts.cpp:7:13: UnexposedStmt=z3 [Extent=8:3:10:3]
+// CHECK: load-stmts.cpp:7:13: UnexposedStmt= [Extent=7:22:7:24]
+// CHECK: load-stmts.cpp:7:13: UnexposedStmt= [Extent=8:3:10:3]
 // CHECK: load-stmts.cpp:8:13: VarDecl=z4:8:13 (Definition) [Extent=8:11:8:18]
 // CHECK: load-stmts.cpp:8:11: TypeRef=T:1:13 [Extent=8:11:8:11]
 // CHECK: load-stmts.cpp:8:18: DeclRefExpr=x:3:12 [Extent=8:18:8:18]
 // CHECK: load-stmts.cpp:8:13: DeclRefExpr=z4:8:13 [Extent=8:13:8:14]
-// CHECK: load-stmts.cpp:8:13: UnexposedStmt=z4 [Extent=8:21:10:3]
-// CHECK: load-stmts.cpp:8:13: UnexposedStmt=z4 [Extent=9:3:9:16]
-// CHECK: load-stmts.cpp:8:13: UnexposedStmt=z4 [Extent=9:12:9:16]
+// CHECK: load-stmts.cpp:8:13: UnexposedStmt= [Extent=8:21:10:3]
+// CHECK: load-stmts.cpp:8:13: UnexposedStmt= [Extent=9:3:9:16]
+// CHECK: load-stmts.cpp:8:13: UnexposedStmt= [Extent=9:12:9:16]
 // CHECK: load-stmts.cpp:9:8: UnexposedExpr= [Extent=9:8:9:9]

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

==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Mon Jan 25 10:56:17 2010
@@ -1349,7 +1349,10 @@
     return CIndexer::createCXString("");
   }
 
-  return getDeclSpelling(getCursorDecl(C));
+  if (clang_isDeclaration(C.kind))
+    return getDeclSpelling(getCursorDecl(C));
+  
+  return CIndexer::createCXString("");
 }
 
 const char *clang_getCursorKindSpelling(enum CXCursorKind Kind) {





More information about the cfe-commits mailing list