[cfe-commits] r129004 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp test/CodeGenObjC/atomic-aggregate-property.m

Fariborz Jahanian fjahanian at apple.com
Wed Apr 6 09:05:26 PDT 2011


Author: fjahanian
Date: Wed Apr  6 11:05:26 2011
New Revision: 129004

URL: http://llvm.org/viewvc/llvm-project?rev=129004&view=rev
Log:
Refine rules for atomic property api to
pass a previously failing clang test.
// rdar://8808439

Modified:
    cfe/trunk/lib/CodeGen/CGObjC.cpp
    cfe/trunk/test/CodeGenObjC/atomic-aggregate-property.m

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=129004&r1=129003&r2=129004&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Wed Apr  6 11:05:26 2011
@@ -293,7 +293,10 @@
         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 @@
            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 @@
              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))) ||

Modified: cfe/trunk/test/CodeGenObjC/atomic-aggregate-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/atomic-aggregate-property.m?rev=129004&r1=129003&r2=129004&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/atomic-aggregate-property.m (original)
+++ cfe/trunk/test/CodeGenObjC/atomic-aggregate-property.m Wed Apr  6 11:05:26 2011
@@ -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 @@
 @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





More information about the cfe-commits mailing list