SetLLVMFunctionAttributesForDefinition(D, Fn);
}
+void
+CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
+ CXXCtorType Type,
+ llvm::Value *This,
+ CallExpr::const_arg_iterator ArgBeg,
+ CallExpr::const_arg_iterator ArgEnd) {
+ CallArgList Args;
+
+ // Push the 'this' pointer.
+ Args.push_back(std::make_pair(RValue::get(This),
+ D->getThisType(getContext())));
+
+ EmitCallArgs(Args, D->getType()->getAsFunctionProtoType(), ArgBeg, ArgEnd);
+
+ EmitCall(CGM.getTypes().getFunctionInfo(getContext().VoidTy, Args),
+ CGM.GetAddrOfCXXConstructor(D, Type), Args, D);
+}
+
+LValue
+CodeGenFunction::EmitCXXTemporaryObjectExprLValue(
+ const CXXTemporaryObjectExpr *E) {
+ // Allocate the destination.
+ llvm::Value *Dest = CreateTempAlloca(ConvertType(E->getType()), "tmp");
+
+ EmitCXXTemporaryObjectExpr(Dest, E);
+
+ return LValue::MakeAddr(Dest, E->getType().getCVRQualifiers(),
+ getContext().getObjCGCAttrKind(E->getType()));
+}
+
+void
+CodeGenFunction::EmitCXXTemporaryObjectExpr(llvm::Value *Dest,
+ const CXXTemporaryObjectExpr *E) {
+ assert(Dest && "Must have a destination!");
+
+ const CXXRecordDecl *RD =
+ cast<CXXRecordDecl>(E->getType()->getAsRecordType()->getDecl());
+ if (RD->hasTrivialConstructor())
+ return;
+
+ // Call the constructor.
+ EmitCXXConstructorCall(E->getConstructor(), Ctor_Complete, Dest,
+ E->arg_begin(), E->arg_end());
+}
+
static bool canGenerateCXXConstructor(const CXXConstructorDecl *D,
ASTContext &Context) {
const CXXRecordDecl *RD = D->getParent();
case Expr::CXXReinterpretCastExprClass:
case Expr::CXXConstCastExprClass:
return EmitCastLValue(cast<CastExpr>(E));
+ case Expr::CXXTemporaryObjectExprClass:
+ return EmitCXXTemporaryObjectExprLValue(cast<CXXTemporaryObjectExpr>(E));
}
}
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
#include "clang/AST/StmtVisitor.h"
#include "llvm/Constants.h"
#include "llvm/Function.h"
void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Visit(DAE->getExpr());
}
+ void VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *E);
void VisitVAArgExpr(VAArgExpr *E);
void EmitInitializationToLValue(Expr *E, LValue Address);
CGF.EmitAggregateCopy(DestPtr, ArgPtr, VE->getType());
}
+void
+AggExprEmitter::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *E) {
+ llvm::Value *This = 0;
+
+ if (DestPtr)
+ This = DestPtr;
+ else
+ This = CGF.CreateTempAlloca(CGF.ConvertType(E->getType()), "tmp");
+
+ CGF.EmitCXXTemporaryObjectExpr(This, E);
+}
+
void AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV) {
// FIXME: Are initializers affected by volatile?
if (isa<ImplicitValueInitExpr>(E)) {
#include "CGBlocks.h"
#include "CGBuilder.h"
#include "CGCall.h"
+#include "CGCXX.h"
#include "CGValue.h"
namespace llvm {
/// generating code for an C++ member function.
llvm::Value *LoadCXXThis();
+ void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type,
+ llvm::Value *This,
+ CallExpr::const_arg_iterator ArgBeg,
+ CallExpr::const_arg_iterator ArgEnd);
+
//===--------------------------------------------------------------------===//
// Declaration Emission
//===--------------------------------------------------------------------===//
LValue EmitBlockDeclRefLValue(const BlockDeclRefExpr *E);
LValue EmitCXXConditionDeclLValue(const CXXConditionDeclExpr *E);
+ LValue EmitCXXTemporaryObjectExprLValue(const CXXTemporaryObjectExpr *E);
LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E);
LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E);
void GenerateStaticCXXBlockVarDeclInit(const VarDecl &D,
llvm::GlobalVariable *GV);
+ void EmitCXXTemporaryObjectExpr(llvm::Value *Dest,
+ const CXXTemporaryObjectExpr *E);
+
//===--------------------------------------------------------------------===//
// Internal Helpers
//===--------------------------------------------------------------------===//