(De-)Serialize the protocols from which a protocol inherits.

Switch a few more clients from ::getInherited() to
::getProtocols(). The trajectory here is that ::getInherited() will
turn into something only populated when we've parsed the inheritance
clause, and that "the truth" will be getProtocols(). The former will
cease being serialized once this is the case.


Swift SVN r6661
This commit is contained in:
Doug Gregor
2013-07-26 23:57:52 +00:00
parent e444a4c7b6
commit 1759210067
5 changed files with 40 additions and 34 deletions

View File

@@ -1023,10 +1023,12 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext,
IdentifierID nameID;
DeclID contextID;
bool isImplicit;
unsigned numProtocols;
ArrayRef<uint64_t> inheritedIDs;
decls_block::ProtocolLayout::readRecord(scratch, nameID, contextID,
isImplicit, inheritedIDs);
isImplicit, numProtocols,
inheritedIDs);
DeclContext *DC;
MutableArrayRef<TypeLoc> inherited;
@@ -1037,7 +1039,7 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext,
if (declOrOffset.isComplete())
break;
inherited = getTypes(inheritedIDs);
inherited = getTypes(inheritedIDs.slice(numProtocols));
}
auto proto = new (ctx) ProtocolDecl(DC, SourceLoc(), SourceLoc(),
getIdentifier(nameID), inherited);
@@ -1050,6 +1052,13 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext,
if (isImplicit)
proto->setImplicit();
// Deserialize the list of protocols.
SmallVector<ProtocolDecl *, 4> protocols;
for (auto protoID : inheritedIDs.slice(0, numProtocols)) {
protocols.push_back(cast<ProtocolDecl>(getDecl(protoID)));
}
proto->setProtocols(ctx.AllocateCopy(protocols));
auto members = readMembers();
assert(members.hasValue() && "could not read struct members");
proto->setMembers(members.getValue(), SourceRange());