summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenObjCXX/lambda-expressions.mm
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2013-05-03 07:33:41 +0000
committerJohn McCall <rjmccall@apple.com>2013-05-03 07:33:41 +0000
commitdec348f7dbf8207a30a2a7b978f6568e2a499cbd (patch)
tree3cd321d2f0ecf328ba36812a25554a7e0502baa7 /clang/test/CodeGenObjCXX/lambda-expressions.mm
parent320fbf057c7bcdfd45b90747a9acf93cde93ec38 (diff)
downloadbcm5719-llvm-dec348f7dbf8207a30a2a7b978f6568e2a499cbd.tar.gz
bcm5719-llvm-dec348f7dbf8207a30a2a7b978f6568e2a499cbd.zip
Correctly emit certain implicit references to 'self' even within
a lambda. Bug #1 is that CGF's CurFuncDecl was "stuck" at lambda invocation functions. Fix that by generally improving getNonClosureContext to look through lambdas and captured statements but only report code contexts, which is generally what's wanted. Audit uses of CurFuncDecl and getNonClosureAncestor for correctness. Bug #2 is that lambdas weren't specially mapping 'self' when inside an ObjC method. Fix that by removing the requirement for that and using the normal EmitDeclRefLValue path in LoadObjCSelf. rdar://13800041 llvm-svn: 181000
Diffstat (limited to 'clang/test/CodeGenObjCXX/lambda-expressions.mm')
-rw-r--r--clang/test/CodeGenObjCXX/lambda-expressions.mm22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjCXX/lambda-expressions.mm b/clang/test/CodeGenObjCXX/lambda-expressions.mm
index 7c1e2e4f57f..c73e1727d63 100644
--- a/clang/test/CodeGenObjCXX/lambda-expressions.mm
+++ b/clang/test/CodeGenObjCXX/lambda-expressions.mm
@@ -38,6 +38,28 @@ void f2() { global = []{ return 3; }; }
// ARC: define internal i32 @___Z2f2v_block_invoke
// ARC: call i32 @"_ZZ2f2vENK3$_1clEv
+template <class T> void take_lambda(T &&lambda) { lambda(); }
+void take_block(void (^block)()) { block(); }
+
+// rdar://13800041
+@interface A
+- (void) test;
+@end
+@interface B : A @end
+@implementation B
+- (void) test {
+ take_block(^{
+ take_lambda([=]{
+ take_block(^{
+ take_lambda([=] {
+ [super test];
+ });
+ });
+ });
+ });
+}
+@end
+
// ARC: attributes [[NUW]] = { nounwind{{.*}} }
// MRC: attributes [[NUW]] = { nounwind{{.*}} }
OpenPOWER on IntegriCloud