[PCH/Modules] The iterator may become invalidated because a new macro can be added

while deserializing a macro, make sure to copy/move what we need from it.

Fixes clang-x86_64-debian-fast bot.

llvm-svn: 172629
This commit is contained in:
Argyrios Kyrtzidis 2013-01-16 17:42:07 +00:00
parent 949e82216c
commit 8078a5a449
1 changed files with 4 additions and 2 deletions

View File

@ -6854,11 +6854,13 @@ void ASTReader::finishPendingActions() {
// Note that new macros may be added while deserializing a macro.
for (unsigned I = 0; I != PendingMacroIDs.size(); ++I) {
PendingMacroIDsMap::iterator PMIt = PendingMacroIDs.begin() + I;
SmallVector<serialization::MacroID, 2> &MacroIDs = PMIt->second;
IdentifierInfo *II = PMIt->first;
SmallVector<serialization::MacroID, 2> MacroIDs;
MacroIDs.swap(PMIt->second);
for (SmallVectorImpl<serialization::MacroID>::iterator
MIt = MacroIDs.begin(), ME = MacroIDs.end(); MIt != ME; ++MIt) {
MacroInfo *MI = getMacro(*MIt);
PP.addLoadedMacroInfo(PMIt->first, MI);
PP.addLoadedMacroInfo(II, MI);
}
}
PendingMacroIDs.clear();