summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang/IndexingContext.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-16 02:35:05 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-16 02:35:05 +0000
commitdf15c209799f6f1a557ebe55916fa36407b09551 (patch)
tree5b17cdcc55071f2677e83b64c3abded2bdf718fa /clang/tools/libclang/IndexingContext.cpp
parentd7b8790003fb06796fb4d34284fdb5f7bed23acf (diff)
downloadbcm5719-llvm-df15c209799f6f1a557ebe55916fa36407b09551.tar.gz
bcm5719-llvm-df15c209799f6f1a557ebe55916fa36407b09551.zip
[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. llvm-svn: 144765
Diffstat (limited to 'clang/tools/libclang/IndexingContext.cpp')
-rw-r--r--clang/tools/libclang/IndexingContext.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/clang/tools/libclang/IndexingContext.cpp b/clang/tools/libclang/IndexingContext.cpp
index 3ecc560d350..890336e3ac0 100644
--- a/clang/tools/libclang/IndexingContext.cpp
+++ b/clang/tools/libclang/IndexingContext.cpp
@@ -259,11 +259,22 @@ void IndexingContext::handleObjCCategoryImpl(const ObjCCategoryImplDecl *D) {
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 @@ CXIdxClientContainer
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;
OpenPOWER on IntegriCloud