[clang] b78045c - Add a C++ test case for https://reviews.llvm.org/D86854

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 20 07:34:58 PDT 2020


Author: Akira Hatanaka
Date: 2020-10-20T07:34:38-07:00
New Revision: b78045c2ce2dba9b43c0e48340c2a69e444386ec

URL: https://github.com/llvm/llvm-project/commit/b78045c2ce2dba9b43c0e48340c2a69e444386ec
DIFF: https://github.com/llvm/llvm-project/commit/b78045c2ce2dba9b43c0e48340c2a69e444386ec.diff

LOG: 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.

Added: 
    

Modified: 
    clang/test/CodeGenCXX/exceptions.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/CodeGenCXX/exceptions.cpp b/clang/test/CodeGenCXX/exceptions.cpp
index c2df30844bce9..7cbd21da63c45 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<const A &>(A()) : static_cast<const A &>(A());
+}
+
+}
+
 // CHECK98: attributes [[NI_NR_NUW]] = { noinline noreturn nounwind }


        


More information about the cfe-commits mailing list