summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenObjCXX/lambda-expressions.mm
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2018-04-27 04:21:51 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2018-04-27 04:21:51 +0000
commite712374496147f61ff701ee46bdd9932366521c6 (patch)
treead3b905195500be4f8400e38a45b6977533793aa /clang/test/CodeGenObjCXX/lambda-expressions.mm
parentfa7fd13cf8b33f879c2f3b80dc7e91ac0cace0bd (diff)
downloadbcm5719-llvm-e712374496147f61ff701ee46bdd9932366521c6.tar.gz
bcm5719-llvm-e712374496147f61ff701ee46bdd9932366521c6.zip
[CodeGen] Avoid destructing a callee-destructued struct type in a
function if a function delegates to another function. Fix a bug introduced in r328731, which caused a struct with ObjC __weak fields that was passed to a function to be destructed twice, once in the callee function and once in another function the callee function delegates to. To prevent this, keep track of the callee-destructed structs passed to a function and disable their cleanups at the point of the call to the delegated function. rdar://problem/39194693 Differential Revision: https://reviews.llvm.org/D45382 llvm-svn: 331016
Diffstat (limited to 'clang/test/CodeGenObjCXX/lambda-expressions.mm')
-rw-r--r--clang/test/CodeGenObjCXX/lambda-expressions.mm28
1 files changed, 27 insertions, 1 deletions
diff --git a/clang/test/CodeGenObjCXX/lambda-expressions.mm b/clang/test/CodeGenObjCXX/lambda-expressions.mm
index c8247e2e0a2..f60655c61b1 100644
--- a/clang/test/CodeGenObjCXX/lambda-expressions.mm
+++ b/clang/test/CodeGenObjCXX/lambda-expressions.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks -fobjc-arc | FileCheck -check-prefix=ARC %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks -fobjc-arc -fobjc-runtime-has-weak -DWEAK_SUPPORTED | FileCheck -check-prefix=ARC %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks | FileCheck -check-prefix=MRC %s
typedef int (^fp)();
@@ -138,5 +138,31 @@ namespace BlockInLambda {
}
@end
+// Check that the delegating invoke function doesn't destruct the Weak object
+// that is passed.
+
+// ARC-LABEL: define internal void @"_ZZN14LambdaDelegate4testEvEN3$_58__invokeENS_4WeakE"(
+// ARC: call void @"_ZZN14LambdaDelegate4testEvENK3$_5clENS_4WeakE"(
+// ARC-NEXT: ret void
+
+// ARC-LABEL: define internal void @"_ZZN14LambdaDelegate4testEvENK3$_5clENS_4WeakE"(
+// ARC: call void @_ZN14LambdaDelegate4WeakD1Ev(
+
+#ifdef WEAK_SUPPORTED
+
+namespace LambdaDelegate {
+
+struct Weak {
+ __weak id x;
+};
+
+void test() {
+ void (*p)(Weak) = [](Weak a) { };
+}
+
+};
+
+#endif
+
// ARC: attributes [[NUW]] = { noinline nounwind{{.*}} }
// MRC: attributes [[NUW]] = { noinline nounwind{{.*}} }
OpenPOWER on IntegriCloud