summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-06-28 18:58:34 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-06-28 18:58:34 +0000
commit36ad0e99d50929255011a1cf1c362f4c411e69a1 (patch)
treee45ccb2a2e8e09462bcac5edc979ea3e95dd0861 /clang
parent0d94d7af7825ad0876aef52ae8ba92f3229613e4 (diff)
downloadbcm5719-llvm-36ad0e99d50929255011a1cf1c362f4c411e69a1.tar.gz
bcm5719-llvm-36ad0e99d50929255011a1cf1c362f4c411e69a1.zip
Have __func__ and siblings point to block's implementation function
name. Fixes radar 7860965. llvm-svn: 107044
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp13
-rw-r--r--clang/test/CodeGen/func-in-block.c18
2 files changed, 30 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index d5fc993c797..5743aa0d71f 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -840,11 +840,22 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD, const BlockExpr *BExpr,
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.
diff --git a/clang/test/CodeGen/func-in-block.c b/clang/test/CodeGen/func-in-block.c
new file mode 100644
index 00000000000..27e0c096099
--- /dev/null
+++ b/clang/test/CodeGen/func-in-block.c
@@ -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_
OpenPOWER on IntegriCloud