[cfe-commits] r144765 - in /cfe/trunk/tools: c-index-test/c-index-test.c libclang/IndexingContext.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Nov 15 18:35:05 PST 2011
Author: akirtzidis
Date: Tue Nov 15 20:35:05 2011
New Revision: 144765
URL: http://llvm.org/viewvc/llvm-project?rev=144765&view=rev
Log:
[libclang] Indexing API: fill the objc category info for a category implementation and
do not crash if no client container is registered for a declaration context.
Modified:
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/IndexingContext.cpp
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=144765&r1=144764&r2=144765&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Nov 15 20:35:05 2011
@@ -1610,7 +1610,10 @@
}
static void printCXIndexContainer(CXIdxClientContainer container) {
- printf("[%s]", (const char *)container);
+ if (!container)
+ printf("[<<NULL>>]");
+ else
+ printf("[%s]", (const char *)container);
}
static const char *getEntityKindString(CXIdxEntityKind kind) {
Modified: cfe/trunk/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.cpp?rev=144765&r1=144764&r2=144765&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.cpp (original)
+++ cfe/trunk/tools/libclang/IndexingContext.cpp Tue Nov 15 20:35:05 2011
@@ -259,11 +259,22 @@
ObjCCategoryDeclInfo CatDInfo(/*isImplementation=*/true);
CXIdxEntityInfo ClassEntity;
StrAdapter SA(*this);
- getEntityInfo(CatD->getClassInterface(), ClassEntity, SA);
+ const ObjCInterfaceDecl *IFaceD = CatD->getClassInterface();
+ SourceLocation ClassLoc = D->getLocation();
+ SourceLocation CategoryLoc = ClassLoc; //FIXME: D->getCategoryNameLoc();
+ getEntityInfo(IFaceD, ClassEntity, SA);
CatDInfo.ObjCCatDeclInfo.containerInfo = &CatDInfo.ObjCContDeclInfo;
- CatDInfo.ObjCCatDeclInfo.objcClass = &ClassEntity;
- handleObjCContainer(D, D->getLocation(), getCursor(D), CatDInfo);
+ if (IFaceD) {
+ CatDInfo.ObjCCatDeclInfo.objcClass = &ClassEntity;
+ CatDInfo.ObjCCatDeclInfo.classCursor =
+ MakeCursorObjCClassRef(IFaceD, ClassLoc, CXTU);
+ } else {
+ CatDInfo.ObjCCatDeclInfo.objcClass = 0;
+ CatDInfo.ObjCCatDeclInfo.classCursor = clang_getNullCursor();
+ }
+ CatDInfo.ObjCCatDeclInfo.classLoc = getIndexLoc(ClassLoc);
+ handleObjCContainer(D, CategoryLoc, getCursor(D), CatDInfo);
}
void IndexingContext::handleObjCMethod(const ObjCMethodDecl *D) {
@@ -402,6 +413,8 @@
IndexingContext::getIndexContainerForDC(const DeclContext *DC) const {
DC = getScopedContext(DC);
ContainerMapTy::const_iterator I = ContainerMap.find(DC);
+ if (I == ContainerMap.end())
+ return 0;
// assert(I != ContainerMap.end() &&
// "Failed to include a scoped context in the container map");
return I->second;
More information about the cfe-commits
mailing list