Compute 'this' correctly for block in lambda.
Using CurFuncDecl is both correct and simple compared to crawling
the DeclContexts of the block.
Fixes <rdar://problem/14415072>.
llvm-svn: 186210
diff --git a/clang/test/CodeGenObjCXX/lambda-expressions.mm b/clang/test/CodeGenObjCXX/lambda-expressions.mm
index acb8efb..84ebeb9 100644
--- a/clang/test/CodeGenObjCXX/lambda-expressions.mm
+++ b/clang/test/CodeGenObjCXX/lambda-expressions.mm
@@ -60,6 +60,12 @@
}
@end
+// Check lines for BlockInLambda test below
+// ARC: define internal i32 @___ZZN13BlockInLambda1X1fEvENKUlvE_clEv_block_invoke
+// ARC: [[Y:%.*]] = getelementptr inbounds %"struct.BlockInLambda::X"* {{.*}}, i32 0, i32 1
+// ARC-NEXT: [[YVAL:%.*]] = load i32* [[Y]], align 4
+// ARC-NEXT: ret i32 [[YVAL]]
+
typedef int (^fptr)();
template<typename T> struct StaticMembers {
static fptr f;
@@ -69,6 +75,18 @@
template fptr StaticMembers<float>::f;
// ARC: define linkonce_odr i32 ()* @_ZZNK13StaticMembersIfE1fMUlvE_clEvENKUlvE_cvU13block_pointerFivEEv
+namespace BlockInLambda {
+ struct X {
+ int x,y;
+ void f() {
+ [this]{return ^{return y;}();}();
+ };
+ };
+ void g(X& x) {
+ x.f();
+ };
+}
+
// ARC: attributes [[NUW]] = { nounwind{{.*}} }
// MRC: attributes [[NUW]] = { nounwind{{.*}} }