aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjC.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGObjC.cpp')
-rw-r--r--lib/CodeGen/CGObjC.cpp19
1 files changed, 17 insertions, 2 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))) ||