summaryrefslogtreecommitdiffstats
path: root/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-12-15 18:03:09 +0000
committerDouglas Gregor <dgregor@apple.com>2011-12-15 18:03:09 +0000
commit53df7a1d34f21d8f2309311d1067d463e9064c60 (patch)
treec656cd7d7c1bd60325bd76cf1cae70defd8f970c /lib/Serialization/ASTWriter.cpp
parent7ab8ef99e6b9064861b8d786a40560d74f96b421 (diff)
Introduce the core infrastructure needed to model a complete
redeclaration chain for Objective-C classes, including: - Using the first declaration as the canonical declaration. - Using the definition as the primary DeclContext - Making sure that all declarations have a pointer to the definition data, and the definition knows that it is the definition. - Serialization support for when a definition gets added to a declaration that comes from an AST file. However, note that we're not taking advantage of much of this code yet, because we're still re-using ObjCInterfaceDecls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146667 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r--lib/Serialization/ASTWriter.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 6cce0afc50..b3f76f7494 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -3439,6 +3439,7 @@ void ASTWriter::ResolveDeclUpdatesBlocks() {
case UPD_CXX_ADDED_IMPLICIT_MEMBER:
case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION:
case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE:
+ case UPD_OBJC_SET_CLASS_DEFINITIONDATA:
URec[Idx] = GetDeclRef(reinterpret_cast<Decl *>(URec[Idx]));
++Idx;
break;
@@ -4379,10 +4380,26 @@ void ASTWriter::AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
void ASTWriter::CompletedObjCForwardRef(const ObjCContainerDecl *D) {
assert(!WritingAST && "Already writing the AST!");
- if (!D->isFromASTFile())
- return; // Declaration not imported from PCH.
+ if (D->isFromASTFile())
+ RewriteDecl(D);
- RewriteDecl(D);
+ if (const ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
+ for (ObjCInterfaceDecl::redecl_iterator I = ID->redecls_begin(),
+ E = ID->redecls_end();
+ I != E; ++I) {
+ if (*I == ID)
+ continue;
+
+ // We are interested when a PCH decl is modified.
+ if (I->isFromASTFile()) {
+ UpdateRecord &Record = DeclUpdates[*I];
+ Record.push_back(UPD_OBJC_SET_CLASS_DEFINITIONDATA);
+ assert((*I)->hasDefinition());
+ assert((*I)->getDefinition() == D);
+ Record.push_back(reinterpret_cast<uint64_t>(D)); // the DefinitionDecl
+ }
+ }
+ }
}
void ASTWriter::AddedObjCPropertyInClassExtension(const ObjCPropertyDecl *Prop,