diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-01 19:51:50 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-01 19:51:50 +0000 |
commit | a715bfff98cbe13c31303c19829bc20226b38a1d (patch) | |
tree | 8cb54beae387712d5c1ed97464be27206bdbfc22 /clang/lib/Serialization/ASTReader.cpp | |
parent | 1c064e0a896451b8083bf2b66c11d7222bc2f3e2 (diff) | |
download | bcm5719-llvm-a715bfff98cbe13c31303c19829bc20226b38a1d.tar.gz bcm5719-llvm-a715bfff98cbe13c31303c19829bc20226b38a1d.zip |
Introduce the core infrastructure needed to model redeclaration chains
for Objective-C protocols, 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 that we know which declaration is the definition
- Serialization support for redeclaration chains and for adding
definitions to already-serialized declarations.
However, note that we're not taking advantage of much of this code
yet, because we're still re-using ObjCProtocolDecls.
llvm-svn: 147410
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index dd48b2dc564..9c9e8b3ca9e 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -6121,9 +6121,10 @@ void ASTReader::finishPendingActions() { PendingChainedObjCCategories.clear(); } - // If we deserialized any C++ or Objective-C class definitions, make sure - // that all redeclarations point to the definitions. Note that this can only - // happen now, after the redeclaration chains have been fully wired. + // If we deserialized any C++ or Objective-C class definitions or any + // Objective-C protocol definitions, make sure that all redeclarations point + // to the definitions. Note that this can only happen now, after the + // redeclaration chains have been fully wired. for (llvm::SmallPtrSet<Decl *, 4>::iterator D = PendingDefinitions.begin(), DEnd = PendingDefinitions.end(); D != DEnd; ++D) { @@ -6136,11 +6137,20 @@ void ASTReader::finishPendingActions() { continue; } - ObjCInterfaceDecl *ID = cast<ObjCInterfaceDecl>(*D); - for (ObjCInterfaceDecl::redecl_iterator R = ID->redecls_begin(), - REnd = ID->redecls_end(); + if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(*D)) { + for (ObjCInterfaceDecl::redecl_iterator R = ID->redecls_begin(), + REnd = ID->redecls_end(); + R != REnd; ++R) + R->Data = ID->Data; + + continue; + } + + ObjCProtocolDecl *PD = cast<ObjCProtocolDecl>(*D); + for (ObjCProtocolDecl::redecl_iterator R = PD->redecls_begin(), + REnd = PD->redecls_end(); R != REnd; ++R) - R->Data = ID->Data; + R->Data = PD->Data; } PendingDefinitions.clear(); } |