diff options
Diffstat (limited to 'lib/Index')
-rw-r--r-- | lib/Index/ASTLocation.cpp | 12 | ||||
-rw-r--r-- | lib/Index/ASTVisitor.h | 4 |
2 files changed, 16 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; } diff --git a/lib/Index/ASTVisitor.h b/lib/Index/ASTVisitor.h index 330bf016d3..11089f044d 100644 --- a/lib/Index/ASTVisitor.h +++ b/lib/Index/ASTVisitor.h @@ -94,6 +94,10 @@ public: 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) |