[cfe-commits] r117167 - in /cfe/trunk: test/Index/blocks.c test/Index/load-exprs.c tools/libclang/CIndex.cpp

Douglas Gregor dgregor at apple.com
Fri Oct 22 15:24:08 PDT 2010


Author: dgregor
Date: Fri Oct 22 17:24:08 2010
New Revision: 117167

URL: http://llvm.org/viewvc/llvm-project?rev=117167&view=rev
Log:
Teach clang_getCursorReferenced() and friends about BlockDeclRefExprs.

Modified:
    cfe/trunk/test/Index/blocks.c
    cfe/trunk/test/Index/load-exprs.c
    cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/blocks.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/blocks.c?rev=117167&r1=117166&r2=117167&view=diff
==============================================================================
--- cfe/trunk/test/Index/blocks.c (original)
+++ cfe/trunk/test/Index/blocks.c Fri Oct 22 17:24:08 2010
@@ -5,25 +5,31 @@
 
 void test() {
   static struct foo _foo;
-  ^ int_t(struct foo *foo) { return (int_t) foo->x; }(&_foo);
+  __block i = 0;
+  ^ int_t(struct foo *foo) { return (int_t) foo->x + i; }(&_foo);
 }
 
-// TODO: expose the BlockExpr, CastExpr, and UnaryOperatorExpr here
-
-// CHECK: blocks.c:3:13: TypedefDecl=int_t:3:13 (Definition) Extent=[3:13 - 3:18]
-// CHECK: blocks.c:4:8: StructDecl=foo:4:8 (Definition) Extent=[4:1 - 4:23]
-// CHECK: blocks.c:4:19: FieldDecl=x:4:19 (Definition) Extent=[4:19 - 4:20]
-// CHECK: blocks.c:6:6: FunctionDecl=test:6:6 (Definition) Extent=[6:6 - 9:2]
+// CHECK: blocks.c:6:6: FunctionDecl=test:6:6 (Definition) Extent=[6:6 - 10:2]
+// CHECK: blocks.c:6:13: UnexposedStmt= Extent=[6:13 - 10:2]
+// CHECK: blocks.c:7:3: UnexposedStmt= Extent=[7:3 - 7:26]
 // CHECK: blocks.c:7:21: VarDecl=_foo:7:21 (Definition) Extent=[7:17 - 7:25]
 // CHECK: blocks.c:7:17: TypeRef=struct foo:4:8 Extent=[7:17 - 7:20]
-// CHECK: blocks.c:8:3: CallExpr= Extent=[8:3 - 8:61]
-// CHECK: blocks.c:8:3: UnexposedExpr= Extent=[8:3 - 8:54]
-// CHECK: blocks.c:8:5: TypeRef=int_t:3:13 Extent=[8:5 - 8:10]
-// CHECK: blocks.c:8:23: ParmDecl=foo:8:23 (Definition) Extent=[8:18 - 8:26]
-// CHECK: blocks.c:8:18: TypeRef=struct foo:4:8 Extent=[8:18 - 8:21]
-// CHECK: blocks.c:8:37: UnexposedExpr=x:4:19 Extent=[8:37 - 8:51]
-// CHECK: blocks.c:8:38: TypeRef=int_t:3:13 Extent=[8:38 - 8:43]
-// CHECK: blocks.c:8:50: MemberRefExpr=x:4:19 Extent=[8:45 - 8:51]
-// CHECK: blocks.c:8:45: DeclRefExpr=foo:8:23 Extent=[8:45 - 8:48]
-// CHECK: blocks.c:8:55: UnexposedExpr= Extent=[8:55 - 8:60]
-// CHECK: blocks.c:8:56: DeclRefExpr=_foo:7:21 Extent=[8:56 - 8:60]
+// CHECK: blocks.c:8:3: UnexposedStmt= Extent=[8:3 - 8:17]
+// CHECK: blocks.c:8:11: VarDecl=i:8:11 (Definition) Extent=[8:11 - 8:16]
+// CHECK: blocks.c:8:15: UnexposedExpr= Extent=[8:15 - 8:16]
+// CHECK: blocks.c:9:3: CallExpr= Extent=[9:3 - 9:65]
+// CHECK: blocks.c:9:3: UnexposedExpr= Extent=[9:3 - 9:58]
+// CHECK: blocks.c:9:5: TypeRef=int_t:3:13 Extent=[9:5 - 9:10]
+// CHECK: blocks.c:9:23: ParmDecl=foo:9:23 (Definition) Extent=[9:18 - 9:26]
+// CHECK: blocks.c:9:18: TypeRef=struct foo:4:8 Extent=[9:18 - 9:21]
+// CHECK: blocks.c:9:28: UnexposedStmt= Extent=[9:28 - 9:58]
+// CHECK: blocks.c:9:30: UnexposedStmt= Extent=[9:30 - 9:55]
+// CHECK: blocks.c:9:37: UnexposedExpr= Extent=[9:37 - 9:55]
+// CHECK: blocks.c:9:37: UnexposedExpr=x:4:19 Extent=[9:37 - 9:51]
+// CHECK: blocks.c:9:38: TypeRef=int_t:3:13 Extent=[9:38 - 9:43]
+// CHECK: blocks.c:9:50: MemberRefExpr=x:4:19 Extent=[9:45 - 9:51]
+// CHECK: blocks.c:9:45: DeclRefExpr=foo:9:23 Extent=[9:45 - 9:48]
+// CHECK: blocks.c:9:54: DeclRefExpr=i:8:11 Extent=[9:54 - 9:55]
+// CHECK: blocks.c:9:59: UnexposedExpr= Extent=[9:59 - 9:64]
+// CHECK: blocks.c:9:60: DeclRefExpr=_foo:7:21 Extent=[9:60 - 9:64]
+

Modified: cfe/trunk/test/Index/load-exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/load-exprs.c?rev=117167&r1=117166&r2=117167&view=diff
==============================================================================
--- cfe/trunk/test/Index/load-exprs.c (original)
+++ cfe/trunk/test/Index/load-exprs.c Fri Oct 22 17:24:08 2010
@@ -56,12 +56,12 @@
 // CHECK: load-exprs.c:11:19: DeclRefExpr=x:10:21 Extent=[11:19 - 11:20]
 // CHECK: load-exprs.c:12:3: CallExpr= Extent=[12:3 - 19:7]
 // CHECK: load-exprs.c:13:17: VarDecl=z:13:17 (Definition) Extent=[13:13 - 13:22]
-// CHECK: load-exprs.c:14:6: DeclRefExpr= Extent=[14:6 - 14:7]
+// CHECK: load-exprs.c:14:6: DeclRefExpr=y:11:15 Extent=[14:6 - 14:7]
 // CHECK: load-exprs.c:14:13: DeclRefExpr=z:13:17 Extent=[14:13 - 14:14]
-// CHECK: load-exprs.c:14:18: DeclRefExpr= Extent=[14:18 - 14:19]
+// CHECK: load-exprs.c:14:18: DeclRefExpr=x:10:21 Extent=[14:18 - 14:19]
 // CHECK: load-exprs.c:15:6: CallExpr= Extent=[15:6 - 18:9]
 // CHECK: load-exprs.c:16:10: DeclRefExpr=z:13:17 Extent=[16:10 - 16:11]
-// CHECK: load-exprs.c:17:10: DeclRefExpr= Extent=[17:10 - 17:11]
+// CHECK: load-exprs.c:17:10: DeclRefExpr=y:11:15 Extent=[17:10 - 17:11]
 // CHECK: load-exprs.c:20:10: DeclRefExpr=y:11:15 Extent=[20:10 - 20:11]
 // CHECK: load-exprs.c:29:6: FunctionDecl=test_members:29:6 (Definition)
 // CHECK: load-exprs.c:30:12: VarDecl=y0:30:12 (Definition) Extent=[30:10 - 30:77]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=117167&r1=117166&r2=117167&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Oct 22 17:24:08 2010
@@ -2404,6 +2404,8 @@
 
   if (DeclRefExpr *RefExpr = dyn_cast<DeclRefExpr>(E))
     return RefExpr->getDecl();
+  if (BlockDeclRefExpr *RefExpr = dyn_cast<BlockDeclRefExpr>(E))
+    return RefExpr->getDecl();
   if (MemberExpr *ME = dyn_cast<MemberExpr>(E))
     return ME->getMemberDecl();
   if (ObjCIvarRefExpr *RE = dyn_cast<ObjCIvarRefExpr>(E))
@@ -2427,6 +2429,8 @@
     return /*FIXME:*/Msg->getLeftLoc();
   if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
     return DRE->getLocation();
+  if (BlockDeclRefExpr *RefExpr = dyn_cast<BlockDeclRefExpr>(E))
+    return RefExpr->getLocation();
   if (MemberExpr *Member = dyn_cast<MemberExpr>(E))
     return Member->getMemberLoc();
   if (ObjCIvarRefExpr *Ivar = dyn_cast<ObjCIvarRefExpr>(E))





More information about the cfe-commits mailing list