summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-22 06:10:01 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-22 06:10:01 +0000
commitd32f035267440f41168b4619670f9114c4ceea3e (patch)
tree3eb910249b21e7c289cbadc9f14c99eee093e66a /clang/lib/Serialization/ASTWriter.cpp
parent77d993d3aaf7b8e7b435d06b86ad184765147683 (diff)
downloadbcm5719-llvm-d32f035267440f41168b4619670f9114c4ceea3e.tar.gz
bcm5719-llvm-d32f035267440f41168b4619670f9114c4ceea3e.zip
Introduce a global bit-offset continuous range map into the ASTReader,
so that we have one, simple way to map from global bit offsets to local bit offsets. Eliminates a number of loops over the chain, and generalizes for more interesting bit remappings. Also, as an amusing oddity, we were computing global bit offsets *backwards* for preprocessed entities (e.g., the directly included PCH file in the chain would start at offset zero, rather than the original PCH that occurs first in translation unit). Even more amusingly, it made precompiled preambles work, because we were forgetting to adjust the local bit offset to a global bit offset when storing preprocessed entity offsets in the ASTUnit. Two wrongs made a right, and now they're both right. llvm-svn: 135750
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index aaf4678ba29..e6e88f8f872 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1803,6 +1803,7 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
unsigned IndexBase = Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0;
RecordData Record;
+ uint64_t BitsInChain = Chain? Chain->TotalModulesSizeInBits : 0;
for (PreprocessingRecord::iterator E = PPRec.begin(Chain),
EEnd = PPRec.end(Chain);
E != EEnd; ++E) {
@@ -1819,7 +1820,7 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
// Notify the serialization listener that we're serializing this entity.
if (SerializationListener)
SerializationListener->SerializedPreprocessedEntity(*E,
- Stream.GetCurrentBitNo());
+ BitsInChain + Stream.GetCurrentBitNo());
unsigned Position = ID - FirstMacroID;
if (Position != MacroDefinitionOffsets.size()) {
@@ -1843,7 +1844,7 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
// Notify the serialization listener that we're serializing this entity.
if (SerializationListener)
SerializationListener->SerializedPreprocessedEntity(*E,
- Stream.GetCurrentBitNo());
+ BitsInChain + Stream.GetCurrentBitNo());
if (MacroExpansion *ME = dyn_cast<MacroExpansion>(*E)) {
Record.push_back(IndexBase + NumPreprocessingRecords++);
OpenPOWER on IntegriCloud