Avoid iteration invalidation issues around MaterializedTemporaryExpr

We risk iterator invalidation issues if we use a DenseMap to hold the
backing storage for an APValue.  Instead, BumpPtrAllocate them and
use APValue * as our DenseMap value.

Also, don't assume that MaterializedGlobalTemporaryMap won't regrow
between when we initially perform a lookup and later on when we actually
try to insert into it.

This fixes PR24289.

Differential Revision: http://reviews.llvm.org/D11629

llvm-svn: 244989
This commit is contained in:
David Majnemer
2015-08-13 23:50:15 +00:00
parent f7b41371d9
commit 2dcef9e0a4
4 changed files with 94 additions and 10 deletions

View File

@@ -3029,8 +3029,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary(
if (Init == E->GetTemporaryExpr())
MaterializedType = E->getType();
llvm::Constant *&Slot = MaterializedGlobalTemporaryMap[E];
if (Slot)
if (llvm::Constant *Slot = MaterializedGlobalTemporaryMap[E])
return Slot;
// FIXME: If an externally-visible declaration extends multiple temporaries,
@@ -3101,7 +3100,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary(
GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
if (VD->getTLSKind())
setTLSMode(GV, *VD);
Slot = GV;
MaterializedGlobalTemporaryMap[E] = GV;
return GV;
}