[cfe-commits] r105491 - in /cfe/trunk: test/Index/blocks.c tools/libclang/CIndex.cpp
John McCall
rjmccall at apple.com
Fri Jun 4 15:33:30 PDT 2010
Author: rjmccall
Date: Fri Jun 4 17:33:30 2010
New Revision: 105491
URL: http://llvm.org/viewvc/llvm-project?rev=105491&view=rev
Log:
Add indexing support for the block and @property type location information
I just implemented.
Added:
cfe/trunk/test/Index/blocks.c
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
Added: cfe/trunk/test/Index/blocks.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/blocks.c?rev=105491&view=auto
==============================================================================
--- cfe/trunk/test/Index/blocks.c (added)
+++ cfe/trunk/test/Index/blocks.c Fri Jun 4 17:33:30 2010
@@ -0,0 +1,29 @@
+// RUN: c-index-test -test-load-source local -fblocks %s | FileCheck %s
+
+typedef int int_t;
+struct foo { long x; };
+
+void test() {
+ static struct foo _foo;
+ ^ int_t(struct foo *foo) { return (int_t) foo->x; }(&_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: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]
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=105491&r1=105490&r2=105491&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Jun 4 17:33:30 2010
@@ -517,10 +517,8 @@
}
bool CursorVisitor::VisitBlockDecl(BlockDecl *B) {
- for (BlockDecl::param_iterator I=B->param_begin(), E=B->param_end(); I!=E;++I)
- if (Decl *D = *I)
- if (Visit(D))
- return true;
+ if (Visit(B->getSignatureAsWritten()->getTypeLoc()))
+ return true;
return Visit(MakeCXCursor(B->getBody(), StmtParent, TU));
}
@@ -672,6 +670,9 @@
}
bool CursorVisitor::VisitObjCPropertyDecl(ObjCPropertyDecl *PD) {
+ if (Visit(PD->getTypeSourceInfo()->getTypeLoc()))
+ return true;
+
// FIXME: This implements a workaround with @property declarations also being
// installed in the DeclContext for the @interface. Eventually this code
// should be removed.
More information about the cfe-commits
mailing list