diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-27 01:47:08 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-27 01:47:08 +0000 |
commit | cff9f26ce0ed76d555cd33b3dca84dd5cdf376af (patch) | |
tree | 6186247a39adb73209e02819b1d3078a7ec00dde /lib/Serialization/ASTWriterDecl.cpp | |
parent | 6895a644ca9df03af14ad06deaa950a09dd352d2 (diff) |
Reimplement (de-)serialization of Objective-C categories to eliminate
the direct serialization of the linked-list structure. Instead, use a
scheme similar to how we handle redeclarations, with redeclaration
lists on the side. This addresses several issues:
- In cases involving mixing and matching of many categories across
many modules, the linked-list structure would not be consistent
across different modules, and categories would get lost.
- If a module is loaded after the class definition and its other
categories have already been loaded, we wouldn't see any categories
in the newly-loaded module.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149112 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r-- | lib/Serialization/ASTWriterDecl.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index a6fae4f20d..404eb88f59 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -481,7 +481,14 @@ void ASTDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) { P != PEnd; ++P) Writer.AddDeclRef(*P, Record); - Writer.AddDeclRef(D->getCategoryList(), Record); + if (ObjCCategoryDecl *Cat = D->getCategoryList()) { + // Ensure that we write out the set of categories for this class. + Writer.ObjCClassesWithCategories.insert(D); + + // Make sure that the categories get serialized. + for (; Cat; Cat = Cat->getNextClassCategory()) + (void)Writer.GetDeclRef(Cat); + } } Code = serialization::DECL_OBJC_INTERFACE; @@ -533,6 +540,7 @@ void ASTDeclWriter::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D) { void ASTDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) { VisitObjCContainerDecl(D); + Writer.AddSourceLocation(D->getCategoryNameLoc(), Record); Writer.AddDeclRef(D->getClassInterface(), Record); Record.push_back(D->protocol_size()); for (ObjCCategoryDecl::protocol_iterator @@ -542,9 +550,7 @@ void ASTDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) { PL = D->protocol_loc_begin(), PLEnd = D->protocol_loc_end(); PL != PLEnd; ++PL) Writer.AddSourceLocation(*PL, Record); - Writer.AddDeclRef(D->getNextClassCategory(), Record); Record.push_back(D->hasSynthBitfield()); - Writer.AddSourceLocation(D->getCategoryNameLoc(), Record); Code = serialization::DECL_OBJC_CATEGORY; } |