diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index ad7d629..7aa1428 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -99,7 +99,10 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, llvm::APInt APNumElements(Context.getTypeSize(Context.getSizeType()), NumElements); QualType ElementType = Context.getObjCIdType().withConst(); - QualType ElementArrayType + if (getLangOpts().ObjCAutoRefCount) { + ElementType = Context.getLifetimeQualifiedType(ElementType, Qualifiers::OCL_Strong); + } + QualType ElementArrayType = Context.getConstantArrayType(ElementType, APNumElements, ArrayType::Normal, /*IndexTypeQuals=*/0); @@ -109,6 +112,23 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, if (DLE) Keys = CreateMemTemp(ElementArrayType, "keys"); + if (getLangOpts().ObjCAutoRefCount) { + CleanupKind ARCCleanup = getARCCleanupKind(); + pushDestroy(ARCCleanup, + Objects, + ElementArrayType, + CodeGenFunction::destroyARCStrongImprecise, + ARCCleanup & EHCleanup); + if (Keys) { + pushDestroy(ARCCleanup, + Keys, + ElementArrayType, + CodeGenFunction::destroyARCStrongImprecise, + ARCCleanup & EHCleanup); + } + } + + // Perform the actual initialialization of the array(s). for (uint64_t i = 0; i < NumElements; i++) { if (ALE) {