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 {
20 static void Emit(CodeGenFunction &CGF, bool forEH,
21 const CXXDestructorDecl *dtor, llvm::Value *addr) {
22 CGF.EmitCXXDestructorCall(dtor, Dtor_Complete, /*ForVirtualBase=*/false,
28 /// Emits all the code to cause the given temporary to be cleaned up.
29 void CodeGenFunction::EmitCXXTemporary(const CXXTemporary *Temporary,
31 pushFullExprCleanup<DestroyTemporary>(NormalAndEHCleanup,
32 Temporary->getDestructor(),
37 CodeGenFunction::EmitExprWithCleanups(const ExprWithCleanups *E,
39 RunCleanupsScope Scope(*this);
40 return EmitAnyExpr(E->getSubExpr(), Slot);
43 LValue CodeGenFunction::EmitExprWithCleanupsLValue(const ExprWithCleanups *E) {
44 RunCleanupsScope Scope(*this);
45 return EmitLValue(E->getSubExpr());