Skip to content

Commit

Permalink
Add a C++ test case for https://reviews.llvm.org/D86854
Browse files Browse the repository at this point in the history
The test case was part of https://reviews.llvm.org/D82999, which was
abandoned after https://reviews.llvm.org/D86854 fixed the bug.
  • Loading branch information
ahatanaka committed Oct 20, 2020
1 parent e7a6915 commit b78045c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions 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.
Expand Down Expand Up @@ -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<const A &>(A()) : static_cast<const A &>(A());
}

}

// CHECK98: attributes [[NI_NR_NUW]] = { noinline noreturn nounwind }

0 comments on commit b78045c

Please sign in to comment.