]> granicus.if.org Git - clang/commitdiff
Providing support for rewriting of block copy/dispose of
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 21 Dec 2009 23:31:42 +0000 (23:31 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 21 Dec 2009 23:31:42 +0000 (23:31 +0000)
imported block variables. WIP.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91856 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/RewriteObjC.cpp

index 4ea081415fad80dd5f7cc29c40ff09b2edb4ae15..289d4d6a1a0bd8739c204b8f1f3fd536939f4cc3 100644 (file)
@@ -565,8 +565,8 @@ void RewriteObjC::Initialize(ASTContext &context) {
   Preamble += "extern \"C\" __declspec(dllexport) void *_NSConcreteGlobalBlock[32];\n";
   Preamble += "extern \"C\" __declspec(dllexport) void *_NSConcreteStackBlock[32];\n";
   Preamble += "#else\n";
-  Preamble += "__OBJC_RW_DLLIMPORT void _Block_object_assign(void *, const void *, const int);\n";
-  Preamble += "__OBJC_RW_DLLIMPORT void _Block_object_dispose(const void *, const int);\n";
+  Preamble += "__OBJC_RW_DLLIMPORT \"C\" void _Block_object_assign(void *, const void *, const int);\n";
+  Preamble += "__OBJC_RW_DLLIMPORT \"C\" void _Block_object_dispose(const void *, const int);\n";
   Preamble += "__OBJC_RW_DLLIMPORT void *_NSConcreteGlobalBlock[32];\n";
   Preamble += "__OBJC_RW_DLLIMPORT void *_NSConcreteStackBlock[32];\n";
   Preamble += "#endif\n";
@@ -3924,7 +3924,12 @@ std::string RewriteObjC::SynthesizeBlockDescriptor(std::string DescTag,
   S += " {\n  unsigned long reserved;\n";
   S += "  unsigned long Block_size;\n";
   if (hasCopy) {
-    S += "  void *copy;\n  void *dispose;\n";
+    S += "  void (*copy)(struct ";
+    S += ImplTag; S += "*, struct ";
+    S += ImplTag; S += "*);\n";
+    
+    S += "  void (*dispose)(struct ";
+    S += ImplTag; S += "*);\n";
   }
   S += "} ";
 
@@ -4331,7 +4336,9 @@ void RewriteObjC::CollectBlockDeclRefInfo(BlockExpr *Exp) {
       }
     // Find any imported blocks...they will need special attention.
     for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
-      if (BlockDeclRefs[i]->getType()->isBlockPointerType()) {
+      if (BlockDeclRefs[i]->isByRef() ||
+          BlockDeclRefs[i]->getType()->isObjCObjectPointerType() || 
+          BlockDeclRefs[i]->getType()->isBlockPointerType()) {
         GetBlockCallExprs(BlockDeclRefs[i]);
         ImportedBlockDecls.insert(BlockDeclRefs[i]->getDecl());
       }