diff options
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 19 | ||||
-rw-r--r-- | test/CodeGenObjC/atomic-aggregate-property.m | 3 |
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index fed19b4267..cfe566e6f0 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -293,7 +293,10 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP, GenerateObjCGetterBody(Ivar, IsAtomic, IsStrong); } else { - if (PID->getGetterCXXConstructor()) { + const CXXRecordDecl *classDecl = IVART->getAsCXXRecordDecl(); + + if (PID->getGetterCXXConstructor() && + classDecl && !classDecl->hasTrivialConstructor()) { ReturnStmt *Stmt = new (getContext()) ReturnStmt(SourceLocation(), PID->getGetterCXXConstructor(), @@ -379,6 +382,18 @@ void CodeGenFunction::GenerateObjCAtomicSetterBody(ObjCMethodDecl *OMD, GetCopyStructFn, ReturnValueSlot(), Args); } +static bool +IvarAssignHasTrvialAssignment(const ObjCPropertyImplDecl *PID, + QualType IvarT) { + bool HasTrvialAssignment = true; + if (PID->getSetterCXXAssignment()) { + const CXXRecordDecl *classDecl = IvarT->getAsCXXRecordDecl(); + HasTrvialAssignment = + (!classDecl || classDecl->hasTrivialCopyAssignment()); + } + return HasTrvialAssignment; +} + /// GenerateObjCSetter - Generate an Objective-C property setter /// function. The given Decl must be an ObjCImplementationDecl. @synthesize /// is illegal within a category. @@ -448,7 +463,7 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP, ReturnValueSlot(), Args); } else if (IsAtomic && hasAggregateLLVMType(IVART) && !IVART->isAnyComplexType() && - !PID->getGetterCXXConstructor() && + IvarAssignHasTrvialAssignment(PID, IVART) && ((Triple.getArch() == llvm::Triple::x86 && (getContext().getTypeSizeInChars(IVART) > CharUnits::fromQuantity(4))) || diff --git a/test/CodeGenObjC/atomic-aggregate-property.m b/test/CodeGenObjC/atomic-aggregate-property.m index 2896d379e7..3cd12a5c2c 100644 --- a/test/CodeGenObjC/atomic-aggregate-property.m +++ b/test/CodeGenObjC/atomic-aggregate-property.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s // rdar: // 7849824 struct s { @@ -22,7 +23,7 @@ struct s1 { @synthesize y; @synthesize z; @end - // CHECK-LP64: call void @objc_copyStruct // CHECK-LP64: call void @objc_copyStruct // CHECK-LP64: call void @objc_copyStruct +// CHECK-LP64: call i8* @objc_memmove_collectable |