Move the data that corresponds to the definition of a protocol into a
separately-allocated DefinitionData structure. Introduce various
functions that will help with the separation of declarations from
definitions (isThisDeclarationADefinition(), hasDefinition(),
getDefinition()).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147408 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 33feadf..f2e6b01 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -4126,8 +4126,8 @@
return clang_getNullCursor();
case Decl::ObjCProtocol:
- if (!cast<ObjCProtocolDecl>(D)->isForwardDecl())
- return C;
+ if (ObjCProtocolDecl *Def = cast<ObjCProtocolDecl>(D)->getDefinition())
+ return MakeCXCursor(Def, TU);
return clang_getNullCursor();
case Decl::ObjCInterface: {
diff --git a/tools/libclang/IndexDecl.cpp b/tools/libclang/IndexDecl.cpp
index 3886813..ee37bba 100644
--- a/tools/libclang/IndexDecl.cpp
+++ b/tools/libclang/IndexDecl.cpp
@@ -102,7 +102,7 @@
bool VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
// Forward decls are handled at VisitObjCForwardProtocolDecl.
- if (D->isForwardDecl())
+ if (!D->isThisDeclarationADefinition())
return true;
IndexCtx.handleObjCProtocol(D);
diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp
index 49dfa05..28efe3f 100644
--- a/tools/libclang/IndexingContext.cpp
+++ b/tools/libclang/IndexingContext.cpp
@@ -368,8 +368,9 @@
}
ObjCProtocolList EmptyProtoList;
- ObjCProtocolListInfo ProtInfo(D->hasDefinition() ? D->getReferencedProtocols()
- : EmptyProtoList,
+ ObjCProtocolListInfo ProtInfo(D->isThisDeclarationADefinition()
+ ? D->getReferencedProtocols()
+ : EmptyProtoList,
*this, SA);
ObjCInterfaceDeclInfo InterInfo(D);
@@ -401,7 +402,11 @@
bool IndexingContext::handleObjCProtocol(const ObjCProtocolDecl *D) {
ScratchAlloc SA(*this);
- ObjCProtocolListInfo ProtListInfo(D->getReferencedProtocols(), *this, SA);
+ ObjCProtocolList EmptyProtoList;
+ ObjCProtocolListInfo ProtListInfo(D->isThisDeclarationADefinition()
+ ? D->getReferencedProtocols()
+ : EmptyProtoList,
+ *this, SA);
ObjCProtocolDeclInfo ProtInfo(D);
ProtInfo.ObjCProtoRefListInfo = ProtListInfo.getListInfo();