summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang
diff options
context:
space:
mode:
Diffstat (limited to 'clang/tools/libclang')
-rw-r--r--clang/tools/libclang/IndexDecl.cpp67
-rw-r--r--clang/tools/libclang/IndexTypeSourceInfo.cpp4
-rw-r--r--clang/tools/libclang/Indexing.cpp54
-rw-r--r--clang/tools/libclang/IndexingContext.cpp581
-rw-r--r--clang/tools/libclang/IndexingContext.h102
-rw-r--r--clang/tools/libclang/libclang.exports6
6 files changed, 412 insertions, 402 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;
diff --git a/clang/tools/libclang/IndexTypeSourceInfo.cpp b/clang/tools/libclang/IndexTypeSourceInfo.cpp
index 63446450f38..bba9dbb6e7a 100644
--- a/clang/tools/libclang/IndexTypeSourceInfo.cpp
+++ b/clang/tools/libclang/IndexTypeSourceInfo.cpp
@@ -87,8 +87,8 @@ void IndexingContext::indexTypeLoc(TypeLoc TL,
void IndexingContext::indexTagDecl(const TagDecl *D) {
handleTagDecl(D);
if (D->isThisDeclarationADefinition()) {
- invokeStartedTagTypeDefinition(D);
+ startContainer(D);
indexDeclContext(D);
- invokeEndedContainer(D);
+ endContainer(D);
}
}
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp
index 7f296ae1d19..4bea88f8de6 100644
--- a/clang/tools/libclang/Indexing.cpp
+++ b/clang/tools/libclang/Indexing.cpp
@@ -40,10 +40,25 @@ namespace {
class IndexPPCallbacks : public PPCallbacks {
Preprocessor &PP;
IndexingContext &IndexCtx;
+ bool IsMainFileEntered;
public:
IndexPPCallbacks(Preprocessor &PP, IndexingContext &indexCtx)
- : PP(PP), IndexCtx(indexCtx) { }
+ : PP(PP), IndexCtx(indexCtx), IsMainFileEntered(false) { }
+
+ virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
+ SrcMgr::CharacteristicKind FileType, FileID PrevFID) {
+ if (IsMainFileEntered)
+ return;
+
+ SourceManager &SM = PP.getSourceManager();
+ SourceLocation MainFileLoc = SM.getLocForStartOfFile(SM.getMainFileID());
+
+ if (Loc == MainFileLoc && Reason == PPCallbacks::EnterFile) {
+ IsMainFileEntered = true;
+ IndexCtx.enteredMainFile(SM.getFileEntryForID(SM.getMainFileID()));
+ }
+ }
virtual void InclusionDirective(SourceLocation HashLoc,
const Token &IncludeTok,
@@ -389,6 +404,41 @@ static void clang_indexTranslationUnit_Impl(void *UserData) {
extern "C" {
+int clang_index_isEntityTagKind(CXIdxEntityKind K) {
+ return CXIdxEntity_Enum <= K && K <= CXIdxEntity_CXXClass;
+}
+
+CXIdxTagDeclInfo *clang_index_getTagDeclInfo(CXIdxDeclInfo *DInfo) {
+ if (clang_index_isEntityTagKind(DInfo->entityInfo->kind))
+ return &static_cast<TagDeclInfo*>(DInfo)->CXTagDeclInfo;
+
+ return 0;
+}
+
+int clang_index_isEntityObjCContainerKind(CXIdxEntityKind K) {
+ return CXIdxEntity_ObjCClass <= K && K <= CXIdxEntity_ObjCCategory;
+}
+
+CXIdxObjCContainerDeclInfo *
+clang_index_getObjCContainerDeclInfo(CXIdxDeclInfo *DInfo) {
+ if (clang_index_isEntityObjCContainerKind(DInfo->entityInfo->kind))
+ return &static_cast<ObjCContainerDeclInfo*>(DInfo)->CXObjCContDeclInfo;
+
+ return 0;
+}
+
+int clang_index_isEntityObjCCategoryKind(CXIdxEntityKind K) {
+ return K == CXIdxEntity_ObjCCategory;
+}
+
+CXIdxObjCCategoryDeclInfo *
+clang_index_getObjCCategoryDeclInfo(CXIdxDeclInfo *DInfo){
+ if (clang_index_isEntityObjCCategoryKind(DInfo->entityInfo->kind))
+ return &static_cast<ObjCCategoryDeclInfo*>(DInfo)->CXObjCCatDeclInfo;
+
+ return 0;
+}
+
int clang_indexTranslationUnit(CXIndex CIdx,
CXClientData client_data,
IndexerCallbacks *index_callbacks,
@@ -445,7 +495,7 @@ int clang_indexTranslationUnit(CXIndex CIdx,
}
void clang_indexLoc_getFileLocation(CXIdxLoc location,
- CXIdxFile *indexFile,
+ CXIdxClientFile *indexFile,
CXFile *file,
unsigned *line,
unsigned *column,
diff --git a/clang/tools/libclang/IndexingContext.cpp b/clang/tools/libclang/IndexingContext.cpp
index 0f00bac948e..3d3277210e4 100644
--- a/clang/tools/libclang/IndexingContext.cpp
+++ b/clang/tools/libclang/IndexingContext.cpp
@@ -33,6 +33,13 @@ void IndexingContext::setASTContext(ASTContext &ctx) {
static_cast<ASTUnit*>(CXTU->TUData)->setASTContext(&ctx);
}
+void IndexingContext::enteredMainFile(const FileEntry *File) {
+ if (File && CB.enteredMainFile) {
+ CXIdxClientFile idxFile = CB.enteredMainFile(ClientData, (CXFile)File, 0);
+ FileMap[File] = idxFile;
+ }
+}
+
void IndexingContext::ppIncludedFile(SourceLocation hashLoc,
StringRef filename,
const FileEntry *File,
@@ -40,12 +47,13 @@ void IndexingContext::ppIncludedFile(SourceLocation hashLoc,
if (!CB.ppIncludedFile)
return;
- StrAdapter SA(this);
+ StrAdapter SA(*this);
CXIdxIncludedFileInfo Info = { getIndexLoc(hashLoc),
SA.toCStr(filename),
- getIndexFile(File),
+ (CXFile)File,
isImport, isAngled };
- CB.ppIncludedFile(ClientData, &Info);
+ CXIdxClientFile idxFile = CB.ppIncludedFile(ClientData, &Info);
+ FileMap[File] = idxFile;
}
void IndexingContext::ppMacroDefined(SourceLocation Loc, StringRef Name,
@@ -54,11 +62,11 @@ void IndexingContext::ppMacroDefined(SourceLocation Loc, StringRef Name,
if (!CB.ppMacroDefined)
return;
- StrAdapter SA(this);
+ StrAdapter SA(*this);
CXIdxMacroInfo MacroInfo = { getIndexLoc(Loc), SA.toCStr(Name) };
CXIdxMacroDefinedInfo Info = { &MacroInfo,
getIndexLoc(DefBegin), Length };
- CXIdxMacro idxMacro = CB.ppMacroDefined(ClientData, &Info);
+ CXIdxClientMacro idxMacro = CB.ppMacroDefined(ClientData, &Info);
MacroMap[OpaqueMacro] = idxMacro;
}
@@ -67,7 +75,7 @@ void IndexingContext::ppMacroUndefined(SourceLocation Loc, StringRef Name,
if (!CB.ppMacroUndefined)
return;
- StrAdapter SA(this);
+ StrAdapter SA(*this);
CXIdxMacroUndefinedInfo Info = { getIndexLoc(Loc),
SA.toCStr(Name), 0 };
CB.ppMacroUndefined(ClientData, &Info);
@@ -78,21 +86,21 @@ void IndexingContext::ppMacroExpanded(SourceLocation Loc, StringRef Name,
if (!CB.ppMacroExpanded)
return;
- StrAdapter SA(this);
+ StrAdapter SA(*this);
CXIdxMacroExpandedInfo Info = { getIndexLoc(Loc),
SA.toCStr(Name), 0 };
CB.ppMacroExpanded(ClientData, &Info);
}
void IndexingContext::invokeStartedTranslationUnit() {
- CXIdxContainer idxCont = 0;
+ CXIdxClientContainer idxCont = 0;
if (CB.startedTranslationUnit)
idxCont = CB.startedTranslationUnit(ClientData, 0);
addContainerInMap(Ctx->getTranslationUnitDecl(), idxCont);
}
void IndexingContext::invokeFinishedTranslationUnit() {
- invokeEndedContainer(Ctx->getTranslationUnitDecl());
+ endContainer(Ctx->getTranslationUnitDecl());
}
void IndexingContext::handleDiagnostic(const StoredDiagnostic &StoredDiag) {
@@ -103,197 +111,172 @@ void IndexingContext::handleDiagnostic(const StoredDiagnostic &StoredDiag) {
CB.diagnostic(ClientData, &CXDiag, 0);
}
-void IndexingContext::handleFunction(const FunctionDecl *D) {
- StrAdapter SA(this);
-
- if (D->isFirstDeclaration()) {
- CXIdxEntity idxEntity = 0;
- if (CB.indexFunction) {
- CXIdxEntityInfo EntityInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedEntityInfo IdxEntityInfo;
- getIndexedEntityInfo(D, IdxEntityInfo, EntityInfo, DeclInfo, SA);
- CXIdxFunctionInfo Info = { &IdxEntityInfo,
- D->isThisDeclarationADefinition() };
-
- idxEntity = CB.indexFunction(ClientData, &Info);
- }
+void IndexingContext::handleDecl(const NamedDecl *D,
+ SourceLocation Loc, CXCursor Cursor,
+ bool isRedeclaration, bool isDefinition,
+ DeclInfo &DInfo) {
+ if (!CB.indexDeclaration)
+ return;
- addEntityInMap(D, idxEntity);
+ StrAdapter SA(*this);
+ getEntityInfo(D, DInfo.CXEntInfo, SA);
+ DInfo.entityInfo = &DInfo.CXEntInfo;
+ DInfo.cursor = Cursor;
+ DInfo.loc = getIndexLoc(Loc);
+ DInfo.container = getIndexContainer(D);
+ DInfo.isRedeclaration = isRedeclaration;
+ DInfo.isDefinition = isDefinition;
+
+ CXIdxClientEntity
+ clientEnt = CB.indexDeclaration(ClientData, &DInfo);
+
+ if (!isRedeclaration)
+ addEntityInMap(D, clientEnt);
+}
+
+void IndexingContext::handleObjCContainer(const ObjCContainerDecl *D,
+ SourceLocation Loc, CXCursor Cursor,
+ bool isForwardRef,
+ bool isRedeclaration,
+ bool isImplementation,
+ ObjCContainerDeclInfo &ContDInfo) {
+ ContDInfo.CXObjCContDeclInfo.declInfo = &ContDInfo;
+ if (isForwardRef)
+ ContDInfo.CXObjCContDeclInfo.kind = CXIdxObjCContainer_ForwardRef;
+ else if (isImplementation)
+ ContDInfo.CXObjCContDeclInfo.kind = CXIdxObjCContainer_Implementation;
+ else
+ ContDInfo.CXObjCContDeclInfo.kind = CXIdxObjCContainer_Interface;
- } else {
- if (CB.indexFunctionRedeclaration) {
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedRedeclInfo RedeclInfo;
- getIndexedRedeclInfo(D, RedeclInfo, DeclInfo);
- CXIdxFunctionRedeclInfo Info = { &RedeclInfo,
- D->isThisDeclarationADefinition() };
-
- CB.indexFunctionRedeclaration(ClientData, &Info);
- }
- }
+ handleDecl(D, Loc, Cursor,
+ isRedeclaration, /*isDefinition=*/!isForwardRef, ContDInfo);
}
-void IndexingContext::handleVar(const VarDecl *D) {
- StrAdapter SA(this);
-
- if (D->isFirstDeclaration()) {
- CXIdxEntity idxEntity = 0;
- if (CB.indexVariable) {
- CXIdxEntityInfo EntityInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedEntityInfo IdxEntityInfo;
- getIndexedEntityInfo(D, IdxEntityInfo, EntityInfo, DeclInfo, SA);
- CXIdxVariableInfo Info = { &IdxEntityInfo,
- D->isThisDeclarationADefinition() };
-
- idxEntity = CB.indexVariable(ClientData, &Info);
- }
-
- addEntityInMap(D, idxEntity);
+void IndexingContext::handleFunction(const FunctionDecl *D) {
+ DeclInfo DInfo;
+ handleDecl(D, D->getLocation(), getCursor(D),
+ !D->isFirstDeclaration(), D->isThisDeclarationADefinition(),
+ DInfo);
+}
- } else {
- if (CB.indexVariableRedeclaration) {
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedRedeclInfo RedeclInfo;
- getIndexedRedeclInfo(D, RedeclInfo, DeclInfo);
- CXIdxVariableRedeclInfo Info = { &RedeclInfo,
- D->isThisDeclarationADefinition() };
-
- CB.indexVariableRedeclaration(ClientData, &Info);
- }
- }
+void IndexingContext::handleVar(const VarDecl *D) {
+ DeclInfo DInfo;
+ handleDecl(D, D->getLocation(), getCursor(D),
+ !D->isFirstDeclaration(), D->isThisDeclarationADefinition(),
+ DInfo);
}
void IndexingContext::handleField(const FieldDecl *D) {
- StrAdapter SA(this);
-
- CXIdxEntity idxEntity = 0;
- if (CB.indexTypedef) {
- CXIdxEntityInfo EntityInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedEntityInfo IdxEntityInfo;
- getIndexedEntityInfo(D, IdxEntityInfo, EntityInfo, DeclInfo, SA);
- CXIdxFieldInfo Info = { &IdxEntityInfo };
-
- idxEntity = CB.indexField(ClientData, &Info);
- }
-
- addEntityInMap(D, idxEntity);
+ DeclInfo DInfo;
+ handleDecl(D, D->getLocation(), getCursor(D),
+ /*isRedeclaration=*/false, /*isDefinition=*/false, DInfo);
}
void IndexingContext::handleEnumerator(const EnumConstantDecl *D) {
- StrAdapter SA(this);
-
- CXIdxEntity idxEntity = 0;
- if (CB.indexTypedef) {
- CXIdxEntityInfo EntityInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedEntityInfo IdxEntityInfo;
- getIndexedEntityInfo(D, IdxEntityInfo, EntityInfo, DeclInfo, SA);
- CXIdxEnumeratorInfo Info = { &IdxEntityInfo };
-
- idxEntity = CB.indexEnumerator(ClientData, &Info);
- }
-
- addEntityInMap(D, idxEntity);
+ DeclInfo DInfo;
+ handleDecl(D, D->getLocation(), getCursor(D),
+ /*isRedeclaration=*/false, /*isDefinition=*/true, DInfo);
}
void IndexingContext::handleTagDecl(const TagDecl *D) {
- StrAdapter SA(this);
-
- if (D->isFirstDeclaration()) {
- CXIdxEntity idxEntity = 0;
- if (CB.indexTagType) {
- CXIdxEntityInfo EntityInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedEntityInfo IdxEntityInfo;
- getIndexedEntityInfo(D, IdxEntityInfo, EntityInfo, DeclInfo, SA);
- CXIdxTagTypeInfo Info = { &IdxEntityInfo,
- D->isThisDeclarationADefinition(),
- D->getIdentifier() == 0};
-
- idxEntity = CB.indexTagType(ClientData, &Info);
- }
-
- addEntityInMap(D, idxEntity);
-
- } else {
- if (CB.indexTagTypeRedeclaration) {
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedRedeclInfo RedeclInfo;
- getIndexedRedeclInfo(D, RedeclInfo, DeclInfo);
- CXIdxTagTypeRedeclInfo Info = { &RedeclInfo,
- D->isThisDeclarationADefinition() };
-
- CB.indexTagTypeRedeclaration(ClientData, &Info);
- }
- }
+ TagDeclInfo TagDInfo;
+ TagDInfo.CXTagDeclInfo.declInfo = &TagDInfo;
+ TagDInfo.CXTagDeclInfo.isAnonymous = D->getIdentifier() == 0;
+ handleDecl(D, D->getLocation(), getCursor(D),
+ !D->isFirstDeclaration(), D->isThisDeclarationADefinition(),
+ TagDInfo);
}
void IndexingContext::handleTypedef(const TypedefDecl *D) {
- StrAdapter SA(this);
-
- CXIdxEntity idxEntity = 0;
- if (CB.indexTypedef) {
- CXIdxEntityInfo EntityInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedEntityInfo IdxEntityInfo;
- getIndexedEntityInfo(D, IdxEntityInfo, EntityInfo, DeclInfo, SA);
- CXIdxTypedefInfo Info = { &IdxEntityInfo };
-
- idxEntity = CB.indexTypedef(ClientData, &Info);
- }
+ DeclInfo DInfo;
+ handleDecl(D, D->getLocation(), getCursor(D),
+ !D->isFirstDeclaration(), /*isDefinition=*/true, DInfo);
+}
- addEntityInMap(D, idxEntity);
+void IndexingContext::handleObjCClass(const ObjCClassDecl *D) {
+ ObjCContainerDeclInfo ContDInfo;
+ const ObjCClassDecl::ObjCClassRef *Ref = D->getForwardDecl();
+ ObjCInterfaceDecl *IFaceD = Ref->getInterface();
+ SourceLocation Loc = Ref->getLocation();
+ bool isRedeclaration = IFaceD->getLocation() != Loc;
+ handleObjCContainer(IFaceD, Loc, MakeCursorObjCClassRef(IFaceD, Loc, CXTU),
+ /*isForwardRef=*/true, isRedeclaration,
+ /*isImplementation=*/false, ContDInfo);
}
void IndexingContext::handleObjCInterface(const ObjCInterfaceDecl *D) {
- StrAdapter SA(this);
+ ObjCContainerDeclInfo ContDInfo;
+ handleObjCContainer(D, D->getLocation(), getCursor(D),
+ /*isForwardRef=*/false,
+ /*isRedeclaration=*/D->isInitiallyForwardDecl(),
+ /*isImplementation=*/false, ContDInfo);
+}
- CXIdxEntity idxEntity = 0;
- if (CB.indexObjCClass) {
- CXIdxEntityInfo EntityInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedEntityInfo IdxEntityInfo;
- getIndexedEntityInfo(D, IdxEntityInfo, EntityInfo, DeclInfo, SA);
- CXIdxObjCClassInfo Info = { &IdxEntityInfo,
- D->isForwardDecl() };
+void IndexingContext::handleObjCImplementation(
+ const ObjCImplementationDecl *D) {
+ ObjCContainerDeclInfo ContDInfo;
+ const ObjCInterfaceDecl *Class = D->getClassInterface();
+ handleObjCContainer(Class, D->getLocation(), getCursor(D),
+ /*isForwardRef=*/false,
+ /*isRedeclaration=*/!Class->isImplicitInterfaceDecl(),
+ /*isImplementation=*/true, ContDInfo);
+}
- idxEntity = CB.indexObjCClass(ClientData, &Info);
- }
+void IndexingContext::handleObjCForwardProtocol(const ObjCProtocolDecl *D,
+ SourceLocation Loc,
+ bool isRedeclaration) {
+ ObjCContainerDeclInfo ContDInfo;
+ handleObjCContainer(D, Loc, MakeCursorObjCProtocolRef(D, Loc, CXTU),
+ /*isForwardRef=*/true,
+ isRedeclaration,
+ /*isImplementation=*/false, ContDInfo);
+}
- addEntityInMap(D, idxEntity);
+void IndexingContext::handleObjCProtocol(const ObjCProtocolDecl *D) {
+ ObjCContainerDeclInfo ContDInfo;
+ handleObjCContainer(D, D->getLocation(), getCursor(D),
+ /*isForwardRef=*/false,
+ /*isRedeclaration=*/D->isInitiallyForwardDecl(),
+ /*isImplementation=*/false, ContDInfo);
}
void IndexingContext::defineObjCInterface(const ObjCInterfaceDecl *D) {
if (!CB.defineObjCClass)
return;
- CXIdxObjCBaseClassInfo BaseClass = { getIndexEntity(D->getSuperClass()),
- getIndexLoc(D->getSuperClassLoc()) };
+ StrAdapter SA(*this);
+ CXIdxObjCBaseClassInfo BaseClass;
+ CXIdxEntityInfo BaseEntity;
if (D->getSuperClass()) {
- BaseClass.objcClass = getIndexEntity(D->getSuperClass());
+ getEntityInfo(D->getSuperClass(), BaseEntity, SA);
+ BaseClass.objcClass = &BaseEntity;
BaseClass.loc = getIndexLoc(D->getSuperClassLoc());
}
-
+
SmallVector<CXIdxObjCProtocolRefInfo, 4> ProtInfos;
+ SmallVector<CXIdxEntityInfo, 4> ProtEntities;
ObjCInterfaceDecl::protocol_loc_iterator LI = D->protocol_loc_begin();
for (ObjCInterfaceDecl::protocol_iterator
I = D->protocol_begin(), E = D->protocol_end(); I != E; ++I, ++LI) {
SourceLocation Loc = *LI;
ObjCProtocolDecl *PD = *I;
- CXIdxObjCProtocolRefInfo ProtInfo = { getIndexEntity(PD),
- getIndexLoc(Loc) };
+ ProtEntities.push_back(CXIdxEntityInfo());
+ getEntityInfo(PD, ProtEntities.back(), SA);
+ CXIdxObjCProtocolRefInfo ProtInfo = { 0, getIndexLoc(Loc) };
ProtInfos.push_back(ProtInfo);
}
+
+ for (unsigned i = 0, e = ProtInfos.size(); i != e; ++i)
+ ProtInfos[i].protocol = &ProtEntities[i];
SmallVector<CXIdxObjCProtocolRefInfo *, 4> Prots;
for (unsigned i = 0, e = Prots.size(); i != e; ++i)
Prots.push_back(&ProtInfos[i]);
+ CXIdxEntityInfo ClassEntity;
+ getEntityInfo(D, ClassEntity, SA);
CXIdxObjCClassDefineInfo Info = { getCursor(D),
- getIndexEntity(D),
+ &ClassEntity,
getIndexContainerForDC(D),
D->getSuperClass() ? &BaseClass : 0,
Prots.data(),
@@ -301,88 +284,47 @@ void IndexingContext::defineObjCInterface(const ObjCInterfaceDecl *D) {
CB.defineObjCClass(ClientData, &Info);
}
-void IndexingContext::handleObjCProtocol(const ObjCProtocolDecl *D) {
- StrAdapter SA(this);
-
- CXIdxEntity idxEntity = 0;
- if (CB.indexObjCProtocol) {
- CXIdxEntityInfo EntityInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedEntityInfo IdxEntityInfo;
- getIndexedEntityInfo(D, IdxEntityInfo, EntityInfo, DeclInfo, SA);
- CXIdxObjCProtocolInfo Info = { &IdxEntityInfo,
- D->isForwardDecl() };
-
- idxEntity = CB.indexObjCProtocol(ClientData, &Info);
- }
-
- addEntityInMap(D, idxEntity);
-}
-
void IndexingContext::handleObjCCategory(const ObjCCategoryDecl *D) {
- StrAdapter SA(this);
-
- CXIdxEntity idxEntity = 0;
- if (CB.indexObjCCategory) {
- CXIdxEntityInfo EntityInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedEntityInfo IdxEntityInfo;
- getIndexedEntityInfo(D, IdxEntityInfo, EntityInfo, DeclInfo, SA);
- CXIdxObjCCategoryInfo Info = { &IdxEntityInfo,
- getIndexEntity(D->getClassInterface()) };
-
- idxEntity = CB.indexObjCCategory(ClientData, &Info);
- }
-
- addEntityInMap(D, idxEntity);
+ ObjCCategoryDeclInfo CatDInfo;
+ CXIdxEntityInfo ClassEntity;
+ StrAdapter SA(*this);
+ getEntityInfo(D->getClassInterface(), ClassEntity, SA);
+
+ CatDInfo.CXObjCCatDeclInfo.containerInfo = &CatDInfo.CXObjCContDeclInfo;
+ CatDInfo.CXObjCCatDeclInfo.objcClass = &ClassEntity;
+ handleObjCContainer(D, D->getLocation(), getCursor(D),
+ /*isForwardRef=*/false,
+ /*isRedeclaration=*/false,
+ /*isImplementation=*/false, CatDInfo);
+}
+
+void IndexingContext::handleObjCCategoryImpl(const ObjCCategoryImplDecl *D) {
+ const ObjCCategoryDecl *CatD = D->getCategoryDecl();
+ ObjCCategoryDeclInfo CatDInfo;
+ CXIdxEntityInfo ClassEntity;
+ StrAdapter SA(*this);
+ getEntityInfo(CatD->getClassInterface(), ClassEntity, SA);
+
+ CatDInfo.CXObjCCatDeclInfo.containerInfo = &CatDInfo.CXObjCContDeclInfo;
+ CatDInfo.CXObjCCatDeclInfo.objcClass = &ClassEntity;
+ handleObjCContainer(CatD, D->getLocation(), getCursor(D),
+ /*isForwardRef=*/false,
+ /*isRedeclaration=*/true,
+ /*isImplementation=*/true, CatDInfo);
}
void IndexingContext::handleObjCMethod(const ObjCMethodDecl *D) {
- StrAdapter SA(this);
-
- if (D->isCanonicalDecl()) {
- CXIdxEntity idxEntity = 0;
- if (CB.indexObjCMethod) {
- CXIdxEntityInfo EntityInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedEntityInfo IdxEntityInfo;
- getIndexedEntityInfo(D, IdxEntityInfo, EntityInfo, DeclInfo, SA);
- CXIdxObjCMethodInfo Info = { &IdxEntityInfo,
- D->isThisDeclarationADefinition() };
-
- idxEntity = CB.indexObjCMethod(ClientData, &Info);
- }
-
- addEntityInMap(D, idxEntity);
-
- } else {
- if (CB.indexObjCMethodRedeclaration) {
- CXIdxIndexedRedeclInfo RedeclInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- getIndexedRedeclInfo(D, RedeclInfo, DeclInfo);
- CXIdxObjCMethodRedeclInfo Info = { &RedeclInfo,
- D->isThisDeclarationADefinition() };
-
- CB.indexObjCMethodRedeclaration(ClientData, &Info);
- }
- }
+ DeclInfo DInfo;
+ handleDecl(D, D->getLocation(), getCursor(D),
+ !D->isCanonicalDecl(), D->isThisDeclarationADefinition(),
+ DInfo);
}
void IndexingContext::handleObjCProperty(const ObjCPropertyDecl *D) {
- StrAdapter SA(this);
-
- CXIdxEntity idxEntity = 0;
- if (CB.indexObjCProperty) {
- CXIdxEntityInfo EntityInfo;
- CXIdxIndexedDeclInfo DeclInfo;
- CXIdxIndexedEntityInfo IdxEntityInfo;
- getIndexedEntityInfo(D, IdxEntityInfo, EntityInfo, DeclInfo, SA);
- CXIdxObjCPropertyInfo Info = { &IdxEntityInfo };
-
- idxEntity = CB.indexObjCProperty(ClientData, &Info);
- }
-
- addEntityInMap(D, idxEntity);
+ DeclInfo DInfo;
+ handleDecl(D, D->getLocation(), getCursor(D),
+ /*isRedeclaration=*/false, /*isDefinition=*/false,
+ DInfo);
}
void IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc,
@@ -397,61 +339,45 @@ void IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc,
if (isNotFromSourceFile(D->getLocation()))
return;
+ StrAdapter SA(*this);
CXCursor Cursor = E ? MakeCXCursor(const_cast<Expr*>(E),
const_cast<Decl*>(cast<Decl>(DC)), CXTU)
: getRefCursor(D, Loc);
+ CXIdxEntityInfo RefEntity, ParentEntity;
+ getEntityInfo(D, RefEntity, SA);
+ getEntityInfo(Parent, ParentEntity, SA);
CXIdxEntityRefInfo Info = { Cursor,
getIndexLoc(Loc),
- getIndexEntity(D),
- getIndexEntity(Parent),
+ &RefEntity,
+ &ParentEntity,
getIndexContainerForDC(DC),
Kind };
CB.indexEntityReference(ClientData, &Info);
}
-void IndexingContext::invokeStartedStatementBody(const NamedDecl *D,
- const DeclContext *DC) {
- const Stmt *Body = cast<Decl>(DC)->getBody();
- assert(Body);
-
- CXIdxContainer idxCont = 0;
- if (CB.startedStatementBody) {
- CXIdxContainerInfo ContainerInfo;
- getContainerInfo(D, ContainerInfo);
- CXIdxStmtBodyInfo Info = { &ContainerInfo,
- getIndexLoc(Body->getLocStart()) };
-
- idxCont = CB.startedStatementBody(ClientData, &Info);
- }
- addContainerInMap(DC, idxCont);
-}
-
-void IndexingContext::invokeStartedTagTypeDefinition(const TagDecl *D) {
- CXIdxContainer idxCont = 0;
- if (CB.startedTagTypeDefinition) {
- CXIdxContainerInfo ContainerInfo;
- getContainerInfo(D, ContainerInfo);
- CXIdxTagTypeDefinitionInfo Info = { &ContainerInfo };
-
- idxCont = CB.startedTagTypeDefinition(ClientData, &Info);
- }
- addContainerInMap(D, idxCont);
-}
+void IndexingContext::startContainer(const NamedDecl *D, bool isStmtBody,
+ const DeclContext *DC) {
+ if (!CB.startedContainer)
+ return;
-void IndexingContext::invokeStartedObjCContainer(const ObjCContainerDecl *D) {
- CXIdxContainer idxCont = 0;
- if (CB.startedObjCContainer) {
- CXIdxContainerInfo ContainerInfo;
- getContainerInfo(D, ContainerInfo);
- CXIdxObjCContainerInfo Info = { &ContainerInfo };
+ if (!DC)
+ DC = cast<DeclContext>(D);
+
+ StrAdapter SA(*this);
+ CXIdxEntityInfo Entity;
+ getEntityInfo(D, Entity, SA);
+ CXIdxContainerInfo Info;
+ Info.entity = &Entity;
+ Info.cursor = getCursor(D);
+ Info.loc = getIndexLoc(D->getLocation());
+ Info.isObjCImpl = isa<ObjCImplDecl>(D);
- idxCont = CB.startedObjCContainer(ClientData, &Info);
- }
- addContainerInMap(D, idxCont);
+ CXIdxClientContainer clientCont = CB.startedContainer(ClientData, &Info);
+ addContainerInMap(DC, clientCont);
}
-void IndexingContext::invokeEndedContainer(const DeclContext *DC) {
+void IndexingContext::endContainer(const DeclContext *DC) {
if (CB.endedContainer) {
CXIdxEndContainerInfo Info = { getIndexContainerForDC(DC),
getIndexLoc(cast<Decl>(DC)->getLocEnd()) };
@@ -469,7 +395,7 @@ bool IndexingContext::isNotFromSourceFile(SourceLocation Loc) const {
}
void IndexingContext::addContainerInMap(const DeclContext *DC,
- CXIdxContainer container) {
+ CXIdxClientContainer container) {
assert(getScopedContext(DC) == DC);
ContainerMapTy::iterator I = ContainerMap.find(DC);
if (I == ContainerMap.end()) {
@@ -485,7 +411,8 @@ void IndexingContext::addContainerInMap(const DeclContext *DC,
ContainerMap.erase(I);
}
-void IndexingContext::addEntityInMap(const NamedDecl *D, CXIdxEntity entity) {
+void IndexingContext::addEntityInMap(const NamedDecl *D,
+ CXIdxClientEntity entity) {
assert(getEntityDecl(D) == D &&
"Tried to add a non-entity (canonical) decl");
assert(EntityMap.find(D) == EntityMap.end());
@@ -493,7 +420,7 @@ void IndexingContext::addEntityInMap(const NamedDecl *D, CXIdxEntity entity) {
EntityMap[D] = entity;
}
-CXIdxEntity IndexingContext::getIndexEntity(const NamedDecl *D) {
+CXIdxClientEntity IndexingContext::getClientEntity(const NamedDecl *D) {
if (!D)
return 0;
D = getEntityDecl(D);
@@ -506,9 +433,9 @@ CXIdxEntity IndexingContext::getIndexEntity(const NamedDecl *D) {
return 0;
}
- StrAdapter SA(this);
+ StrAdapter SA(*this);
- CXIdxEntity idxEntity = 0;
+ CXIdxClientEntity idxEntity = 0;
if (CB.importedEntity) {
CXIdxEntityInfo EntityInfo;
getEntityInfo(D, EntityInfo, SA);
@@ -562,7 +489,7 @@ IndexingContext::getScopedContext(const DeclContext *DC) const {
return DC->getRedeclContext();
}
-CXIdxContainer
+CXIdxClientContainer
IndexingContext::getIndexContainerForDC(const DeclContext *DC) const {
DC = getScopedContext(DC);
ContainerMapTy::const_iterator I = ContainerMap.find(DC);
@@ -571,19 +498,15 @@ IndexingContext::getIndexContainerForDC(const DeclContext *DC) const {
return I->second;
}
-CXIdxFile IndexingContext::getIndexFile(const FileEntry *File) {
+CXIdxClientFile IndexingContext::getIndexFile(const FileEntry *File) {
if (!File)
return 0;
- if (!CB.recordFile)
- return 0;
FileMapTy::iterator FI = FileMap.find(File);
if (FI != FileMap.end())
return FI->second;
- CXIdxFile idxFile = CB.recordFile(ClientData, (CXFile)File, 0);
- FileMap[File] = idxFile;
- return idxFile;
+ return 0;
}
CXIdxLoc IndexingContext::getIndexLoc(SourceLocation Loc) const {
@@ -597,7 +520,7 @@ CXIdxLoc IndexingContext::getIndexLoc(SourceLocation Loc) const {
}
void IndexingContext::translateLoc(SourceLocation Loc,
- CXIdxFile *indexFile, CXFile *file,
+ CXIdxClientFile *indexFile, CXFile *file,
unsigned *line, unsigned *column,
unsigned *offset) {
if (Loc.isInvalid())
@@ -626,47 +549,59 @@ void IndexingContext::translateLoc(SourceLocation Loc,
*offset = FileOffset;
}
-void IndexingContext::getIndexedEntityInfo(const NamedDecl *D,
- CXIdxIndexedEntityInfo &IdxEntityInfo,
- CXIdxEntityInfo &EntityInfo,
- CXIdxIndexedDeclInfo &IdxDeclInfo,
- StrAdapter &SA) {
- getEntityInfo(D, EntityInfo, SA);
- getIndexedDeclInfo(D, IdxDeclInfo);
- IdxEntityInfo.entityInfo = &EntityInfo;
- IdxEntityInfo.declInfo = &IdxDeclInfo;
-}
-
-void IndexingContext::getIndexedDeclInfo(const NamedDecl *D,
- CXIdxIndexedDeclInfo &IdxDeclInfo) {
- IdxDeclInfo.cursor = getCursor(D);
- IdxDeclInfo.loc = getIndexLoc(D->getLocation());
- IdxDeclInfo.container = getIndexContainer(D);
-}
-
-void IndexingContext::getIndexedRedeclInfo(const NamedDecl *D,
- CXIdxIndexedRedeclInfo &RedeclInfo,
- CXIdxIndexedDeclInfo &IdxDeclInfo) {
- getIndexedDeclInfo(D, IdxDeclInfo);
- RedeclInfo.declInfo = &IdxDeclInfo;
- RedeclInfo.entity = getIndexEntity(D);
-}
+void IndexingContext::getEntityInfo(const NamedDecl *D,
+ CXIdxEntityInfo &EntityInfo,
+ StrAdapter &SA) {
+ D = getEntityDecl(D);
+ EntityInfo.kind = CXIdxEntity_Unexposed;
+ EntityInfo.clientEntity = getClientEntity(D);
+
+ if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
+ switch (TD->getTagKind()) {
+ case TTK_Struct:
+ EntityInfo.kind = CXIdxEntity_Struct; break;
+ case TTK_Union:
+ EntityInfo.kind = CXIdxEntity_Union; break;
+ case TTK_Class:
+ EntityInfo.kind = CXIdxEntity_CXXClass; break;
+ case TTK_Enum:
+ EntityInfo.kind = CXIdxEntity_Enum; break;
+ }
-void IndexingContext::getContainerInfo(const NamedDecl *D,
- CXIdxContainerInfo &ContainerInfo) {
- ContainerInfo.cursor = getCursor(D);
- ContainerInfo.loc = getIndexLoc(D->getLocation());
- ContainerInfo.entity = getIndexEntity(D);
-}
+ } else {
+ switch (D->getKind()) {
+ case Decl::Typedef:
+ EntityInfo.kind = CXIdxEntity_Typedef; break;
+ case Decl::Function:
+ EntityInfo.kind = CXIdxEntity_Function; break;
+ case Decl::Var:
+ EntityInfo.kind = CXIdxEntity_Variable; break;
+ case Decl::Field:
+ EntityInfo.kind = CXIdxEntity_Field; break;
+ case Decl::EnumConstant:
+ EntityInfo.kind = CXIdxEntity_EnumConstant; break;
+ case Decl::ObjCInterface:
+ EntityInfo.kind = CXIdxEntity_ObjCClass; break;
+ case Decl::ObjCProtocol:
+ EntityInfo.kind = CXIdxEntity_ObjCProtocol; break;
+ case Decl::ObjCCategory:
+ EntityInfo.kind = CXIdxEntity_ObjCCategory; break;
+ case Decl::ObjCMethod:
+ EntityInfo.kind = CXIdxEntity_ObjCMethod; break;
+ case Decl::ObjCProperty:
+ EntityInfo.kind = CXIdxEntity_ObjCProperty; break;
+ case Decl::ObjCIvar:
+ EntityInfo.kind = CXIdxEntity_ObjCIvar; break;
+ default:
+ break;
+ }
+ }
-void IndexingContext::getEntityInfo(const NamedDecl *D,
- CXIdxEntityInfo &EntityInfo,
- StrAdapter &SA) {
if (IdentifierInfo *II = D->getIdentifier()) {
EntityInfo.name = SA.toCStr(II->getName());
} else if (isa<RecordDecl>(D) || isa<NamespaceDecl>(D)) {
- EntityInfo.name = 0;
+ EntityInfo.name = 0; // anonymous record/namespace.
} else {
unsigned Begin = SA.getCurSize();
@@ -677,12 +612,14 @@ void IndexingContext::getEntityInfo(const NamedDecl *D,
EntityInfo.name = SA.getCStr(Begin);
}
- unsigned Begin = SA.getCurSize();
- bool Ignore = getDeclCursorUSR(D, SA.getBuffer());
- if (Ignore) {
- EntityInfo.USR = "";
- } else {
- EntityInfo.USR = SA.getCStr(Begin);
+ {
+ unsigned Begin = SA.getCurSize();
+ bool Ignore = getDeclCursorUSR(D, SA.getBuffer());
+ if (Ignore) {
+ EntityInfo.USR = "";
+ } else {
+ EntityInfo.USR = SA.getCStr(Begin);
+ }
}
}
diff --git a/clang/tools/libclang/IndexingContext.h b/clang/tools/libclang/IndexingContext.h
index d69f1c8eaa9..8d5f56609f0 100644
--- a/clang/tools/libclang/IndexingContext.h
+++ b/clang/tools/libclang/IndexingContext.h
@@ -17,10 +17,27 @@
namespace clang {
class FileEntry;
class ObjCPropertyDecl;
+ class ObjCClassDecl;
namespace cxindex {
class IndexingContext;
+struct DeclInfo : public CXIdxDeclInfo {
+ CXIdxEntityInfo CXEntInfo;
+};
+
+struct TagDeclInfo : public DeclInfo {
+ CXIdxTagDeclInfo CXTagDeclInfo;
+};
+
+struct ObjCContainerDeclInfo : public DeclInfo {
+ CXIdxObjCContainerDeclInfo CXObjCContDeclInfo;
+};
+
+struct ObjCCategoryDeclInfo : public ObjCContainerDeclInfo {
+ CXIdxObjCCategoryDeclInfo CXObjCCatDeclInfo;
+};
+
class IndexingContext {
ASTContext *Ctx;
CXClientData ClientData;
@@ -28,10 +45,10 @@ class IndexingContext {
unsigned IndexOptions;
CXTranslationUnit CXTU;
- typedef llvm::DenseMap<const FileEntry *, CXIdxFile> FileMapTy;
- typedef llvm::DenseMap<const NamedDecl *, CXIdxEntity> EntityMapTy;
- typedef llvm::DenseMap<const void *, CXIdxMacro> MacroMapTy;
- typedef llvm::DenseMap<const DeclContext *, CXIdxContainer> ContainerMapTy;
+ typedef llvm::DenseMap<const FileEntry *, CXIdxClientFile> FileMapTy;
+ typedef llvm::DenseMap<const NamedDecl *, CXIdxClientEntity> EntityMapTy;
+ typedef llvm::DenseMap<const void *, CXIdxClientMacro> MacroMapTy;
+ typedef llvm::DenseMap<const DeclContext *, CXIdxClientContainer> ContainerMapTy;
FileMapTy FileMap;
EntityMapTy EntityMap;
MacroMapTy MacroMap;
@@ -40,14 +57,23 @@ class IndexingContext {
SmallVector<DeclGroupRef, 8> TUDeclsInObjCContainer;
llvm::SmallString<256> StrScratch;
+ unsigned StrAdapterCount;
class StrAdapter {
llvm::SmallString<256> &Scratch;
+ IndexingContext &IdxCtx;
public:
- StrAdapter(IndexingContext *indexCtx)
- : Scratch(indexCtx->StrScratch) {}
- ~StrAdapter() { Scratch.clear(); }
+ StrAdapter(IndexingContext &indexCtx)
+ : Scratch(indexCtx.StrScratch), IdxCtx(indexCtx) {
+ ++IdxCtx.StrAdapterCount;
+ }
+
+ ~StrAdapter() {
+ --IdxCtx.StrAdapterCount;
+ if (IdxCtx.StrAdapterCount == 0)
+ Scratch.clear();
+ }
const char *toCStr(StringRef Str);
@@ -65,12 +91,14 @@ public:
IndexingContext(CXClientData clientData, IndexerCallbacks &indexCallbacks,
unsigned indexOptions, CXTranslationUnit cxTU)
: Ctx(0), ClientData(clientData), CB(indexCallbacks),
- IndexOptions(indexOptions), CXTU(cxTU) { }
+ IndexOptions(indexOptions), CXTU(cxTU), StrAdapterCount(0) { }
ASTContext &getASTContext() const { return *Ctx; }
void setASTContext(ASTContext &ctx);
+ void enteredMainFile(const FileEntry *File);
+
void ppIncludedFile(SourceLocation hashLoc,
StringRef filename, const FileEntry *File,
bool isImport, bool isAngled);
@@ -117,13 +145,20 @@ public:
void handleTypedef(const TypedefDecl *D);
+ void handleObjCClass(const ObjCClassDecl *D);
void handleObjCInterface(const ObjCInterfaceDecl *D);
+ void handleObjCImplementation(const ObjCImplementationDecl *D);
void defineObjCInterface(const ObjCInterfaceDecl *D);
+ void handleObjCForwardProtocol(const ObjCProtocolDecl *D,
+ SourceLocation Loc,
+ bool isRedeclaration);
+
void handleObjCProtocol(const ObjCProtocolDecl *D);
void handleObjCCategory(const ObjCCategoryDecl *D);
+ void handleObjCCategoryImpl(const ObjCCategoryImplDecl *D);
void handleObjCMethod(const ObjCMethodDecl *D);
@@ -135,13 +170,10 @@ public:
const Expr *E = 0,
CXIdxEntityRefKind Kind = CXIdxEntityRef_Direct);
- void invokeStartedTagTypeDefinition(const TagDecl *D);
-
- void invokeStartedStatementBody(const NamedDecl *D, const DeclContext *DC);
+ void startContainer(const NamedDecl *D, bool isStmtBody = false,
+ const DeclContext *DC = 0);
- void invokeStartedObjCContainer(const ObjCContainerDecl *D);
-
- void invokeEndedContainer(const DeclContext *DC);
+ void endContainer(const DeclContext *DC);
bool isNotFromSourceFile(SourceLocation Loc) const;
@@ -152,45 +184,41 @@ public:
TUDeclsInObjCContainer.push_back(DG);
}
- void translateLoc(SourceLocation Loc, CXIdxFile *indexFile, CXFile *file,
+ void translateLoc(SourceLocation Loc, CXIdxClientFile *indexFile, CXFile *file,
unsigned *line, unsigned *column, unsigned *offset);
private:
- void addEntityInMap(const NamedDecl *D, CXIdxEntity entity);
+ void handleDecl(const NamedDecl *D,
+ SourceLocation Loc, CXCursor Cursor,
+ bool isRedeclaration, bool isDefinition,
+ DeclInfo &DInfo);
+
+ void handleObjCContainer(const ObjCContainerDecl *D,
+ SourceLocation Loc, CXCursor Cursor,
+ bool isForwardRef,
+ bool isRedeclaration,
+ bool isImplementation,
+ ObjCContainerDeclInfo &ContDInfo);
- void addContainerInMap(const DeclContext *DC, CXIdxContainer container);
+ void addEntityInMap(const NamedDecl *D, CXIdxClientEntity entity);
- CXIdxEntity getIndexEntity(const NamedDecl *D);
+ void addContainerInMap(const DeclContext *DC, CXIdxClientContainer container);
+
+ CXIdxClientEntity getClientEntity(const NamedDecl *D);
const NamedDecl *getEntityDecl(const NamedDecl *D) const;
- CXIdxContainer getIndexContainer(const NamedDecl *D) const {
+ CXIdxClientContainer getIndexContainer(const NamedDecl *D) const {
return getIndexContainerForDC(D->getDeclContext());
}
const DeclContext *getScopedContext(const DeclContext *DC) const;
- CXIdxContainer getIndexContainerForDC(const DeclContext *DC) const;
+ CXIdxClientContainer getIndexContainerForDC(const DeclContext *DC) const;
- CXIdxFile getIndexFile(const FileEntry *File);
+ CXIdxClientFile getIndexFile(const FileEntry *File);
CXIdxLoc getIndexLoc(SourceLocation Loc) const;
- void getIndexedEntityInfo(const NamedDecl *D,
- CXIdxIndexedEntityInfo &IdxEntityInfo,
- CXIdxEntityInfo &EntityInfo,
- CXIdxIndexedDeclInfo &IdxDeclInfo,
- StrAdapter &SA);
-
- void getIndexedDeclInfo(const NamedDecl *D,
- CXIdxIndexedDeclInfo &IdxDeclInfo);
-
- void getIndexedRedeclInfo(const NamedDecl *D,
- CXIdxIndexedRedeclInfo &RedeclInfo,
- CXIdxIndexedDeclInfo &IdxDeclInfo);
-
- void getContainerInfo(const NamedDecl *D,
- CXIdxContainerInfo &ContainerInfo);
-
void getEntityInfo(const NamedDecl *D,
CXIdxEntityInfo &EntityInfo,
StrAdapter &SA);
diff --git a/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports
index a82bd999d58..b644baa4d9e 100644
--- a/clang/tools/libclang/libclang.exports
+++ b/clang/tools/libclang/libclang.exports
@@ -135,6 +135,12 @@ clang_getTranslationUnitSpelling
clang_getTypeDeclaration
clang_getTypeKindSpelling
clang_hashCursor
+clang_index_getObjCCategoryDeclInfo
+clang_index_getObjCContainerDeclInfo
+clang_index_getTagDeclInfo
+clang_index_isEntityObjCCategoryKind
+clang_index_isEntityObjCContainerKind
+clang_index_isEntityTagKind
clang_indexLoc_getCXSourceLocation
clang_indexLoc_getFileLocation
clang_indexTranslationUnit
OpenPOWER on IntegriCloud