void CodeGenFunction::PushCXXTemporary(const CXXTemporary *Temporary,
llvm::Value *Ptr) {
- LiveTemporaries.push_back(CXXLiveTemporaryInfo(Temporary, Ptr, 0, 0));
+ llvm::BasicBlock *DtorBlock = createBasicBlock("temp.dtor");
+
+ LiveTemporaries.push_back(CXXLiveTemporaryInfo(Temporary, Ptr, DtorBlock, 0));
+}
+
+void CodeGenFunction::PopCXXTemporary() {
+ const CXXLiveTemporaryInfo& Info = LiveTemporaries.back();
- // Make a cleanup scope and emit the destructor.
- {
- CleanupScope Scope(*this);
-
- EmitCXXDestructorCall(Temporary->getDestructor(), Dtor_Complete, Ptr);
- }
+ CleanupBlockInfo CleanupInfo = PopCleanupBlock();
+ assert(CleanupInfo.CleanupBlock == Info.DtorBlock &&
+ "Cleanup block mismatch!");
+ assert(!CleanupInfo.SwitchBlock &&
+ "Should not have a switch block for temporary cleanup!");
+ assert(!CleanupInfo.EndBlock &&
+ "Should not have an end block for temporary cleanup!");
+
+ EmitBlock(Info.DtorBlock);
+
+ EmitCXXDestructorCall(Info.Temporary->getDestructor(),
+ Dtor_Complete, Info.ThisPtr);
+
+ LiveTemporaries.pop_back();
}
-RValue
+RValue
CodeGenFunction::EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
llvm::Value *AggLoc,
bool isAggLocVolatile) {
llvm::Value *CondPtr;
CXXLiveTemporaryInfo(const CXXTemporary *temporary,
- llvm::Value *thisptr, llvm::Value *condptr,
- llvm::BasicBlock *dtorblock)
+ llvm::Value *thisptr, llvm::BasicBlock *dtorblock,
+ llvm::Value *condptr)
: Temporary(temporary), ThisPtr(thisptr), DtorBlock(dtorblock),
CondPtr(condptr) { }
};
llvm::Value *This);
void PushCXXTemporary(const CXXTemporary *Temporary, llvm::Value *Ptr);
+ void PopCXXTemporary();
llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);