aboutsummaryrefslogtreecommitdiff
path: root/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-08-02 10:56:51 +0000
committerDouglas Gregor <dgregor@apple.com>2011-08-02 10:56:51 +0000
commitf33740efdb2d836a96ba97ca3004d46404401439 (patch)
treec7ce78949afe38027240701b6bca39441c7cf994 /lib/Serialization/ASTWriter.cpp
parent39997fc2b8d300a85ead0a7d687964c6e63a8110 (diff)
Generalize the module offset map to include mapping information for
all of the kinds of IDs that can be offset. No effectively functionality change; this is preparation for adding remapping for IDs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136686 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r--lib/Serialization/ASTWriter.cpp44
1 files changed, 26 insertions, 18 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 06200d8db0..fb24f85188 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -3041,35 +3041,43 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
// Write the mapping information describing our module dependencies and how
// each of those modules were mapped into our own offset/ID space, so that
// the reader can build the appropriate mapping to its own offset/ID space.
-
- // If we have module dependencies, write the mapping from source locations to
- // their containing modules, so that the reader can build the remapping.
// The map consists solely of a blob with the following format:
- // *(offset:i32 len:i16 name:len*i8)
- // Sorted by offset.
- typedef std::pair<uint32_t, StringRef> ModuleOffset;
- SmallVector<ModuleOffset, 16> Modules;
-
- Chain->ModuleMgr.exportLookup(Modules);
-
+ // *(module-name-len:i16 module-name:len*i8
+ // source-location-offset:i32
+ // identifier-id:i32
+ // preprocessed-entity-id:i32
+ // macro-definition-id:i32
+ // selector-id:i32
+ // declaration-id:i32
+ // c++-base-specifiers-id:i32
+ // type-id:i32)
+ //
llvm::BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
Abbrev->Add(BitCodeAbbrevOp(MODULE_OFFSET_MAP));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
- unsigned SLocMapAbbrev = Stream.EmitAbbrev(Abbrev);
+ unsigned ModuleOffsetMapAbbrev = Stream.EmitAbbrev(Abbrev);
llvm::SmallString<2048> Buffer;
{
llvm::raw_svector_ostream Out(Buffer);
- for (SmallVector<ModuleOffset, 16>::iterator I = Modules.begin(),
- E = Modules.end();
- I != E; ++I) {
- io::Emit32(Out, I->first);
- io::Emit16(Out, I->second.size());
- Out.write(I->second.data(), I->second.size());
+ for (ModuleManager::ModuleConstIterator M = Chain->ModuleMgr.begin(),
+ MEnd = Chain->ModuleMgr.end();
+ M != MEnd; ++M) {
+ StringRef FileName = (*M)->FileName;
+ io::Emit16(Out, FileName.size());
+ Out.write(FileName.data(), FileName.size());
+ io::Emit32(Out, (*M)->SLocEntryBaseOffset);
+ io::Emit32(Out, (*M)->BaseIdentifierID);
+ io::Emit32(Out, (*M)->BasePreprocessedEntityID);
+ io::Emit32(Out, (*M)->BaseMacroDefinitionID);
+ io::Emit32(Out, (*M)->BaseSelectorID);
+ io::Emit32(Out, (*M)->BaseDeclID);
+ io::Emit32(Out, (*M)->BaseCXXBaseSpecifiersID);
+ io::Emit32(Out, (*M)->BaseTypeID);
}
}
Record.clear();
Record.push_back(MODULE_OFFSET_MAP);
- Stream.EmitRecordWithBlob(SLocMapAbbrev, Record,
+ Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record,
Buffer.data(), Buffer.size());
// The special types are in the chained PCH.