]> granicus.if.org Git - clang/commitdiff
[libclang] Indexing API: Provide the protocols list for objc categories as well.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 13 Dec 2011 18:47:45 +0000 (18:47 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 13 Dec 2011 18:47:45 +0000 (18:47 +0000)
rdar://10573361

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146498 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang-c/Index.h
tools/libclang/Indexing.cpp
tools/libclang/IndexingContext.cpp
tools/libclang/IndexingContext.h

index 8b0aed17a63797c3715f0cb4e93ddf966c5d9a45..9da6b2370f7f37486e8d36365ce9d4a8c9969245 100644 (file)
@@ -4238,13 +4238,6 @@ typedef struct {
   CXIdxObjCContainerKind kind;
 } CXIdxObjCContainerDeclInfo;
 
-typedef struct {
-  const CXIdxObjCContainerDeclInfo *containerInfo;
-  const CXIdxEntityInfo *objcClass;
-  CXCursor classCursor;
-  CXIdxLoc classLoc;
-} CXIdxObjCCategoryDeclInfo;
-
 typedef struct {
   const CXIdxEntityInfo *base;
   CXCursor cursor;
@@ -4268,6 +4261,14 @@ typedef struct {
   const CXIdxObjCProtocolRefListInfo *protocols;
 } CXIdxObjCInterfaceDeclInfo;
 
+typedef struct {
+  const CXIdxObjCContainerDeclInfo *containerInfo;
+  const CXIdxEntityInfo *objcClass;
+  CXCursor classCursor;
+  CXIdxLoc classLoc;
+  const CXIdxObjCProtocolRefListInfo *protocols;
+} CXIdxObjCCategoryDeclInfo;
+
 typedef struct {
   const CXIdxDeclInfo *declInfo;
   const CXIdxBaseClassInfo *const *bases;
index 50c37bc51fdfc253d4e7096d5815ed9f3ca7aaa5..630c55bb335f147a869337ecc756f38544048bbf 100644 (file)
@@ -583,6 +583,9 @@ clang_index_getObjCProtocolRefListInfo(const CXIdxDeclInfo *DInfo) {
         ProtInfo = dyn_cast<ObjCProtocolDeclInfo>(DI))
     return &ProtInfo->ObjCProtoRefListInfo;
 
+  if (const ObjCCategoryDeclInfo *CatInfo = dyn_cast<ObjCCategoryDeclInfo>(DI))
+    return CatInfo->ObjCCatDeclInfo.protocols;
+
   return 0;
 }
 
index 66e552c8f47f37479a157e59b03ea73eb61b6a1e..812669397d47bc05bd6816da59d1acc0dcf1b764 100644 (file)
@@ -383,6 +383,8 @@ bool IndexingContext::handleObjCCategory(const ObjCCategoryDecl *D) {
   if (suppressRefs())
     markEntityOccurrenceInFile(IFaceD, ClassLoc);
 
+  ObjCProtocolListInfo ProtInfo(D->getReferencedProtocols(), *this, SA);
+  
   CatDInfo.ObjCCatDeclInfo.containerInfo = &CatDInfo.ObjCContDeclInfo;
   if (IFaceD) {
     CatDInfo.ObjCCatDeclInfo.objcClass = &ClassEntity;
@@ -393,6 +395,9 @@ bool IndexingContext::handleObjCCategory(const ObjCCategoryDecl *D) {
     CatDInfo.ObjCCatDeclInfo.classCursor = clang_getNullCursor();
   }
   CatDInfo.ObjCCatDeclInfo.classLoc = getIndexLoc(ClassLoc);
+  CatDInfo.ObjCProtoListInfo = ProtInfo.getListInfo();
+  CatDInfo.ObjCCatDeclInfo.protocols = &CatDInfo.ObjCProtoListInfo;
+
   return handleObjCContainer(D, CategoryLoc, getCursor(D), CatDInfo);
 }
 
@@ -416,6 +421,8 @@ bool IndexingContext::handleObjCCategoryImpl(const ObjCCategoryImplDecl *D) {
     CatDInfo.ObjCCatDeclInfo.classCursor = clang_getNullCursor();
   }
   CatDInfo.ObjCCatDeclInfo.classLoc = getIndexLoc(ClassLoc);
+  CatDInfo.ObjCCatDeclInfo.protocols = 0;
+
   return handleObjCContainer(D, CategoryLoc, getCursor(D), CatDInfo);
 }
 
index 1ad1d809eeb05153ad2c2174b7c3b3e70a82e13a..b9234d88b3faf45af6e02647ba51f9e3c34092e5 100644 (file)
@@ -149,6 +149,7 @@ struct ObjCProtocolDeclInfo : public ObjCContainerDeclInfo {
 
 struct ObjCCategoryDeclInfo : public ObjCContainerDeclInfo {
   CXIdxObjCCategoryDeclInfo ObjCCatDeclInfo;
+  CXIdxObjCProtocolRefListInfo ObjCProtoListInfo;
 
   explicit ObjCCategoryDeclInfo(bool isImplementation)
     : ObjCContainerDeclInfo(Info_ObjCCategory,