[cfe-commits] r76271 - /cfe/trunk/lib/Index/ASTLocation.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Fri Jul 17 17:33:46 PDT 2009
Author: akirtzidis
Date: Fri Jul 17 19:33:46 2009
New Revision: 76271
URL: http://llvm.org/viewvc/llvm-project?rev=76271&view=rev
Log:
Make ASTLocation accept a Stmt that is inside an ObjCMethodDecl.
Modified:
cfe/trunk/lib/Index/ASTLocation.cpp
Modified: cfe/trunk/lib/Index/ASTLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/ASTLocation.cpp?rev=76271&r1=76270&r2=76271&view=diff
==============================================================================
--- cfe/trunk/lib/Index/ASTLocation.cpp (original)
+++ cfe/trunk/lib/Index/ASTLocation.cpp Fri Jul 17 19:33:46 2009
@@ -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 @@
return 0;
return isContainedInStatement(Node, Init) ? D : 0;
}
-
+
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
if (!FD->isThisDeclarationADefinition())
return 0;
@@ -53,11 +54,26 @@
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;
}
More information about the cfe-commits
mailing list