aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-01 00:58:55 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-01 00:58:55 +0000
commite6b8d68a927368b06ac06cc9ac9e7f60aa966d5f (patch)
treeed379340bfd735af63c521a8b6439104799f434a /lib/Serialization/ASTWriter.cpp
parent50c909bd837f00265034d876736e2db47686be38 (diff)
Support importing of ObjC categories from modules.
The initial incentive was to fix a crash when PCH chaining categories to an interface, but the fix was done in the "modules way" that I hear is popular with the kids these days. Each module stores the local chain of categories and we combine them when the interface is loaded. We also warn if non-dependent modules introduce duplicate named categories. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138926 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r--lib/Serialization/ASTWriter.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 25bff0aba1..a57f3a1388 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -3188,6 +3188,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
WriteDeclUpdatesBlocks();
WriteDeclReplacementsBlock();
+ WriteChainedObjCCategories();
// Some simple statistics
Record.clear();
@@ -3236,6 +3237,26 @@ void ASTWriter::WriteDeclReplacementsBlock() {
Stream.EmitRecord(DECL_REPLACEMENTS, Record);
}
+void ASTWriter::WriteChainedObjCCategories() {
+ if (LocalChainedObjCCategories.empty())
+ return;
+
+ RecordData Record;
+ for (SmallVector<ChainedObjCCategoriesData, 16>::iterator
+ I = LocalChainedObjCCategories.begin(),
+ E = LocalChainedObjCCategories.end(); I != E; ++I) {
+ ChainedObjCCategoriesData &Data = *I;
+ serialization::DeclID
+ HeadCatID = getDeclID(Data.Interface->getCategoryList());
+ assert(HeadCatID != 0 && "Category not written ?");
+
+ Record.push_back(Data.InterfaceID);
+ Record.push_back(HeadCatID);
+ Record.push_back(Data.TailCatID);
+ }
+ Stream.EmitRecord(OBJC_CHAINED_CATEGORIES, Record);
+}
+
void ASTWriter::AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record) {
Record.push_back(Loc.getRawEncoding());
}
@@ -4037,4 +4058,17 @@ void ASTWriter::StaticDataMemberInstantiated(const VarDecl *D) {
D->getMemberSpecializationInfo()->getPointOfInstantiation(), Record);
}
+void ASTWriter::AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
+ const ObjCInterfaceDecl *IFD) {
+ if (IFD->getPCHLevel() == 0)
+ return; // Declaration not imported from PCH.
+ if (CatD->getNextClassCategory() &&
+ CatD->getNextClassCategory()->getPCHLevel() == 0)
+ return; // We already recorded that the tail of a category chain should be
+ // attached to an interface.
+
+ ChainedObjCCategoriesData Data = { IFD, GetDeclRef(IFD), GetDeclRef(CatD) };
+ LocalChainedObjCCategories.push_back(Data);
+}
+
ASTSerializationListener::~ASTSerializationListener() { }