aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-04-28 22:30:33 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-04-28 22:30:33 +0000
commit9b4d4fc49f30f1caa35d680702f1921afad81971 (patch)
treea9e55cfadfeb34c5f50566151b9fbd6a1251d99d /lib/CodeGen/CGObjC.cpp
parent8ecdb65716cd7914ffb2eeee993fa9039fcd31e8 (diff)
Support for construct/destruct of ivar array
of c++ objects (NeXt runtime). radar 7900343. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102546 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGObjC.cpp')
-rw-r--r--lib/CodeGen/CGObjC.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index 3ce1a65132..4a874e22da 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -413,10 +413,9 @@ void CodeGenFunction::GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP,
CXXBaseOrMemberInitializer *IvarInit = IvarInitializers[I];
FieldDecl *Field = IvarInit->getMember();
QualType FieldType = Field->getType();
- if (CGM.getContext().getAsConstantArrayType(FieldType))
- assert(false && "Construction objc arrays NYI");
ObjCIvarDecl *Ivar = cast<ObjCIvarDecl>(Field);
- LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), Ivar, 0);
+ LValue LV = EmitLValueForIvar(TypeOfSelfObject(),
+ LoadObjCSelf(), Ivar, 0);
EmitAggExpr(IvarInit->getInit(), LV.getAddress(),
LV.isVolatileQualified(), false, true);
}
@@ -432,15 +431,27 @@ void CodeGenFunction::GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP,
for (size_t i = IvarInitializers.size(); i > 0; --i) {
FieldDecl *Field = IvarInitializers[i - 1]->getMember();
QualType FieldType = Field->getType();
- if (CGM.getContext().getAsConstantArrayType(FieldType))
- assert(false && "Destructing objc arrays NYI");
+ const ConstantArrayType *Array =
+ getContext().getAsConstantArrayType(FieldType);
+ if (Array)
+ FieldType = getContext().getBaseElementType(FieldType);
+
ObjCIvarDecl *Ivar = cast<ObjCIvarDecl>(Field);
LValue LV = EmitLValueForIvar(TypeOfSelfObject(),
LoadObjCSelf(), Ivar, 0);
const RecordType *RT = FieldType->getAs<RecordType>();
CXXRecordDecl *FieldClassDecl = cast<CXXRecordDecl>(RT->getDecl());
- EmitCXXDestructorCall(FieldClassDecl->getDestructor(CGM.getContext()),
- Dtor_Complete, LV.getAddress());
+ if (Array) {
+ const llvm::Type *BasePtr = ConvertType(FieldType);
+ BasePtr = llvm::PointerType::getUnqual(BasePtr);
+ llvm::Value *BaseAddrPtr =
+ Builder.CreateBitCast(LV.getAddress(), BasePtr);
+ EmitCXXAggrDestructorCall(FieldClassDecl->getDestructor(getContext()),
+ Array, BaseAddrPtr);
+ }
+ else
+ EmitCXXDestructorCall(FieldClassDecl->getDestructor(CGM.getContext()),
+ Dtor_Complete, LV.getAddress());
}
}
FinishFunction();