1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fcxx-exceptions -fexceptions -emit-llvm -o - | FileCheck %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc // Reduced from a crash on boost::interprocess's node_allocator_test.cpp. 4*f4a2713aSLionel Sambuc namespace test0 { 5*f4a2713aSLionel Sambuc struct A { A(); ~A(); }; 6*f4a2713aSLionel Sambuc struct V { V(const A &a = A()); ~V(); }; 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc // CHECK-LABEL: define linkonce_odr i32 @_ZN5test04testILi0EEEii 9*f4a2713aSLionel Sambuc template<int X> int test(int x) { 10*f4a2713aSLionel Sambuc // CHECK: [[RET:%.*]] = alloca i32 11*f4a2713aSLionel Sambuc // CHECK-NEXT: [[X:%.*]] = alloca i32 12*f4a2713aSLionel Sambuc // CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]], 13*f4a2713aSLionel Sambuc // CHECK-NEXT: [[Z:%.*]] = alloca [[A]] 14*f4a2713aSLionel Sambuc // CHECK-NEXT: [[EXN:%.*]] = alloca i8* 15*f4a2713aSLionel Sambuc // CHECK-NEXT: [[SEL:%.*]] = alloca i32 16*f4a2713aSLionel Sambuc // CHECK-NEXT: [[V:%.*]] = alloca [[V:%.*]]*, 17*f4a2713aSLionel Sambuc // CHECK-NEXT: [[TMP:%.*]] = alloca [[A]] 18*f4a2713aSLionel Sambuc // CHECK-NEXT: [[CLEANUPACTIVE:%.*]] = alloca i1 19*f4a2713aSLionel Sambuc // CHECK: call void @_ZN5test01AC1Ev([[A]]* [[Y]]) 20*f4a2713aSLionel Sambuc // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[Z]]) 21*f4a2713aSLionel Sambuc // CHECK: [[NEW:%.*]] = invoke noalias i8* @_Znwm(i64 1) 22*f4a2713aSLionel Sambuc // CHECK: store i1 true, i1* [[CLEANUPACTIVE]] 23*f4a2713aSLionel Sambuc // CHECK: [[NEWCAST:%.*]] = bitcast i8* [[NEW]] to [[V]]* 24*f4a2713aSLionel Sambuc // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[TMP]]) 25*f4a2713aSLionel Sambuc // CHECK: invoke void @_ZN5test01VC1ERKNS_1AE([[V]]* [[NEWCAST]], [[A]]* [[TMP]]) 26*f4a2713aSLionel Sambuc // CHECK: store i1 false, i1* [[CLEANUPACTIVE]] 27*f4a2713aSLionel Sambuc // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[TMP]]) 28*f4a2713aSLionel Sambuc A y; 29*f4a2713aSLionel Sambuc try { 30*f4a2713aSLionel Sambuc A z; 31*f4a2713aSLionel Sambuc V *v = new V(); 32*f4a2713aSLionel Sambuc 33*f4a2713aSLionel Sambuc if (x) return 1; 34*f4a2713aSLionel Sambuc } catch (int ex) { 35*f4a2713aSLionel Sambuc return 1; 36*f4a2713aSLionel Sambuc } 37*f4a2713aSLionel Sambuc return 0; 38*f4a2713aSLionel Sambuc } 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc int test() { 41*f4a2713aSLionel Sambuc return test<0>(5); 42*f4a2713aSLionel Sambuc } 43*f4a2713aSLionel Sambuc } 44