aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprCXX.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-11-13 21:53:34 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-11-13 21:53:34 +0000
commit34999876e215b22febc240b1a6dc054215d12f9c (patch)
tree2c0ec2f204edc053fd9fb6e5efc3c0dbbbf709c5 /lib/CodeGen/CGExprCXX.cpp
parentae2cf767de457df939d07c44b162de5fe0b5e607 (diff)
Block API patch to do copy ctor of copied-in cxx objects in
copy helper function and dtor of copied cxx objects in dispose helper functions. __block variables TBD next. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprCXX.cpp')
-rw-r--r--lib/CodeGen/CGExprCXX.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp
index a03a1fe362..137c54ab1e 100644
--- a/lib/CodeGen/CGExprCXX.cpp
+++ b/lib/CodeGen/CGExprCXX.cpp
@@ -341,6 +341,33 @@ CodeGenFunction::EmitCXXConstructExpr(const CXXConstructExpr *E,
}
}
+void
+CodeGenFunction::EmitSynthesizedCXXCopyCtor(llvm::Value *Dest,
+ llvm::Value *Src,
+ const BlockDeclRefExpr *BDRE) {
+ const Expr *Exp = BDRE->getCopyConstructorExpr();
+ if (const CXXExprWithTemporaries *E = dyn_cast<CXXExprWithTemporaries>(Exp))
+ Exp = E->getSubExpr();
+ assert(isa<CXXConstructExpr>(Exp) &&
+ "EmitSynthesizedCXXCopyCtor - unknown copy ctor expr");
+ const CXXConstructExpr* E = cast<CXXConstructExpr>(Exp);
+ const CXXConstructorDecl *CD = E->getConstructor();
+ RunCleanupsScope Scope(*this);
+
+ // If we require zero initialization before (or instead of) calling the
+ // constructor, as can be the case with a non-user-provided default
+ // constructor, emit the zero initialization now.
+ // FIXME. Do I still need this for a copy ctor synthesis?
+ if (E->requiresZeroInitialization())
+ EmitNullInitialization(Dest, E->getType());
+
+ const ConstantArrayType *Array
+ = getContext().getAsConstantArrayType(E->getType());
+ assert (!Array && "EmitSynthesizedCXXCopyCtor - Copied-in Array");
+ EmitSynthesizedCXXCopyCtorCall(CD, Dest, Src,
+ E->arg_begin(), E->arg_end());
+}
+
/// Check whether the given operator new[] is the global placement
/// operator new[].
static bool IsPlacementOperatorNewArray(ASTContext &Ctx,