diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-18 00:33:46 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-18 00:33:46 +0000 |
commit | 38d83defbeab1f5360fd28ee53d0eb63e656a769 (patch) | |
tree | 3128948756e2f59efa72b9b2edfcec0623d026e4 /clang/lib/Index/ASTLocation.cpp | |
parent | 340f8af489addfe18ead338843101f71e2bdb5e1 (diff) | |
download | bcm5719-llvm-38d83defbeab1f5360fd28ee53d0eb63e656a769.tar.gz bcm5719-llvm-38d83defbeab1f5360fd28ee53d0eb63e656a769.zip |
Make ASTLocation accept a Stmt that is inside an ObjCMethodDecl.
llvm-svn: 76271
Diffstat (limited to 'clang/lib/Index/ASTLocation.cpp')
-rw-r--r-- | clang/lib/Index/ASTLocation.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/clang/lib/Index/ASTLocation.cpp b/clang/lib/Index/ASTLocation.cpp index 41846055da0..f73ddc087aa 100644 --- a/clang/lib/Index/ASTLocation.cpp +++ b/clang/lib/Index/ASTLocation.cpp @@ -13,6 +13,7 @@ #include "clang/Index/ASTLocation.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclObjC.h" #include "clang/AST/Stmt.h" #include "clang/AST/Expr.h" using namespace clang; @@ -42,7 +43,7 @@ Decl *ASTLocation::FindImmediateParent(Decl *D, Stmt *Node) { return 0; return isContainedInStatement(Node, Init) ? D : 0; } - + if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { if (!FD->isThisDeclarationADefinition()) return 0; @@ -53,11 +54,26 @@ Decl *ASTLocation::FindImmediateParent(Decl *D, Stmt *Node) { if (Child) return Child; } - + assert(FD->getBody() && "If not definition we should have exited already"); return isContainedInStatement(Node, FD->getBody()) ? D : 0; } - + + if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) { + if (!MD->getBody()) + return 0; + + for (DeclContext::decl_iterator + I = MD->decls_begin(), E = MD->decls_end(); I != E; ++I) { + Decl *Child = FindImmediateParent(*I, Node); + if (Child) + return Child; + } + + assert(MD->getBody() && "If not definition we should have exited already"); + return isContainedInStatement(Node, MD->getBody()) ? D : 0; + } + return 0; } |