2009-11-24 08:51:11 +03:00
|
|
|
//===--- CGTemporaries.cpp - Emit LLVM Code for C++ temporaries -----------===//
|
2009-06-03 22:40:21 +04:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This contains code dealing with C++ code generation of temporaries
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "CodeGenFunction.h"
|
|
|
|
using namespace clang;
|
|
|
|
using namespace CodeGen;
|
|
|
|
|
2010-07-21 10:44:28 +04:00
|
|
|
namespace {
|
2011-07-12 04:15:30 +04:00
|
|
|
struct DestroyTemporary : EHScopeStack::Cleanup {
|
|
|
|
const CXXDestructorDecl *dtor;
|
|
|
|
llvm::Value *addr;
|
|
|
|
DestroyTemporary(const CXXDestructorDecl *dtor, llvm::Value *addr)
|
|
|
|
: dtor(dtor), addr(addr) {}
|
2011-07-13 00:27:29 +04:00
|
|
|
void Emit(CodeGenFunction &CGF, Flags flags) {
|
2011-01-26 22:15:39 +03:00
|
|
|
CGF.EmitCXXDestructorCall(dtor, Dtor_Complete, /*ForVirtualBase=*/false,
|
|
|
|
addr);
|
2010-07-21 10:44:28 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-07-06 05:34:17 +04:00
|
|
|
/// Emits all the code to cause the given temporary to be cleaned up.
|
|
|
|
void CodeGenFunction::EmitCXXTemporary(const CXXTemporary *Temporary,
|
|
|
|
llvm::Value *Ptr) {
|
2011-01-26 22:15:39 +03:00
|
|
|
pushFullExprCleanup<DestroyTemporary>(NormalAndEHCleanup,
|
|
|
|
Temporary->getDestructor(),
|
|
|
|
Ptr);
|
2009-06-03 22:40:21 +04:00
|
|
|
}
|
|
|
|
|
2009-06-03 23:05:16 +04:00
|
|
|
RValue
|
2010-12-06 11:20:24 +03:00
|
|
|
CodeGenFunction::EmitExprWithCleanups(const ExprWithCleanups *E,
|
|
|
|
AggValueSlot Slot) {
|
2010-07-21 10:45:54 +04:00
|
|
|
RunCleanupsScope Scope(*this);
|
2010-09-15 14:14:12 +04:00
|
|
|
return EmitAnyExpr(E->getSubExpr(), Slot);
|
2009-06-03 22:40:21 +04:00
|
|
|
}
|
2009-06-04 06:22:12 +04:00
|
|
|
|
2010-12-06 11:20:24 +03:00
|
|
|
LValue CodeGenFunction::EmitExprWithCleanupsLValue(const ExprWithCleanups *E) {
|
2010-07-21 10:45:54 +04:00
|
|
|
RunCleanupsScope Scope(*this);
|
|
|
|
return EmitLValue(E->getSubExpr());
|
2009-09-14 05:10:45 +04:00
|
|
|
}
|