forked from OSchip/llvm-project
parent
c3deb79049
commit
34be01b9f4
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 &&
|
||||
|
||||
|
|
|
@ -25,5 +25,7 @@ void field_test(void) {
|
|||
ms.field_var = 10;
|
||||
}
|
||||
|
||||
int (^CP)(int) = ^(int x) { return x * global_var; };
|
||||
|
||||
// Suppress 'no run line' failure.
|
||||
// RUN: true
|
||||
|
|
Loading…
Reference in New Issue