1 //===--- CGTemporaries.cpp - Emit LLVM Code for C++ temporaries -----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This contains code dealing with C++ code generation of temporaries
12 //===----------------------------------------------------------------------===//
14 #include "CodeGenFunction.h"
15 using namespace clang;
16 using namespace CodeGen;
19 struct DestroyTemporary : EHScopeStack::Cleanup {
20 const CXXDestructorDecl *dtor;
22 DestroyTemporary(const CXXDestructorDecl *dtor, llvm::Value *addr)
23 : dtor(dtor), addr(addr) {}
24 void Emit(CodeGenFunction &CGF, Flags flags) {
25 CGF.EmitCXXDestructorCall(dtor, Dtor_Complete, /*ForVirtualBase=*/false,
31 /// Emits all the code to cause the given temporary to be cleaned up.
32 void CodeGenFunction::EmitCXXTemporary(const CXXTemporary *Temporary,
34 pushFullExprCleanup<DestroyTemporary>(NormalAndEHCleanup,
35 Temporary->getDestructor(),
40 CodeGenFunction::EmitExprWithCleanups(const ExprWithCleanups *E,
42 RunCleanupsScope Scope(*this);
43 return EmitAnyExpr(E->getSubExpr(), Slot);
46 LValue CodeGenFunction::EmitExprWithCleanupsLValue(const ExprWithCleanups *E) {
47 RunCleanupsScope Scope(*this);
48 return EmitLValue(E->getSubExpr());