From: Akira Hatanaka Date: Tue, 20 Oct 2020 14:34:38 +0000 (-0700) Subject: Add a C++ test case for https://reviews.llvm.org/D86854 X-Git-Tag: llvmorg-13-init~8725 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b78045c2ce2dba9b43c0e48340c2a69e444386ec;p=platform%2Fupstream%2Fllvm.git Add a C++ test case for https://reviews.llvm.org/D86854 The test case was part of https://reviews.llvm.org/D82999, which was abandoned after https://reviews.llvm.org/D86854 fixed the bug. --- diff --git a/clang/test/CodeGenCXX/exceptions.cpp b/clang/test/CodeGenCXX/exceptions.cpp index c2df308..7cbd21d 100644 --- a/clang/test/CodeGenCXX/exceptions.cpp +++ b/clang/test/CodeGenCXX/exceptions.cpp @@ -1,6 +1,8 @@ // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -std=c++98 -o - -fcxx-exceptions -fexceptions | FileCheck -check-prefix=CHECK -check-prefix=CHECK98 %s // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -std=c++11 -o - -fcxx-exceptions -fexceptions | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s +// CHECK: %[[STRUCT_TEST13_A:.*]] = type { i32, i32 } + typedef __typeof(sizeof(0)) size_t; // Declare the reserved global placement new. @@ -594,4 +596,41 @@ namespace test12 { // CHECK11: call void @_ZN6test121AdlEPvS1_(i8* [[PTR]], i8* [[PTR]]) } +namespace test13 { + +struct A { + A(); + ~A(); + int a, b; +}; + +// CHECK: define void @_ZN6test134testEi( +// CHECK: %[[REF_TMP:.*]] = alloca %[[STRUCT_TEST13_A]], align 4 +// CHECK: %[[CLEANUP_COND:.*]] = alloca i1, align 1 +// CHECK: %[[REF_TMP1:.*]] = alloca %[[STRUCT_TEST13_A]], align 4 +// CHECK: %[[CLEANUP_COND2:.*]] = alloca i1, align 1 + +// CHECK: call void @_ZN6test131AC1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP]]) +// CHECK: store i1 true, i1* %[[CLEANUP_COND]], align 1 +// CHECK: br + +// CHECK: invoke void @_ZN6test131AC1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP1]]) + +// CHECK: store i1 true, i1* %[[CLEANUP_COND2]], align 1 +// CHECK: br + +// Check the flag before destructing the temporary. + +// CHECK: landingpad { i8*, i32 } +// CHECK: %[[CLEANUP_IS_ACTIVE:.*]] = load i1, i1* %[[CLEANUP_COND]], align 1 +// CHECK: br i1 %[[CLEANUP_IS_ACTIVE]], + +// CHECK: void @_ZN6test131AD1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP]]) + +void test(int c) { + const A &s = c ? static_cast(A()) : static_cast(A()); +} + +} + // CHECK98: attributes [[NI_NR_NUW]] = { noinline noreturn nounwind }