summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2018-04-27 06:57:00 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2018-04-27 06:57:00 +0000
commit1e2c681c5bc803e357a95cb211648d707edc92fd (patch)
treec5b201a9215d014827d8329feecdf85d24dc845d /test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp
parentb4f1a4acff5a558a5b3b8ca95d2fccf525f8e78a (diff)
[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. This reapplies r331016, which was reverted in r331019 because it caused an assertion to fail in EmitDelegateCallArg on a windows bot. I made changes to EmitDelegateCallArg so that it doesn't try to deactivate cleanups for structs that have trivial destructors (cleanups for those structs are never pushed to the cleanup stack in EmitParmDecl). rdar://problem/39194693 Differential Revision: https://reviews.llvm.org/D45382 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331020 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp')
-rw-r--r--test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp b/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp
new file mode 100644
index 0000000000..87d21a3461
--- /dev/null
+++ b/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc19.0.0 -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+// This code used to cause an assertion failure in EmitDelegateCallArg.
+
+// CHECK: define internal void @"?__invoke@<lambda_0>@?0??test@@YAXXZ@CA@UTrivial@@@Z"(
+// CHECK: call void @"??R<lambda_0>@?0??test@@YAXXZ@QEBA@UTrivial@@@Z"(
+
+// CHECK: define internal void @"??R<lambda_0>@?0??test@@YAXXZ@QEBA@UTrivial@@@Z"(
+
+struct Trivial {
+ int x;
+};
+
+void (*fnptr)(Trivial);
+
+void test() {
+ fnptr = [](Trivial a){ (void)a; };
+}