2009-11-24 13:51:11 +08:00
|
|
|
//===--- CGTemporaries.cpp - Emit LLVM Code for C++ temporaries -----------===//
|
2009-06-04 02:40:21 +08: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 14:44:28 +08:00
|
|
|
namespace {
|
2011-07-12 08:15:30 +08: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 04:27:29 +08:00
|
|
|
void Emit(CodeGenFunction &CGF, Flags flags) {
|
2011-01-27 03:15:39 +08:00
|
|
|
CGF.EmitCXXDestructorCall(dtor, Dtor_Complete, /*ForVirtualBase=*/false,
|
|
|
|
addr);
|
2010-07-21 14:44:28 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-07-06 09:34:17 +08: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-27 03:15:39 +08:00
|
|
|
pushFullExprCleanup<DestroyTemporary>(NormalAndEHCleanup,
|
|
|
|
Temporary->getDestructor(),
|
|
|
|
Ptr);
|
2009-06-04 02:40:21 +08:00
|
|
|
}
|
|
|
|
|
2009-06-04 03:05:16 +08:00
|
|
|
RValue
|
2010-12-06 16:20:24 +08:00
|
|
|
CodeGenFunction::EmitExprWithCleanups(const ExprWithCleanups *E,
|
|
|
|
AggValueSlot Slot) {
|
2010-07-21 14:45:54 +08:00
|
|
|
RunCleanupsScope Scope(*this);
|
2010-09-15 18:14:12 +08:00
|
|
|
return EmitAnyExpr(E->getSubExpr(), Slot);
|
2009-06-04 02:40:21 +08:00
|
|
|
}
|
2009-06-04 10:22:12 +08:00
|
|
|
|
2010-12-06 16:20:24 +08:00
|
|
|
LValue CodeGenFunction::EmitExprWithCleanupsLValue(const ExprWithCleanups *E) {
|
2010-07-21 14:45:54 +08:00
|
|
|
RunCleanupsScope Scope(*this);
|
|
|
|
return EmitLValue(E->getSubExpr());
|
2009-09-14 09:10:45 +08:00
|
|
|
}
|