]> granicus.if.org Git - clang/commitdiff
Fixup codegen for write barriers for block variables. Radar 6786715
authorMike Stump <mrs@apple.com>
Tue, 21 Apr 2009 00:51:43 +0000 (00:51 +0000)
committerMike Stump <mrs@apple.com>
Tue, 21 Apr 2009 00:51:43 +0000 (00:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69642 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Type.h
include/clang/Parse/DeclSpec.h
lib/Parse/ParseDecl.cpp
test/CodeGenObjC/blocks-1.m

index 62750087c0673f58a4afbe3707204b11fde733bb..d5d607fde9517c8e6291a07caadb9ae859522769 100644 (file)
@@ -2009,7 +2009,7 @@ inline bool Type::isPointerType() const {
   return isa<PointerType>(CanonicalType.getUnqualifiedType()); 
 }
 inline bool Type::isBlockPointerType() const {
-    return isa<BlockPointerType>(CanonicalType); 
+  return isa<BlockPointerType>(CanonicalType.getUnqualifiedType()); 
 }
 inline bool Type::isReferenceType() const {
   return isa<ReferenceType>(CanonicalType.getUnqualifiedType());
index c3c07b7f4a144a1b8f789b75218bb6b7eb6a2839..1be687be8efe6934ff50c44aa3123485d412b35e 100644 (file)
@@ -561,7 +561,10 @@ struct DeclaratorChunk {
     /// For now, sema will catch these as invalid.
     /// The type qualifiers: const/volatile/restrict.
     unsigned TypeQuals : 3;
-    void destroy() {}
+    AttributeList *AttrList;
+    void destroy() {
+      delete AttrList;
+    }
   };
 
   struct MemberPointerTypeInfo {
@@ -617,7 +620,7 @@ struct DeclaratorChunk {
     case MemberPointer: return Mem.AttrList;
     case Array:         return 0;
     case Function:      return 0;
-    case BlockPointer:  return 0; // FIXME: Do blocks have attr list?
+    case BlockPointer:  return Cls.AttrList;
     }
   }
 
@@ -672,12 +675,13 @@ struct DeclaratorChunk {
   
   /// getBlockPointer - Return a DeclaratorChunk for a block.
   ///
-  static DeclaratorChunk getBlockPointer(unsigned TypeQuals, 
-                                         SourceLocation Loc) {
+  static DeclaratorChunk getBlockPointer(unsigned TypeQuals, SourceLocation Loc,
+                                         AttributeList *AL) {
     DeclaratorChunk I;
     I.Kind          = BlockPointer;
     I.Loc           = Loc;
     I.Cls.TypeQuals = TypeQuals;
+    I.Cls.AttrList  = AL;
     return I;
   }
 
index 55355880b1483bfd1f0a2bceb04b8060880f815c..938e9655561603cdda975f2dd547e6fa277297dc 100644 (file)
@@ -1876,7 +1876,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
     else
       // Remember that we parsed a Block type, and remember the type-quals.
       D.AddTypeInfo(DeclaratorChunk::getBlockPointer(DS.getTypeQualifiers(), 
-                                                     Loc),
+                                                     Loc, DS.TakeAttributes()),
                     SourceLocation());
   } else {
     // Is a reference
index e343a58ee51d86b7e31e6a0907428b83fd668522..2b4f8faeb82ed46a094c3b71c90ced3200d6acbc 100644 (file)
@@ -1,13 +1,13 @@
 // RUN: clang-cc %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 &&
-// RUN: grep "_Block_object_dispose" %t | count 4 &&
-// RUN: grep "__copy_helper_block_" %t | count 2 &&
-// RUN: grep "__destroy_helper_block_" %t | count 2 &&
+// RUN: grep "_Block_object_dispose" %t | count 6 &&
+// RUN: grep "__copy_helper_block_" %t | count 4 &&
+// RUN: grep "__destroy_helper_block_" %t | count 4 &&
 // RUN: grep "__Block_byref_id_object_copy_" %t | count 2 &&
 // RUN: grep "__Block_byref_id_object_dispose_" %t | count 2 &&
 // RUN: grep "i32 135)" %t | count 0 &&
-// RUN: grep "_Block_object_assign" %t | count 3 &&
+// RUN: grep "_Block_object_assign" %t | count 4 &&
 // RUN: grep "objc_read_weak" %t | count 2 &&
-// RUN: grep "objc_assign_weak" %t | count 2
+// RUN: grep "objc_assign_weak" %t | count 3
 
 @interface NSDictionary @end
 
@@ -24,3 +24,10 @@ void foo() {
   l = weakSelf;
   weakSelf = l;
 }
+
+void (^__weak b)(void);
+
+void test2() {
+  __block int i = 0;
+  b = ^ {  ++i; };
+}