aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/IndexDecl.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-11 00:23:36 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-11 00:23:36 +0000
commitdd93c596cd95e1b96031ff47efe0a5095ff3d7f1 (patch)
tree423f7b1be7f9d00e680f5bf2eb6cc2e9bea4cc49 /tools/libclang/IndexDecl.cpp
parentba49103550281ff9c92c850487e83c7a6eb43825 (diff)
[libclang] Simplify the indexing API.
Cut down the number of callbacks to more generic ones. Clients can check an enum to find out what kind of declaration it is and they can call functions to get more specific information than the generic provided info. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144343 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/IndexDecl.cpp')
-rw-r--r--tools/libclang/IndexDecl.cpp67
1 files changed, 28 insertions, 39 deletions
diff --git a/tools/libclang/IndexDecl.cpp b/tools/libclang/IndexDecl.cpp
index 5cf9f80263..5087355a8d 100644
--- a/tools/libclang/IndexDecl.cpp
+++ b/tools/libclang/IndexDecl.cpp
@@ -29,9 +29,9 @@ public:
if (D->isThisDeclarationADefinition()) {
const Stmt *Body = D->getBody();
if (Body) {
- IndexCtx.invokeStartedStatementBody(D, D);
+ IndexCtx.startContainer(D, /*isBody=*/true);
IndexCtx.indexBody(Body, D);
- IndexCtx.invokeEndedContainer(D);
+ IndexCtx.endContainer(D);
}
}
return true;
@@ -68,15 +68,7 @@ public:
}
bool VisitObjCClassDecl(ObjCClassDecl *D) {
- ObjCClassDecl::ObjCClassRef *Ref = D->getForwardDecl();
- if (Ref->getInterface()->getLocation() == Ref->getLocation()) {
- IndexCtx.handleObjCInterface(Ref->getInterface());
- } else {
- IndexCtx.handleReference(Ref->getInterface(),
- Ref->getLocation(),
- 0,
- Ref->getInterface()->getDeclContext());
- }
+ IndexCtx.handleObjCClass(D);
return true;
}
@@ -87,74 +79,71 @@ public:
SourceLocation Loc = *LI;
ObjCProtocolDecl *PD = *I;
- if (PD->getLocation() == Loc) {
- IndexCtx.handleObjCProtocol(PD);
- } else {
- IndexCtx.handleReference(PD, Loc, 0, PD->getDeclContext());
- }
+ bool isRedeclaration = PD->getLocation() != Loc;
+ IndexCtx.handleObjCForwardProtocol(PD, Loc, isRedeclaration);
}
return true;
}
bool VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
- // Only definitions are handled here.
+ // Forward decls are handled at VisitObjCClassDecl.
if (D->isForwardDecl())
return true;
- if (!D->isInitiallyForwardDecl())
- IndexCtx.handleObjCInterface(D);
+ IndexCtx.handleObjCInterface(D);
IndexCtx.indexTUDeclsInObjCContainer();
- IndexCtx.invokeStartedObjCContainer(D);
+ IndexCtx.startContainer(D);
IndexCtx.defineObjCInterface(D);
IndexCtx.indexDeclContext(D);
- IndexCtx.invokeEndedContainer(D);
+ IndexCtx.endContainer(D);
return true;
}
bool VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
- // Only definitions are handled here.
+ // Forward decls are handled at VisitObjCForwardProtocolDecl.
if (D->isForwardDecl())
return true;
- if (!D->isInitiallyForwardDecl())
- IndexCtx.handleObjCProtocol(D);
+ IndexCtx.handleObjCProtocol(D);
IndexCtx.indexTUDeclsInObjCContainer();
- IndexCtx.invokeStartedObjCContainer(D);
+ IndexCtx.startContainer(D);
IndexCtx.indexDeclContext(D);
- IndexCtx.invokeEndedContainer(D);
+ IndexCtx.endContainer(D);
return true;
}
bool VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
- ObjCInterfaceDecl *Class = D->getClassInterface();
- if (Class->isImplicitInterfaceDecl())
- IndexCtx.handleObjCInterface(Class);
+ IndexCtx.handleObjCImplementation(D);
IndexCtx.indexTUDeclsInObjCContainer();
- IndexCtx.invokeStartedObjCContainer(D);
+ IndexCtx.startContainer(D);
IndexCtx.indexDeclContext(D);
- IndexCtx.invokeEndedContainer(D);
+ IndexCtx.endContainer(D);
return true;
}
bool VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
- if (!D->IsClassExtension())
- IndexCtx.handleObjCCategory(D);
+ IndexCtx.handleObjCCategory(D);
IndexCtx.indexTUDeclsInObjCContainer();
- IndexCtx.invokeStartedObjCContainer(D);
+ IndexCtx.startContainer(D);
IndexCtx.indexDeclContext(D);
- IndexCtx.invokeEndedContainer(D);
+ IndexCtx.endContainer(D);
return true;
}
bool VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
+ if (D->getCategoryDecl()->getLocation().isInvalid())
+ return true;
+
+ IndexCtx.handleObjCCategoryImpl(D);
+
IndexCtx.indexTUDeclsInObjCContainer();
- IndexCtx.invokeStartedObjCContainer(D);
+ IndexCtx.startContainer(D);
IndexCtx.indexDeclContext(D);
- IndexCtx.invokeEndedContainer(D);
+ IndexCtx.endContainer(D);
return true;
}
@@ -168,9 +157,9 @@ public:
if (D->isThisDeclarationADefinition()) {
const Stmt *Body = D->getBody();
if (Body) {
- IndexCtx.invokeStartedStatementBody(D, D);
+ IndexCtx.startContainer(D, /*isBody=*/true);
IndexCtx.indexBody(Body, D);
- IndexCtx.invokeEndedContainer(D);
+ IndexCtx.endContainer(D);
}
}
return true;