From: Argyrios Kyrtzidis Date: Tue, 21 Jul 2009 00:05:38 +0000 (+0000) Subject: Handle references from ObjCIvarRefExprs. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80ede1d7148582b7647d7cbe09c86e3305976839;p=clang Handle references from ObjCIvarRefExprs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76507 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Index/ASTLocation.cpp b/lib/Index/ASTLocation.cpp index e869707f4d..55a90fad8d 100644 --- a/lib/Index/ASTLocation.cpp +++ b/lib/Index/ASTLocation.cpp @@ -16,6 +16,7 @@ #include "clang/AST/DeclObjC.h" #include "clang/AST/Stmt.h" #include "clang/AST/Expr.h" +#include "clang/AST/ExprObjC.h" using namespace clang; using namespace idx; @@ -24,6 +25,9 @@ static Decl *getDeclFromExpr(Stmt *E) { return RefExpr->getDecl(); if (MemberExpr *ME = dyn_cast(E)) return ME->getMemberDecl(); + if (ObjCIvarRefExpr *RE = dyn_cast(E)) + return RE->getDecl(); + if (CallExpr *CE = dyn_cast(E)) return getDeclFromExpr(CE->getCallee()); if (CastExpr *CE = dyn_cast(E)) diff --git a/lib/Index/DeclReferenceMap.cpp b/lib/Index/DeclReferenceMap.cpp index 2e5e7c389a..f99f4ae84d 100644 --- a/lib/Index/DeclReferenceMap.cpp +++ b/lib/Index/DeclReferenceMap.cpp @@ -35,6 +35,7 @@ public: void VisitDeclStmt(DeclStmt *Node); void VisitDeclRefExpr(DeclRefExpr *Node); void VisitMemberExpr(MemberExpr *Node); + void VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node); void VisitStmt(Stmt *Node); }; @@ -48,6 +49,7 @@ public: void VisitDeclContext(DeclContext *DC); void VisitVarDecl(VarDecl *D); void VisitFunctionDecl(FunctionDecl *D); + void VisitObjCMethodDecl(ObjCMethodDecl *D); void VisitBlockDecl(BlockDecl *D); void VisitDecl(Decl *D); }; @@ -75,6 +77,10 @@ void StmtMapper::VisitMemberExpr(MemberExpr *Node) { Map.insert(std::make_pair(PrimD, ASTLocation(Parent, Node))); } +void StmtMapper::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) { + Map.insert(std::make_pair(Node->getDecl(), ASTLocation(Parent, Node))); +} + void StmtMapper::VisitStmt(Stmt *Node) { for (Stmt::child_iterator I = Node->child_begin(), E = Node->child_end(); I != E; ++I) @@ -92,10 +98,13 @@ void DeclMapper::VisitDeclContext(DeclContext *DC) { } void DeclMapper::VisitFunctionDecl(FunctionDecl *D) { - if (!D->isThisDeclarationADefinition()) - return; - - StmtMapper(Map, D).Visit(D->getBody()); + if (D->isThisDeclarationADefinition()) + StmtMapper(Map, D).Visit(D->getBody()); +} + +void DeclMapper::VisitObjCMethodDecl(ObjCMethodDecl *D) { + if (D->getBody()) + StmtMapper(Map, D).Visit(D->getBody()); } void DeclMapper::VisitBlockDecl(BlockDecl *D) {