diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-28 20:55:41 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-28 20:55:41 +0000 |
| commit | f1639fffbc2375e71a693f1eb7c5f23e9dc8901e (patch) | |
| tree | 97dc9506ea74e9c6ed2baee939418e407f1cbb0f /clang/lib/CodeGen | |
| parent | 97b93126632e6221064658b48745647ca9ca8f7a (diff) | |
| download | bcm5719-llvm-f1639fffbc2375e71a693f1eb7c5f23e9dc8901e.tar.gz bcm5719-llvm-f1639fffbc2375e71a693f1eb7c5f23e9dc8901e.zip | |
Code gen for array construction - WIP
llvm-svn: 85432
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGCXX.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index cfa669dc4b6..345eacb673e 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/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) { |

