[cfe-commits] r71774 - in /cfe/trunk: lib/CodeGen/CGBlocks.h test/CodeGenObjC/blocks.m

Daniel Dunbar daniel at zuster.org
Thu May 14 09:42:18 PDT 2009


Author: ddunbar
Date: Thu May 14 11:42:16 2009
New Revision: 71774

URL: http://llvm.org/viewvc/llvm-project?rev=71774&view=rev
Log:
Skip the asm prefix when storing the name in block info.
 - Otherwise we emit internal names with embedded '\01' characters,
   which confuses some tools.

 - Ideally all the code which wants to get a "display name" for the
   given function should follow one code path, but this should be a
   monotonic improvement for now.

Modified:
    cfe/trunk/lib/CodeGen/CGBlocks.h
    cfe/trunk/test/CodeGenObjC/blocks.m

Modified: cfe/trunk/lib/CodeGen/CGBlocks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.h?rev=71774&r1=71773&r2=71774&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.h (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.h Thu May 14 11:42:16 2009
@@ -140,7 +140,7 @@
     /// BlockLiteralTy - The type of the block literal.
     const llvm::Type *BlockLiteralTy;
 
-    /// Name - the name of the function this block was created for, if any
+    /// Name - the name of the function this block was created for, if any.
     const char *Name;
 
     /// ByCopyDeclRefs - Variables from parent scopes that have been imported
@@ -152,7 +152,11 @@
     llvm::SmallVector<const BlockDeclRefExpr *, 8> ByRefDeclRefs;
     
     BlockInfo(const llvm::Type *blt, const char *n)
-      : BlockLiteralTy(blt), Name(n) {}
+      : BlockLiteralTy(blt), Name(n) {
+      // Skip asm prefix, if any.
+      if (Name && Name[0] == '\01')
+        ++Name;
+    }
   };
 
   CGBuilderTy &Builder;

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

==============================================================================
--- cfe/trunk/test/CodeGenObjC/blocks.m (original)
+++ cfe/trunk/test/CodeGenObjC/blocks.m Thu May 14 11:42:16 2009
@@ -1,4 +1,4 @@
-// RUN: clang-cc -emit-llvm -fblocks -S -o - %s
+// RUN: clang-cc -triple i386-apple-darwin9 -emit-llvm -fblocks -o %t %s &&
 // rdar://6676764
 
 struct S {
@@ -19,9 +19,18 @@
 -(void) im0;
 @end
 
+// RUN: grep 'define internal i32 @"__-\[A im0\]_block_invoke_"' %t &&
+ at implementation A
+-(void) im0 {
+  (void) ^{ return 1; }();
+}
+ at end
+
 @interface B : A @end
 @implementation B
 -(void) im1 {
   ^(void) { [super im0]; }();
 }
 @end
+
+// RUN: true





More information about the cfe-commits mailing list