diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-01 00:58:55 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-09-01 00:58:55 +0000 |
commit | 7d847c9fd81d10d3927bd47fd99133265c5d0ad4 (patch) | |
tree | 492c87da277c5c89906a1b44bede46aa6311111c /clang/lib/Serialization/ASTReader.cpp | |
parent | e88632d66738689f6b7dd896d0aa0d7c4a2787c8 (diff) | |
download | bcm5719-llvm-7d847c9fd81d10d3927bd47fd99133265c5d0ad4.tar.gz bcm5719-llvm-7d847c9fd81d10d3927bd47fd99133265c5d0ad4.zip |
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.
llvm-svn: 138926
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index fe714300ac8..bc022f5721b 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -2391,6 +2391,20 @@ ASTReader::ReadASTBlock(Module &F) { = std::make_pair(&F, Record[I+1]); break; } + + case OBJC_CHAINED_CATEGORIES: { + if (Record.size() % 3 != 0) { + Error("invalid OBJC_CHAINED_CATEGORIES block in AST file"); + return Failure; + } + for (unsigned I = 0, N = Record.size(); I != N; I += 3) { + serialization::GlobalDeclID GlobID = getGlobalDeclID(F, Record[I]); + F.ChainedObjCCategories[GlobID] = std::make_pair(Record[I+1], + Record[I+2]); + ObjCChainedCategoriesInterfaces.insert(GlobID); + } + break; + } case CXX_BASE_SPECIFIER_OFFSETS: { if (F.LocalNumCXXBaseSpecifiers != 0) { @@ -4075,6 +4089,13 @@ ASTReader::getGlobalDeclID(Module &F, unsigned LocalID) const { return LocalID + I->second; } +bool ASTReader::isDeclIDFromModule(serialization::GlobalDeclID ID, + Module &M) const { + GlobalDeclMapType::const_iterator I = GlobalDeclMap.find(ID); + assert(I != GlobalDeclMap.end() && "Corrupted global declaration map"); + return &M == I->second; +} + Decl *ASTReader::GetDecl(DeclID ID) { if (ID < NUM_PREDEF_DECL_IDS) { switch ((PredefinedDeclIDs)ID) { |