[serialization] Don't special-case builtin types.

Instead, special-case cross-references to use the empty identifier as the
name of the Builtin module. This way imported modules will be able to use
builtin types and functions without the main TU having access.

Swift SVN r5947
This commit is contained in:
Jordan Rose
2013-07-01 21:05:39 +00:00
parent 1528454dca
commit cb45063516
5 changed files with 27 additions and 38 deletions

View File

@@ -558,8 +558,14 @@ Decl *ModuleFile::getDecl(DeclID DID, DeclDeserializationOptions opts) {
// First, find the module this reference is referring to.
Identifier moduleName = getIdentifier(rawAccessPath.front());
rawAccessPath = rawAccessPath.slice(1);
// FIXME: provide a real source location.
Module *M = ctx.getModule(std::make_pair(moduleName, SourceLoc()), false);
Module *M;
if (moduleName.empty()) {
M = ctx.TheBuiltinModule;
} else {
// FIXME: provide a real source location.
M = ctx.getModule(std::make_pair(moduleName, SourceLoc()), false);
}
assert(M && "missing dependency");
switch (kind) {
@@ -717,22 +723,6 @@ Type ModuleFile::getType(TypeID TID) {
unsigned recordID = DeclTypeCursor.readRecord(entry.ID, scratch, &blobData);
switch (recordID) {
case decls_block::BUILTIN_TYPE: {
assert(!blobData.empty() && "missing name in BUILTIN_TYPE record");
SmallVector<ValueDecl *, 1> lookupResult;
ctx.TheBuiltinModule->lookupValue({}, ctx.getIdentifier(blobData),
NLKind::QualifiedLookup, lookupResult);
if (lookupResult.empty()) {
// This builtin is not supported.
error();
return nullptr;
}
assert(lookupResult.size() == 1 && "multiple types for the same name");
typeOrOffset = cast<TypeDecl>(lookupResult.front())->getDeclaredType();
break;
}
case decls_block::NAME_ALIAS_TYPE: {
DeclID underlyingID;
decls_block::NameAliasTypeLayout::readRecord(scratch, underlyingID);