[cfe-commits] r69642 - in /cfe/trunk: include/clang/AST/Type.h include/clang/Parse/DeclSpec.h lib/Parse/ParseDecl.cpp test/CodeGenObjC/blocks-1.m

Mike Stump mrs at apple.com
Mon Apr 20 17:51:44 PDT 2009


Author: mrs
Date: Mon Apr 20 19:51:43 2009
New Revision: 69642

URL: http://llvm.org/viewvc/llvm-project?rev=69642&view=rev
Log:
Fixup codegen for write barriers for block variables.  Radar 6786715

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

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=69642&r1=69641&r2=69642&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Apr 20 19:51:43 2009
@@ -2009,7 +2009,7 @@
   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());

Modified: cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=69642&r1=69641&r2=69642&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Mon Apr 20 19:51:43 2009
@@ -561,7 +561,10 @@
     /// 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 @@
     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 @@
   
   /// 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;
   }
 

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=69642&r1=69641&r2=69642&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr 20 19:51:43 2009
@@ -1876,7 +1876,7 @@
     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

Modified: cfe/trunk/test/CodeGenObjC/blocks-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/blocks-1.m?rev=69642&r1=69641&r2=69642&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenObjC/blocks-1.m (original)
+++ cfe/trunk/test/CodeGenObjC/blocks-1.m Mon Apr 20 19:51:43 2009
@@ -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 @@
   l = weakSelf;
   weakSelf = l;
 }
+
+void (^__weak b)(void);
+
+void test2() {
+  __block int i = 0;
+  b = ^ {  ++i; };
+}





More information about the cfe-commits mailing list