1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - %s | opt -instnamer -S | FileCheck %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc struct A { 4*f4a2713aSLionel Sambuc A(); 5*f4a2713aSLionel Sambuc A(const A&); 6*f4a2713aSLionel Sambuc ~A(); 7*f4a2713aSLionel Sambuc }; 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc struct B { 10*f4a2713aSLionel Sambuc B(); 11*f4a2713aSLionel Sambuc B(const B&); 12*f4a2713aSLionel Sambuc ~B(); 13*f4a2713aSLionel Sambuc }; 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambuc struct C { 16*f4a2713aSLionel Sambuc C(); 17*f4a2713aSLionel Sambuc C(const C&); 18*f4a2713aSLionel Sambuc ~C(); 19*f4a2713aSLionel Sambuc }; 20*f4a2713aSLionel Sambuc 21*f4a2713aSLionel Sambuc struct D { 22*f4a2713aSLionel Sambuc D(); 23*f4a2713aSLionel Sambuc D(const D&); 24*f4a2713aSLionel Sambuc ~D(); 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc B *begin(); 27*f4a2713aSLionel Sambuc B *end(); 28*f4a2713aSLionel Sambuc }; 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc B *begin(C&); 31*f4a2713aSLionel Sambuc B *end(C&); 32*f4a2713aSLionel Sambuc 33*f4a2713aSLionel Sambuc extern B array[5]; 34*f4a2713aSLionel Sambuc 35*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z9for_arrayv( for_array()36*f4a2713aSLionel Sambucvoid for_array() { 37*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) 38*f4a2713aSLionel Sambuc A a; 39*f4a2713aSLionel Sambuc for (B b : array) { 40*f4a2713aSLionel Sambuc // CHECK-NOT: 5begin 41*f4a2713aSLionel Sambuc // CHECK-NOT: 3end 42*f4a2713aSLionel Sambuc // CHECK: getelementptr {{.*}}, i32 0 43*f4a2713aSLionel Sambuc // CHECK: getelementptr {{.*}}, i64 5 44*f4a2713aSLionel Sambuc // CHECK: br label %[[COND:.*]] 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc // CHECK: [[COND]]: 47*f4a2713aSLionel Sambuc // CHECK: %[[CMP:.*]] = icmp ne 48*f4a2713aSLionel Sambuc // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[END:.*]] 49*f4a2713aSLionel Sambuc 50*f4a2713aSLionel Sambuc // CHECK: [[BODY]]: 51*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1BC1ERKS_( 52*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1BD1Ev( 53*f4a2713aSLionel Sambuc // CHECK: br label %[[INC:.*]] 54*f4a2713aSLionel Sambuc 55*f4a2713aSLionel Sambuc // CHECK: [[INC]]: 56*f4a2713aSLionel Sambuc // CHECK: getelementptr {{.*}} i32 1 57*f4a2713aSLionel Sambuc // CHECK: br label %[[COND]] 58*f4a2713aSLionel Sambuc } 59*f4a2713aSLionel Sambuc // CHECK: [[END]]: 60*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]]) 61*f4a2713aSLionel Sambuc // CHECK: ret void 62*f4a2713aSLionel Sambuc } 63*f4a2713aSLionel Sambuc 64*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z9for_rangev( for_range()65*f4a2713aSLionel Sambucvoid for_range() { 66*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) 67*f4a2713aSLionel Sambuc A a; 68*f4a2713aSLionel Sambuc for (B b : C()) { 69*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1CC1Ev( 70*f4a2713aSLionel Sambuc // CHECK: = call %struct.B* @_Z5beginR1C( 71*f4a2713aSLionel Sambuc // CHECK: = call %struct.B* @_Z3endR1C( 72*f4a2713aSLionel Sambuc // CHECK: br label %[[COND:.*]] 73*f4a2713aSLionel Sambuc 74*f4a2713aSLionel Sambuc // CHECK: [[COND]]: 75*f4a2713aSLionel Sambuc // CHECK: %[[CMP:.*]] = icmp ne 76*f4a2713aSLionel Sambuc // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]] 77*f4a2713aSLionel Sambuc 78*f4a2713aSLionel Sambuc // CHECK: [[CLEANUP]]: 79*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1CD1Ev( 80*f4a2713aSLionel Sambuc // CHECK: br label %[[END:.*]] 81*f4a2713aSLionel Sambuc 82*f4a2713aSLionel Sambuc // CHECK: [[BODY]]: 83*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1BC1ERKS_( 84*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1BD1Ev( 85*f4a2713aSLionel Sambuc // CHECK: br label %[[INC:.*]] 86*f4a2713aSLionel Sambuc 87*f4a2713aSLionel Sambuc // CHECK: [[INC]]: 88*f4a2713aSLionel Sambuc // CHECK: getelementptr {{.*}} i32 1 89*f4a2713aSLionel Sambuc // CHECK: br label %[[COND]] 90*f4a2713aSLionel Sambuc } 91*f4a2713aSLionel Sambuc // CHECK: [[END]]: 92*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]]) 93*f4a2713aSLionel Sambuc // CHECK: ret void 94*f4a2713aSLionel Sambuc } 95*f4a2713aSLionel Sambuc 96*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z16for_member_rangev( for_member_range()97*f4a2713aSLionel Sambucvoid for_member_range() { 98*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]]) 99*f4a2713aSLionel Sambuc A a; 100*f4a2713aSLionel Sambuc for (B b : D()) { 101*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1DC1Ev( 102*f4a2713aSLionel Sambuc // CHECK: = call %struct.B* @_ZN1D5beginEv( 103*f4a2713aSLionel Sambuc // CHECK: = call %struct.B* @_ZN1D3endEv( 104*f4a2713aSLionel Sambuc // CHECK: br label %[[COND:.*]] 105*f4a2713aSLionel Sambuc 106*f4a2713aSLionel Sambuc // CHECK: [[COND]]: 107*f4a2713aSLionel Sambuc // CHECK: %[[CMP:.*]] = icmp ne 108*f4a2713aSLionel Sambuc // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]] 109*f4a2713aSLionel Sambuc 110*f4a2713aSLionel Sambuc // CHECK: [[CLEANUP]]: 111*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1DD1Ev( 112*f4a2713aSLionel Sambuc // CHECK: br label %[[END:.*]] 113*f4a2713aSLionel Sambuc 114*f4a2713aSLionel Sambuc // CHECK: [[BODY]]: 115*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1BC1ERKS_( 116*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1BD1Ev( 117*f4a2713aSLionel Sambuc // CHECK: br label %[[INC:.*]] 118*f4a2713aSLionel Sambuc 119*f4a2713aSLionel Sambuc // CHECK: [[INC]]: 120*f4a2713aSLionel Sambuc // CHECK: getelementptr {{.*}} i32 1 121*f4a2713aSLionel Sambuc // CHECK: br label %[[COND]] 122*f4a2713aSLionel Sambuc } 123*f4a2713aSLionel Sambuc // CHECK: [[END]]: 124*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]]) 125*f4a2713aSLionel Sambuc // CHECK: ret void 126*f4a2713aSLionel Sambuc } 127