[cfe-commits] r107044 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp test/CodeGen/func-in-block.c

Fariborz Jahanian fjahanian at apple.com
Mon Jun 28 11:58:34 PDT 2010


Author: fjahanian
Date: Mon Jun 28 13:58:34 2010
New Revision: 107044

URL: http://llvm.org/viewvc/llvm-project?rev=107044&view=rev
Log:
Have __func__ and siblings point to block's implementation function
name. Fixes radar 7860965.

Added:
    cfe/trunk/test/CodeGen/func-in-block.c
Modified:
    cfe/trunk/lib/CodeGen/CGBlocks.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=107044&r1=107043&r2=107044&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon Jun 28 13:58:34 2010
@@ -840,11 +840,22 @@
 
   CGM.SetInternalFunctionAttributes(BD, Fn, FI);
 
+  QualType FnType(BlockFunctionType, 0);
+  bool HasPrototype = (dyn_cast<FunctionProtoType>(BlockFunctionType) != 0);
+  
+  IdentifierInfo *ID = &getContext().Idents.get(Name.getString());
+  CurCodeDecl = FunctionDecl::Create(getContext(),
+                                     getContext().getTranslationUnitDecl(),
+                                     SourceLocation(), ID, FnType, 
+                                     0,
+                                     FunctionDecl::Static,
+                                     FunctionDecl::None,
+                                     false, HasPrototype);
+  
   StartFunction(BD, ResultType, Fn, Args,
                 BExpr->getBody()->getLocEnd());
 
   CurFuncDecl = OuterFuncDecl;
-  CurCodeDecl = BD;
 
   // If we have a C++ 'this' reference, go ahead and force it into
   // existence now.

Added: cfe/trunk/test/CodeGen/func-in-block.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/func-in-block.c?rev=107044&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/func-in-block.c (added)
+++ cfe/trunk/test/CodeGen/func-in-block.c Mon Jun 28 13:58:34 2010
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-llvm -o - %s | FileCheck %s
+// rdar: // 7860965
+
+extern void PRINTF(const char *);
+extern void B(void (^)(void));
+
+int main()
+{
+    PRINTF(__func__);
+    B(
+       ^{
+            PRINTF(__func__);
+        }
+    );
+    return 0; // not reached
+}
+
+// CHECK: call void @PRINTF({{.*}}@__func__.__main_block_invoke_ 





More information about the cfe-commits mailing list