aboutsummaryrefslogtreecommitdiff
path: root/lib/Index/ASTLocation.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-29 23:40:48 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-29 23:40:48 +0000
commitad6e5d12d0ec3a49157e7794ddc1baa575ca008b (patch)
treed009debc7880fa851a3c2f484b7f12859ff720db /lib/Index/ASTLocation.cpp
parent81e84560c85c5d3727072f5b9e8bd2a963adf8e7 (diff)
Find references inside blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77540 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Index/ASTLocation.cpp')
-rw-r--r--lib/Index/ASTLocation.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Index/ASTLocation.cpp b/lib/Index/ASTLocation.cpp
index d528c5ac5f..f010a2bcc8 100644
--- a/lib/Index/ASTLocation.cpp
+++ b/lib/Index/ASTLocation.cpp
@@ -103,6 +103,18 @@ Decl *ASTLocation::FindImmediateParent(Decl *D, Stmt *Node) {
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;
}