1// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions -std=c++11 | FileCheck %s 2 3// rdar://11904428 4// Ensure that we call __cxa_begin_catch before calling 5// std::terminate in a noexcept function. 6namespace test0 { 7 void foo(); 8 9 struct A { 10 A(); 11 ~A(); 12 }; 13 14 void test() noexcept { 15 A a; 16 foo(); 17 } 18} 19// CHECK: define void @_ZN5test04testEv() 20// CHECK: [[EXN:%.*]] = alloca i8* 21// This goes to the terminate lpad. 22// CHECK: invoke void @_ZN5test01AC1Ev( 23// This goes to the cleanup-and-then-terminate lpad. 24// CHECK: invoke void @_ZN5test03fooEv() 25// Destructors don't throw by default in C++11. 26// CHECK: call void @_ZN5test01AD1Ev( 27// Cleanup lpad. 28// CHECK: [[T0:%.*]] = landingpad 29// CHECK-NEXT: catch i8* null 30// CHECK-NEXT: [[T1:%.*]] = extractvalue { i8*, i32 } [[T0]], 0 31// CHECK-NEXT: store i8* [[T1]], i8** [[EXN]] 32// (Calling this destructor is not technically required.) 33// CHECK: call void @_ZN5test01AD1Ev( 34// CHECK-NEXT: br label 35// The terminate landing pad jumps in here for some reason. 36// CHECK: [[T0:%.*]] = landingpad 37// CHECK-NEXT: catch i8* null 38// CHECK-NEXT: [[T1:%.*]] = extractvalue { i8*, i32 } [[T0]], 0 39// CHECK-NEXT: call void @__clang_call_terminate(i8* [[T1]]) 40// CHECK-NEXT: unreachable 41// The terminate handler chained to by the cleanup lpad. 42// CHECK: [[T0:%.*]] = load i8** [[EXN]] 43// CHECK-NEXT: call void @__clang_call_terminate(i8* [[T0]]) 44// CHECK-NEXT: unreachable 45 46// CHECK: define linkonce_odr hidden void @__clang_call_terminate( 47// CHECK: call i8* @__cxa_begin_catch( 48// CHECK-NEXT: call void @_ZSt9terminatev() 49// CHECK-NEXT: unreachable 50