forked from OSchip/llvm-project
When chaining PCHs, only write PPRecords that don't come from PCH, and give them the correct IDs. Fixes a crash in XCode.
llvm-svn: 114913
This commit is contained in:
parent
a1ce1f80cf
commit
9609b4f1a8
|
@ -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.
|
||||
|
|
|
@ -1474,7 +1474,7 @@ void ASTReader::ReadMacroRecord(llvm::BitstreamCursor &Stream, uint64_t Offset){
|
|||
MacroDefinitionsLoaded[Record[1]] = MD;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue