[cfe-commits] r77540 - in /cfe/trunk: lib/Index/ASTLocation.cpp lib/Index/ASTVisitor.h test/Index/find-refs.c test/Index/t1.c
Argiris Kirtzidis
akyrtzi at gmail.com
Wed Jul 29 16:40:49 PDT 2009
Author: akirtzidis
Date: Wed Jul 29 18:40:48 2009
New Revision: 77540
URL: http://llvm.org/viewvc/llvm-project?rev=77540&view=rev
Log:
Find references inside blocks.
Modified:
cfe/trunk/lib/Index/ASTLocation.cpp
cfe/trunk/lib/Index/ASTVisitor.h
cfe/trunk/test/Index/find-refs.c
cfe/trunk/test/Index/t1.c
Modified: cfe/trunk/lib/Index/ASTLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/ASTLocation.cpp?rev=77540&r1=77539&r2=77540&view=diff
==============================================================================
--- cfe/trunk/lib/Index/ASTLocation.cpp (original)
+++ cfe/trunk/lib/Index/ASTLocation.cpp Wed Jul 29 18:40:48 2009
@@ -103,6 +103,18 @@
return isContainedInStatement(Node, MD->getBody()) ? D : 0;
}
+ if (BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
+ for (DeclContext::decl_iterator
+ I = BD->decls_begin(), E = BD->decls_end(); I != E; ++I) {
+ Decl *Child = FindImmediateParent(*I, Node);
+ if (Child)
+ return Child;
+ }
+
+ assert(BD->getBody() && "BlockDecl without body ?");
+ return isContainedInStatement(Node, BD->getBody()) ? D : 0;
+ }
+
return 0;
}
Modified: cfe/trunk/lib/Index/ASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/ASTVisitor.h?rev=77540&r1=77539&r2=77540&view=diff
==============================================================================
--- cfe/trunk/lib/Index/ASTVisitor.h (original)
+++ cfe/trunk/lib/Index/ASTVisitor.h Wed Jul 29 18:40:48 2009
@@ -94,6 +94,10 @@
Visit(*I);
}
+ void VisitBlockExpr(BlockExpr *Node) {
+ Visit(Node->getBlockDecl());
+ }
+
void VisitStmt(Stmt *Node) {
for (Stmt::child_iterator
I = Node->child_begin(), E = Node->child_end(); I != E; ++I)
Modified: cfe/trunk/test/Index/find-refs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/find-refs.c?rev=77540&r1=77539&r2=77540&view=diff
==============================================================================
--- cfe/trunk/test/Index/find-refs.c (original)
+++ cfe/trunk/test/Index/find-refs.c Wed Jul 29 18:40:48 2009
@@ -2,8 +2,9 @@
// RUN: clang-cc -emit-pch %S/t2.c -o %t2.ast &&
// RUN: index-test %t1.ast %t2.ast -point-at %S/foo.h:1:14 -print-refs > %t &&
-// RUN: cat %t | count 3 &&
+// RUN: cat %t | count 4 &&
// RUN: grep 't1.c:4:19,' %t &&
+// RUN: grep 't1.c:28:40,' %t &&
// RUN: grep 't2.c:6:3,' %t &&
// RUN: grep 't2.c:7:12,' %t &&
Modified: cfe/trunk/test/Index/t1.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/t1.c?rev=77540&r1=77539&r2=77540&view=diff
==============================================================================
--- cfe/trunk/test/Index/t1.c (original)
+++ cfe/trunk/test/Index/t1.c Wed Jul 29 18:40:48 2009
@@ -25,5 +25,7 @@
ms.field_var = 10;
}
+int (^CP)(int) = ^(int x) { return x * global_var; };
+
// Suppress 'no run line' failure.
// RUN: true
More information about the cfe-commits
mailing list