diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-04-06 16:05:26 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-04-06 16:05:26 +0000 |
commit | 01cb307f0b84a368cdbc0738d6680aab8ed7423f (patch) | |
tree | aa24ce2bc101783f4a9aa2ee308feb38ee931cd4 /lib/CodeGen | |
parent | 6931743e29845d66d919a83db5a7b734f57ffdf2 (diff) |
Refine rules for atomic property api to
pass a previously failing clang test.
// rdar://8808439
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 19 |
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))) || |