[llvm-branch-commits] [cfe-branch] r121540 - in /cfe/branches/Apple/whitney: lib/CodeGen/CGBlocks.cpp lib/CodeGen/CGBlocks.h lib/Sema/SemaExpr.cpp test/CodeGenObjC/block-var-layout.m test/CodeGenObjCXX/block-var-layout.mm

Daniel Dunbar daniel at zuster.org
Fri Dec 10 13:37:02 PST 2010


Author: ddunbar
Date: Fri Dec 10 15:37:02 2010
New Revision: 121540

URL: http://llvm.org/viewvc/llvm-project?rev=121540&view=rev
Log:
Merge r118745:
--
Author: Fariborz Jahanian <fjahanian at apple.com>
Date:   Thu Nov 11 00:11:38 2010 +0000

    Adding couple of Block API, a bug fix and
    a test change, all for blocks. wip.

Added:
    cfe/branches/Apple/whitney/test/CodeGenObjCXX/block-var-layout.mm
      - copied, changed from r121539, cfe/branches/Apple/whitney/test/CodeGenObjC/block-var-layout.m
Modified:
    cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.cpp
    cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.h
    cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp
    cfe/branches/Apple/whitney/test/CodeGenObjC/block-var-layout.m

Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.cpp?rev=121540&r1=121539&r2=121540&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.cpp Fri Dec 10 15:37:02 2010
@@ -311,11 +311,10 @@
       }
 
       const BlockDeclRefExpr *BDRE = cast<BlockDeclRefExpr>(E);
+      Note.RequiresCopying = BlockRequiresCopying(BDRE);
+      
       const ValueDecl *VD = BDRE->getDecl();
       QualType T = VD->getType();
-
-      Note.RequiresCopying = BlockRequiresCopying(T);
-
       if (BDRE->isByRef()) {
         Note.flag = BLOCK_FIELD_IS_BYREF;
         if (T.isObjCGCWeak())
@@ -563,7 +562,7 @@
   // Don't run the expensive check, unless we have to.
   if (!BlockHasCopyDispose)
     if (E->isByRef()
-        || BlockRequiresCopying(E->getType()))
+        || BlockRequiresCopying(E))
       BlockHasCopyDispose = true;
 
   const ValueDecl *D = cast<ValueDecl>(E->getDecl());

Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.h?rev=121540&r1=121539&r2=121540&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.h (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.h Fri Dec 10 15:37:02 2010
@@ -103,6 +103,9 @@
 
   bool BlockRequiresCopying(QualType Ty)
     { return getContext().BlockRequiresCopying(Ty); }
+  bool BlockRequiresCopying(const BlockDeclRefExpr *E)
+  { return E->getCopyConstructorExpr() != 0 ||
+           getContext().BlockRequiresCopying(E->getType()); }
 };
 
 class BlockFunction : public BlockBase {
@@ -197,6 +200,9 @@
 
   bool BlockRequiresCopying(QualType Ty)
     { return getContext().BlockRequiresCopying(Ty); }
+  bool BlockRequiresCopying(const BlockDeclRefExpr *E)
+  { return E->getCopyConstructorExpr() != 0 ||
+           getContext().BlockRequiresCopying(E->getType()); }
 };
 
 }  // end namespace CodeGen

Modified: cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp?rev=121540&r1=121539&r2=121540&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp Fri Dec 10 15:37:02 2010
@@ -1913,16 +1913,18 @@
         Expr *E = new (Context) 
                     DeclRefExpr(const_cast<ValueDecl*>(BDRE->getDecl()), T,
                                           SourceLocation());
-      
-        ExprResult Res = PerformCopyInitialization(
+        if (T->getAs<RecordType>())
+          if (!T->isUnionType()) {
+            ExprResult Res = PerformCopyInitialization(
                           InitializedEntity::InitializeBlock(VD->getLocation(), 
                                                          T, false),
                                                          SourceLocation(),
                                                          Owned(E));
-        if (!Res.isInvalid()) {
-          Res = MaybeCreateCXXExprWithTemporaries(Res.get());
-          Expr *Init = Res.takeAs<Expr>();
-          BDRE->setCopyConstructorExpr(Init);
+            if (!Res.isInvalid()) {
+              Res = MaybeCreateCXXExprWithTemporaries(Res.get());
+              Expr *Init = Res.takeAs<Expr>();
+              BDRE->setCopyConstructorExpr(Init);
+            }
         }
       }
     }

Modified: cfe/branches/Apple/whitney/test/CodeGenObjC/block-var-layout.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/CodeGenObjC/block-var-layout.m?rev=121540&r1=121539&r2=121540&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/CodeGenObjC/block-var-layout.m (original)
+++ cfe/branches/Apple/whitney/test/CodeGenObjC/block-var-layout.m Fri Dec 10 15:37:02 2010
@@ -1,7 +1,5 @@
 // RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s
 // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fobjc-gc -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s
-// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
 
 struct S {
     int i1;

Copied: cfe/branches/Apple/whitney/test/CodeGenObjCXX/block-var-layout.mm (from r121539, cfe/branches/Apple/whitney/test/CodeGenObjC/block-var-layout.m)
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/CodeGenObjCXX/block-var-layout.mm?p2=cfe/branches/Apple/whitney/test/CodeGenObjCXX/block-var-layout.mm&p1=cfe/branches/Apple/whitney/test/CodeGenObjC/block-var-layout.m&r1=121539&r2=121540&rev=121540&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/CodeGenObjC/block-var-layout.m (original)
+++ cfe/branches/Apple/whitney/test/CodeGenObjCXX/block-var-layout.mm Fri Dec 10 15:37:02 2010
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s
-// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
 // RUN: %clang_cc1 -x objective-c++ -fblocks -fobjc-gc -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s
 // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
 
+
 struct S {
     int i1;
     id o1;
@@ -141,11 +140,11 @@
 // CHECK-LP64: L_OBJC_CLASS_NAME_11:
 // CHECK-LP64-NEXT: .asciz   "\001A\021\021"
 
-// CHECK-LP64: L_OBJC_CLASS_NAME_14:
+// CHECK-LP64: L_OBJC_CLASS_NAME_16:
 // CHECK-LP64-NEXT: .asciz   "\001A\021\022p"
 
-// CHECK-LP64: L_OBJC_CLASS_NAME_16:
+// CHECK-LP64: L_OBJC_CLASS_NAME_20:
 // CHECK-LP64-NEXT: .asciz   "\0013"
 
-// CHECK-LP64: L_OBJC_CLASS_NAME_20:
+// CHECK-LP64: L_OBJC_CLASS_NAME_24:
 // CHECK-LP64-NEXT: .asciz   "\001"





More information about the llvm-branch-commits mailing list