aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/IndexBody.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-13 18:47:41 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-13 18:47:41 +0000
commite422e45a6a89d450b8eca10f671b49874e87617a (patch)
treebe55d8a6c74db604e5d83cb474c96ceeefe39274 /tools/libclang/IndexBody.cpp
parentc2be04eaec94e20fc825fb98b713112d9d82562f (diff)
[libclang] Indexing API: Fix indexing of missed references.
rdar://10567864&10567916 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/IndexBody.cpp')
-rw-r--r--tools/libclang/IndexBody.cpp46
1 files changed, 29 insertions, 17 deletions
diff --git a/tools/libclang/IndexBody.cpp b/tools/libclang/IndexBody.cpp
index 9418ed7bb1..bac7e02514 100644
--- a/tools/libclang/IndexBody.cpp
+++ b/tools/libclang/IndexBody.cpp
@@ -19,43 +19,49 @@ namespace {
class BodyIndexer : public RecursiveASTVisitor<BodyIndexer> {
IndexingContext &IndexCtx;
+ const NamedDecl *Parent;
const DeclContext *ParentDC;
bool InPseudoObject;
typedef RecursiveASTVisitor<BodyIndexer> base;
public:
- BodyIndexer(IndexingContext &indexCtx, const DeclContext *DC)
- : IndexCtx(indexCtx), ParentDC(DC), InPseudoObject(false) { }
+ BodyIndexer(IndexingContext &indexCtx,
+ const NamedDecl *Parent, const DeclContext *DC)
+ : IndexCtx(indexCtx), Parent(Parent), ParentDC(DC),
+ InPseudoObject(false) { }
bool shouldWalkTypesOfTypeLocs() const { return false; }
bool TraverseTypeLoc(TypeLoc TL) {
- IndexCtx.indexTypeLoc(TL, 0, ParentDC);
+ IndexCtx.indexTypeLoc(TL, Parent, ParentDC);
return true;
}
bool VisitDeclRefExpr(DeclRefExpr *E) {
- IndexCtx.handleReference(E->getDecl(), E->getLocation(), 0, ParentDC, E);
+ IndexCtx.handleReference(E->getDecl(), E->getLocation(),
+ Parent, ParentDC, E);
return true;
}
bool VisitMemberExpr(MemberExpr *E) {
- IndexCtx.handleReference(E->getMemberDecl(), E->getMemberLoc(), 0, ParentDC,
- E);
+ IndexCtx.handleReference(E->getMemberDecl(), E->getMemberLoc(),
+ Parent, ParentDC, E);
return true;
}
bool VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
- IndexCtx.handleReference(E->getDecl(), E->getLocation(), 0, ParentDC, E);
+ IndexCtx.handleReference(E->getDecl(), E->getLocation(),
+ Parent, ParentDC, E);
return true;
}
bool VisitObjCMessageExpr(ObjCMessageExpr *E) {
if (TypeSourceInfo *Cls = E->getClassReceiverTypeInfo())
- IndexCtx.indexTypeSourceInfo(Cls, 0, ParentDC);
+ IndexCtx.indexTypeSourceInfo(Cls, Parent, ParentDC);
if (ObjCMethodDecl *MD = E->getMethodDecl())
- IndexCtx.handleReference(MD, E->getSelectorStartLoc(), 0, ParentDC, E,
+ IndexCtx.handleReference(MD, E->getSelectorStartLoc(),
+ Parent, ParentDC, E,
InPseudoObject ? CXIdxEntityRef_Implicit
: CXIdxEntityRef_Direct);
return true;
@@ -64,14 +70,14 @@ public:
bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
if (E->isImplicitProperty()) {
if (ObjCMethodDecl *MD = E->getImplicitPropertyGetter())
- IndexCtx.handleReference(MD, E->getLocation(), 0, ParentDC, E,
+ IndexCtx.handleReference(MD, E->getLocation(), Parent, ParentDC, E,
CXIdxEntityRef_Implicit);
if (ObjCMethodDecl *MD = E->getImplicitPropertySetter())
- IndexCtx.handleReference(MD, E->getLocation(), 0, ParentDC, E,
+ IndexCtx.handleReference(MD, E->getLocation(), Parent, ParentDC, E,
CXIdxEntityRef_Implicit);
} else {
- IndexCtx.handleReference(E->getExplicitProperty(), E->getLocation(), 0,
- ParentDC, E);
+ IndexCtx.handleReference(E->getExplicitProperty(), E->getLocation(),
+ Parent, ParentDC, E);
}
return true;
}
@@ -82,14 +88,20 @@ public:
}
bool VisitCXXConstructExpr(CXXConstructExpr *E) {
- IndexCtx.handleReference(E->getConstructor(), E->getLocation(), 0,
- ParentDC, E);
+ IndexCtx.handleReference(E->getConstructor(), E->getLocation(),
+ Parent, ParentDC, E);
return true;
}
};
} // anonymous namespace
-void IndexingContext::indexBody(const Stmt *S, const DeclContext *DC) {
- BodyIndexer(*this, DC).TraverseStmt(const_cast<Stmt*>(S));
+void IndexingContext::indexBody(const Stmt *S, const NamedDecl *Parent,
+ const DeclContext *DC) {
+ if (!S)
+ return;
+
+ if (DC == 0)
+ DC = Parent->getLexicalDeclContext();
+ BodyIndexer(*this, Parent, DC).TraverseStmt(const_cast<Stmt*>(S));
}