summaryrefslogtreecommitdiffstats
path: root/clang/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
commit7519c5e44034ee85d531dd9d842d4233b91ac39a (patch)
tree072365c9e90e3b2b09f66ba368a18d5cd3e2a1f8 /clang/tools/libclang/IndexDecl.cpp
parent85b075b8451370f6f6fc1f3be737f49b52f63a07 (diff)
downloadbcm5719-llvm-7519c5e44034ee85d531dd9d842d4233b91ac39a.tar.gz
bcm5719-llvm-7519c5e44034ee85d531dd9d842d4233b91ac39a.zip
[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. llvm-svn: 144343
Diffstat (limited to 'clang/tools/libclang/IndexDecl.cpp')
-rw-r--r--clang/tools/libclang/IndexDecl.cpp67
1 files changed, 28 insertions, 39 deletions
diff --git a/clang/tools/libclang/IndexDecl.cpp b/clang/tools/libclang/IndexDecl.cpp
index 5cf9f802634..5087355a8dd 100644
--- a/clang/tools/libclang/IndexDecl.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud