aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-09-27 22:18:47 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-09-27 22:18:47 +0000
commitb57a624f22b1efa873e0abac78128b69fba3d486 (patch)
tree079bac0d4377bc5e4ef5640a3d4bd6202653298b
parent27c08ab4859d071efa158a256f7e47e13d924443 (diff)
When chaining PCHs, only write PPRecords that don't come from PCH, and give them the correct IDs. Fixes a crash in XCode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114913 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Lex/PreprocessingRecord.h4
-rw-r--r--lib/Serialization/ASTReader.cpp2
-rw-r--r--lib/Serialization/ASTWriter.cpp8
3 files changed, 10 insertions, 4 deletions
diff --git a/include/clang/Lex/PreprocessingRecord.h b/include/clang/Lex/PreprocessingRecord.h
index 730f04f2fa..576b571a4e 100644
--- a/include/clang/Lex/PreprocessingRecord.h
+++ b/include/clang/Lex/PreprocessingRecord.h
@@ -236,6 +236,10 @@ namespace clang {
/// \brief Set the external source for preprocessed entities.
void SetExternalSource(ExternalPreprocessingRecordSource &Source,
unsigned NumPreallocatedEntities);
+
+ unsigned getNumPreallocatedEntities() const {
+ return NumPreallocatedEntities;
+ }
/// \brief Set the preallocated entry at the given index to the given
/// preprocessed entity.
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index cc593e9827..1a42665d07 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -1474,7 +1474,7 @@ void ASTReader::ReadMacroRecord(llvm::BitstreamCursor &Stream, uint64_t Offset){
MacroDefinitionsLoaded[Record[1]] = MD;
return;
}
- }
+ }
}
}
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 24ec7ea4b7..61ba5ab71b 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -1334,12 +1334,14 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP) {
// If the preprocessor has a preprocessing record, emit it.
unsigned NumPreprocessingRecords = 0;
if (PPRec) {
- for (PreprocessingRecord::iterator E = PPRec->begin(), EEnd = PPRec->end();
+ unsigned IndexBase = PPRec->getNumPreallocatedEntities();
+ for (PreprocessingRecord::iterator E = PPRec->begin(Chain),
+ EEnd = PPRec->end(Chain);
E != EEnd; ++E) {
Record.clear();
if (MacroInstantiation *MI = dyn_cast<MacroInstantiation>(*E)) {
- Record.push_back(NumPreprocessingRecords++);
+ Record.push_back(IndexBase + NumPreprocessingRecords++);
AddSourceLocation(MI->getSourceRange().getBegin(), Record);
AddSourceLocation(MI->getSourceRange().getEnd(), Record);
AddIdentifierRef(MI->getName(), Record);
@@ -1359,7 +1361,7 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP) {
} else
MacroDefinitionOffsets.push_back(Stream.GetCurrentBitNo());
- Record.push_back(NumPreprocessingRecords++);
+ Record.push_back(IndexBase + NumPreprocessingRecords++);
Record.push_back(ID);
AddSourceLocation(MD->getSourceRange().getBegin(), Record);
AddSourceLocation(MD->getSourceRange().getEnd(), Record);