[serialization] Load the decl and type offset arrays from the module.

...but don't do anything with them yet. This does check that they're being
correctly serialized, though.

This introduces a new ADT, PointerIntUnion, which like PointerUnion is an
efficient variant type using the lowest bit of data as a discriminator.
By default, the union can store any pointer-bits-minus-one-sized integer,
but both the integer type and the underlying storage type can be
customized.

Swift SVN r5321
This commit is contained in:
Jordan Rose
2013-05-25 01:34:52 +00:00
parent fc1cbf0aaf
commit 965035dc2a
4 changed files with 128 additions and 0 deletions

View File

@@ -129,6 +129,43 @@ ModuleFile::ModuleFile(llvm::OwningPtr<llvm::MemoryBuffer> &&input)
break;
}
case INDEX_BLOCK_ID: {
if (!hasValidControlBlock)
return error();
cursor.EnterSubBlock(INDEX_BLOCK_ID);
auto next = cursor.advanceSkippingSubblocks();
while (next.Kind == llvm::BitstreamEntry::Record) {
scratch.clear();
StringRef blobData;
unsigned kind = cursor.readRecord(next.ID, scratch, &blobData);
switch (kind) {
case index_block::DECL_OFFSETS:
assert(blobData.empty());
// FIXME: Use proper BCRecordLayout for this.
Decls.assign(scratch.begin()+1, scratch.end());
break;
case index_block::TYPE_OFFSETS:
assert(blobData.empty());
// FIXME: Use proper BCRecordLayout for this.
Types.assign(scratch.begin()+1, scratch.end());
break;
default:
// Unknown index kind, which this version of the compiler won't use.
break;
}
next = cursor.advanceSkippingSubblocks();
}
if (next.Kind != llvm::BitstreamEntry::EndBlock)
return error();
break;
}
case FALL_BACK_TO_TRANSLATION_UNIT_ID:
// This is a bring-up hack and will eventually go away.
Status = ModuleStatus::FallBackToTranslationUnit;