aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-10-28 20:55:41 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-10-28 20:55:41 +0000
commitae013b9da64b48f22ca82828aa3c7a909f99dbd7 (patch)
tree20c3b5526fa356b3a19357141b9c8ed4dc4783ba /lib/CodeGen/CGCXX.cpp
parentf96b524306ccfa623235d375deee79637bd38f29 (diff)
Code gen for array construction - WIP
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85432 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r--lib/CodeGen/CGCXX.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index cfa669dc4b..345eacb673 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -594,8 +594,11 @@ CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest,
// For a copy constructor, even if it is trivial, must fall thru so
// its argument is code-gen'ed.
if (!CD->isCopyConstructor(getContext())) {
+ QualType InitType = E->getType();
+ if (const ArrayType *Array = getContext().getAsArrayType(InitType))
+ InitType = getContext().getBaseElementType(Array);
const CXXRecordDecl *RD =
- cast<CXXRecordDecl>(E->getType()->getAs<RecordType>()->getDecl());
+ cast<CXXRecordDecl>(InitType->getAs<RecordType>()->getDecl());
if (RD->hasTrivialConstructor())
return;
}
@@ -606,9 +609,19 @@ CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest,
EmitAggExpr((*i), Dest, false);
return;
}
- // Call the constructor.
- EmitCXXConstructorCall(CD, Ctor_Complete, Dest,
- E->arg_begin(), E->arg_end());
+ if (const ConstantArrayType *Array =
+ getContext().getAsConstantArrayType(E->getType())) {
+ QualType BaseElementTy = getContext().getBaseElementType(Array);
+ const llvm::Type *BasePtr = ConvertType(BaseElementTy);
+ BasePtr = llvm::PointerType::getUnqual(BasePtr);
+ llvm::Value *BaseAddrPtr =
+ Builder.CreateBitCast(Dest, BasePtr);
+ EmitCXXAggrConstructorCall(CD, Array, BaseAddrPtr);
+ }
+ else
+ // Call the constructor.
+ EmitCXXConstructorCall(CD, Ctor_Complete, Dest,
+ E->arg_begin(), E->arg_end());
}
void CodeGenModule::EmitCXXConstructors(const CXXConstructorDecl *D) {