[cfe-commits] r79640 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/constructor-init.cpp
Fariborz Jahanian
fjahanian at apple.com
Fri Aug 21 10:09:38 PDT 2009
Author: fjahanian
Date: Fri Aug 21 12:09:38 2009
New Revision: 79640
URL: http://llvm.org/viewvc/llvm-project?rev=79640&view=rev
Log:
Array member construction in prologue of user-declared
constructors.
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/test/CodeGenCXX/constructor-init.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=79640&r1=79639&r2=79640&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Fri Aug 21 12:09:38 2009
@@ -1362,8 +1362,10 @@
// non-static data member initilaizers.
FieldDecl *Field = Member->getMember();
QualType FieldType = getContext().getCanonicalType((Field)->getType());
- assert(!getContext().getAsArrayType(FieldType)
- && "FIXME. Field arrays initialization unsupported");
+ const ConstantArrayType *Array =
+ getContext().getAsConstantArrayType(FieldType);
+ if (Array)
+ FieldType = getContext().getBaseElementType(FieldType);
LoadOfThis = LoadCXXThis();
LValue LHS = EmitLValueForField(LoadOfThis, Field, false, 0);
@@ -1371,10 +1373,19 @@
if (!Field->isAnonymousStructOrUnion()) {
assert(Member->getConstructor() &&
"EmitCtorPrologue - no constructor to initialize member");
- EmitCXXConstructorCall(Member->getConstructor(),
- Ctor_Complete, LHS.getAddress(),
- Member->const_arg_begin(),
- Member->const_arg_end());
+ if (Array) {
+ const llvm::Type *BasePtr = ConvertType(FieldType);
+ BasePtr = llvm::PointerType::getUnqual(BasePtr);
+ llvm::Value *BaseAddrPtr =
+ Builder.CreateBitCast(LHS.getAddress(), BasePtr);
+ EmitCXXAggrConstructorCall(Member->getConstructor(),
+ Array, BaseAddrPtr);
+ }
+ else
+ EmitCXXConstructorCall(Member->getConstructor(),
+ Ctor_Complete, LHS.getAddress(),
+ Member->const_arg_begin(),
+ Member->const_arg_end());
continue;
}
else {
Modified: cfe/trunk/test/CodeGenCXX/constructor-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/constructor-init.cpp?rev=79640&r1=79639&r2=79640&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/constructor-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/constructor-init.cpp Fri Aug 21 12:09:38 2009
@@ -46,6 +46,9 @@
}
float ld;
float ff;
+ M arr_m[3];
+ P arr_p[1][3];
+ Q arr_q[2][3][4];
};
int main() {
More information about the cfe-commits
mailing list