summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-08-01 16:54:33 +0000
committerDouglas Gregor <dgregor@apple.com>2011-08-01 16:54:33 +0000
commit2df17cbeeb442ee9668d3552ce9852e6ef31579b (patch)
tree0196f6d15de7204624eac84d38021c43603401c2 /clang/lib/Serialization/ASTWriter.cpp
parent0cc000ef29d00d110a9b1d04422e4ef75644d019 (diff)
downloadbcm5719-llvm-2df17cbeeb442ee9668d3552ce9852e6ef31579b.tar.gz
bcm5719-llvm-2df17cbeeb442ee9668d3552ce9852e6ef31579b.zip
Move the serialization of the MODULE_OFFSET_MAP out of the source-manager-writing code and into the general chained-PCH writing code
llvm-svn: 136624
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp67
1 files changed, 35 insertions, 32 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 649b05e21d5..06200d8db00 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1570,38 +1570,6 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
Record.push_back(SourceMgr.getNextLocalOffset() - 1); // skip dummy
Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record, data(SLocEntryOffsets));
- // If we have module dependencies, write the mapping from source locations to
- // their containing modules, so that the reader can build the remapping.
- if (Chain) {
- // 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);
-
- Abbrev = new BitCodeAbbrev();
- Abbrev->Add(BitCodeAbbrevOp(MODULE_OFFSET_MAP));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
- unsigned SLocMapAbbrev = 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());
- }
- }
- Record.clear();
- Record.push_back(MODULE_OFFSET_MAP);
- Stream.EmitRecordWithBlob(SLocMapAbbrev, Record,
- Buffer.data(), Buffer.size());
- }
-
Abbrev = new BitCodeAbbrev();
Abbrev->Add(BitCodeAbbrevOp(FILE_SOURCE_LOCATION_OFFSETS));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // # of slocs
@@ -2938,6 +2906,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
if (StatCalls && isysroot.empty())
WriteStatCache(*StatCalls);
WriteSourceManagerBlock(Context.getSourceManager(), PP, isysroot);
+
// Write the record of special types.
Record.clear();
@@ -3069,6 +3038,40 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
// done by tracking the largest ID in the chain
WriteSourceManagerBlock(Context.getSourceManager(), PP, isysroot);
+ // 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);
+
+ llvm::BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+ Abbrev->Add(BitCodeAbbrevOp(MODULE_OFFSET_MAP));
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
+ unsigned SLocMapAbbrev = 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());
+ }
+ }
+ Record.clear();
+ Record.push_back(MODULE_OFFSET_MAP);
+ Stream.EmitRecordWithBlob(SLocMapAbbrev, Record,
+ Buffer.data(), Buffer.size());
+
// The special types are in the chained PCH.
// We don't start with the translation unit, but with its decls that
OpenPOWER on IntegriCloud