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