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 | 404cddec1b415a16553b1e4240021d7d0c61a98c (patch) | |
tree | ba6c4fac8e0c64e1b52e4a8f08f7ec371dd9d27d /clang/lib/Serialization/ASTWriterDecl.cpp | |
parent | 7ba81830ff717736940a48a53508eb3c7e90b32e (diff) | |
download | bcm5719-llvm-404cddec1b415a16553b1e4240021d7d0c61a98c.tar.gz bcm5719-llvm-404cddec1b415a16553b1e4240021d7d0c61a98c.zip |
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.
llvm-svn: 149112
Diffstat (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriterDecl.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index a6fae4f20da..404eb88f59d 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/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; } |