xref: /llvm-project/clang/test/CodeGenCXX/noexcept.cpp (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions -std=c++11 | FileCheck %s
2 
3 //   Ensure that we call __cxa_begin_catch before calling
4 //   std::terminate in a noexcept function.
5 namespace test0 {
6   void foo();
7 
8   struct A {
9     A();
10     ~A();
11   };
12 
test()13   void test() noexcept {
14     A a;
15     foo();
16   }
17 }
18 
19 // CHECK-LABEL:    define{{.*}} void @_ZN5test04testEv()
20 //   This goes to the terminate lpad.
21 // CHECK:      invoke void @_ZN5test01AC1Ev(
22 // CHECK-NEXT:   unwind label %[[TERMINATE_LPAD:.*]]
23 //   This also goes to the terminate lpad (no cleanups!).
24 // CHECK:      invoke void @_ZN5test03fooEv()
25 // CHECK-NEXT:   unwind label %[[TERMINATE_LPAD]]
26 //   Destructors don't throw by default in C++11.
27 // CHECK:      call void @_ZN5test01AD1Ev(
28 //   Cleanup lpad.
29 // CHECK: [[TERMINATE_LPAD]]:
30 // CHECK-NEXT: [[T0:%.*]] = landingpad
31 // CHECK-NEXT:   catch ptr null
32 // CHECK-NEXT: [[T1:%.*]] = extractvalue { ptr, i32 } [[T0]], 0
33 // CHECK-NEXT: call void @__clang_call_terminate(ptr [[T1]])
34 // CHECK-NEXT: unreachable
35 
36 // CHECK-LABEL:  define linkonce_odr hidden void @__clang_call_terminate(
37 // CHECK:      call ptr @__cxa_begin_catch(
38 // CHECK-NEXT: call void @_ZSt9terminatev()
39 // CHECK-NEXT: unreachable
40