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/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 75100ec..f5828fc 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -1003,9 +1003,19 @@
return NULL;
}
+void ObjCProtocolDecl::allocateDefinitionData() {
+ assert(!Data && "Protocol already has a definition!");
+ Data = new (getASTContext()) DefinitionData;
+}
+
+void ObjCProtocolDecl::startDefinition() {
+ allocateDefinitionData();
+}
+
void ObjCProtocolDecl::completedForwardDecl() {
- assert(isForwardDecl() && "Only valid to call for forward refs");
+ assert(!hasDefinition() && "Only valid to call for forward refs");
isForwardProtoDecl = false;
+ startDefinition();
if (ASTMutationListener *L = getASTContext().getASTMutationListener())
L->CompletedObjCForwardRef(this);
}