2011-10-14 06:29:44 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - %s | opt -instnamer -S | FileCheck %s
|
2011-04-15 06:09:26 +08:00
|
|
|
|
|
|
|
struct A {
|
|
|
|
A();
|
|
|
|
A(const A&);
|
|
|
|
~A();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B {
|
|
|
|
B();
|
|
|
|
B(const B&);
|
|
|
|
~B();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct C {
|
|
|
|
C();
|
|
|
|
C(const C&);
|
|
|
|
~C();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct D {
|
|
|
|
D();
|
|
|
|
D(const D&);
|
|
|
|
~D();
|
|
|
|
|
|
|
|
B *begin();
|
|
|
|
B *end();
|
|
|
|
};
|
|
|
|
|
2012-10-19 01:56:02 +08:00
|
|
|
B *begin(C&);
|
|
|
|
B *end(C&);
|
2011-04-15 06:09:26 +08:00
|
|
|
|
|
|
|
extern B array[5];
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_Z9for_arrayv(
|
2011-04-15 06:09:26 +08:00
|
|
|
void for_array() {
|
2018-10-15 23:43:00 +08:00
|
|
|
// CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]])
|
2011-04-15 06:09:26 +08:00
|
|
|
A a;
|
|
|
|
for (B b : array) {
|
|
|
|
// CHECK-NOT: 5begin
|
|
|
|
// CHECK-NOT: 3end
|
2019-02-08 23:34:12 +08:00
|
|
|
// CHECK: getelementptr {{.*}}, i64 0
|
2013-11-08 11:06:45 +08:00
|
|
|
// CHECK: getelementptr {{.*}}, i64 5
|
2011-04-15 06:09:26 +08:00
|
|
|
// CHECK: br label %[[COND:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[COND]]:
|
|
|
|
// CHECK: %[[CMP:.*]] = icmp ne
|
|
|
|
// CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[END:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[BODY]]:
|
|
|
|
// CHECK: call void @_ZN1BC1ERKS_(
|
|
|
|
// CHECK: call void @_ZN1BD1Ev(
|
|
|
|
// CHECK: br label %[[INC:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[INC]]:
|
|
|
|
// CHECK: getelementptr {{.*}} i32 1
|
|
|
|
// CHECK: br label %[[COND]]
|
|
|
|
}
|
|
|
|
// CHECK: [[END]]:
|
|
|
|
// CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]])
|
|
|
|
// CHECK: ret void
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_Z9for_rangev(
|
2011-04-15 06:09:26 +08:00
|
|
|
void for_range() {
|
2018-10-15 23:43:00 +08:00
|
|
|
// CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]])
|
2011-04-15 06:09:26 +08:00
|
|
|
A a;
|
|
|
|
for (B b : C()) {
|
|
|
|
// CHECK: call void @_ZN1CC1Ev(
|
2012-10-19 01:56:02 +08:00
|
|
|
// CHECK: = call %struct.B* @_Z5beginR1C(
|
|
|
|
// CHECK: = call %struct.B* @_Z3endR1C(
|
2011-04-15 06:09:26 +08:00
|
|
|
// CHECK: br label %[[COND:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[COND]]:
|
|
|
|
// CHECK: %[[CMP:.*]] = icmp ne
|
|
|
|
// CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[CLEANUP]]:
|
|
|
|
// CHECK: call void @_ZN1CD1Ev(
|
|
|
|
// CHECK: br label %[[END:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[BODY]]:
|
|
|
|
// CHECK: call void @_ZN1BC1ERKS_(
|
|
|
|
// CHECK: call void @_ZN1BD1Ev(
|
|
|
|
// CHECK: br label %[[INC:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[INC]]:
|
|
|
|
// CHECK: getelementptr {{.*}} i32 1
|
|
|
|
// CHECK: br label %[[COND]]
|
|
|
|
}
|
|
|
|
// CHECK: [[END]]:
|
|
|
|
// CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]])
|
|
|
|
// CHECK: ret void
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_Z16for_member_rangev(
|
2011-04-15 06:09:26 +08:00
|
|
|
void for_member_range() {
|
2018-10-15 23:43:00 +08:00
|
|
|
// CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]])
|
2011-04-15 06:09:26 +08:00
|
|
|
A a;
|
|
|
|
for (B b : D()) {
|
|
|
|
// CHECK: call void @_ZN1DC1Ev(
|
2011-07-10 01:41:47 +08:00
|
|
|
// CHECK: = call %struct.B* @_ZN1D5beginEv(
|
|
|
|
// CHECK: = call %struct.B* @_ZN1D3endEv(
|
2011-04-15 06:09:26 +08:00
|
|
|
// CHECK: br label %[[COND:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[COND]]:
|
|
|
|
// CHECK: %[[CMP:.*]] = icmp ne
|
|
|
|
// CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[CLEANUP]]:
|
|
|
|
// CHECK: call void @_ZN1DD1Ev(
|
|
|
|
// CHECK: br label %[[END:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[BODY]]:
|
|
|
|
// CHECK: call void @_ZN1BC1ERKS_(
|
|
|
|
// CHECK: call void @_ZN1BD1Ev(
|
|
|
|
// CHECK: br label %[[INC:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[INC]]:
|
|
|
|
// CHECK: getelementptr {{.*}} i32 1
|
|
|
|
// CHECK: br label %[[COND]]
|
|
|
|
}
|
|
|
|
// CHECK: [[END]]:
|
|
|
|
// CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]])
|
|
|
|
// CHECK: ret void
|
|
|
|
}
|