2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
|
2009-11-25 00:43:22 +08:00
|
|
|
void *f();
|
|
|
|
|
|
|
|
template <typename T> T* g() {
|
|
|
|
if (T* t = f())
|
|
|
|
return t;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void h() {
|
|
|
|
void *a = g<void>();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct X {
|
|
|
|
X();
|
|
|
|
~X();
|
|
|
|
operator bool();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Y {
|
|
|
|
Y();
|
|
|
|
~Y();
|
|
|
|
};
|
|
|
|
|
|
|
|
void if_destruct(int z) {
|
|
|
|
// Verify that the condition variable is destroyed at the end of the
|
|
|
|
// "if" statement.
|
|
|
|
// CHECK: call void @_ZN1XC1Ev
|
|
|
|
// CHECK: call zeroext i1 @_ZN1XcvbEv
|
|
|
|
if (X x = X()) {
|
|
|
|
// CHECK: store i32 18
|
|
|
|
z = 18;
|
|
|
|
}
|
|
|
|
// CHECK: call void @_ZN1XD1Ev
|
|
|
|
// CHECK: store i32 17
|
|
|
|
z = 17;
|
|
|
|
|
|
|
|
// CHECK: call void @_ZN1XC1Ev
|
|
|
|
if (X x = X())
|
|
|
|
Y y;
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: br
|
2009-11-25 00:43:22 +08:00
|
|
|
// CHECK: call void @_ZN1YC1Ev
|
|
|
|
// CHECK: call void @_ZN1YD1Ev
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: br
|
2009-11-25 00:43:22 +08:00
|
|
|
// CHECK: call void @_ZN1XD1Ev
|
|
|
|
}
|
2009-11-25 01:07:59 +08:00
|
|
|
|
|
|
|
struct ConvertibleToInt {
|
|
|
|
ConvertibleToInt();
|
|
|
|
~ConvertibleToInt();
|
|
|
|
operator int();
|
|
|
|
};
|
|
|
|
|
|
|
|
void switch_destruct(int z) {
|
|
|
|
// CHECK: call void @_ZN16ConvertibleToIntC1Ev
|
|
|
|
switch (ConvertibleToInt conv = ConvertibleToInt()) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: {{sw.default:|:3}}
|
2009-11-25 01:07:59 +08:00
|
|
|
// CHECK: store i32 19
|
|
|
|
z = 19;
|
|
|
|
break;
|
|
|
|
}
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: {{sw.epilog:|:4}}
|
2009-11-25 01:07:59 +08:00
|
|
|
// CHECK: call void @_ZN16ConvertibleToIntD1Ev
|
|
|
|
// CHECK: store i32 20
|
|
|
|
z = 20;
|
|
|
|
}
|
2009-11-25 05:15:44 +08:00
|
|
|
|
|
|
|
int foo();
|
|
|
|
|
|
|
|
void while_destruct(int z) {
|
|
|
|
// CHECK: define void @_Z14while_destructi
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: {{while.cond:|:1}}
|
2009-11-25 05:15:44 +08:00
|
|
|
while (X x = X()) {
|
|
|
|
// CHECK: call void @_ZN1XC1Ev
|
|
|
|
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: {{while.body:|:3}}
|
2009-11-25 05:15:44 +08:00
|
|
|
// CHECK: store i32 21
|
|
|
|
z = 21;
|
|
|
|
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: {{while.cleanup:|:4}}
|
2009-11-25 05:15:44 +08:00
|
|
|
// CHECK: call void @_ZN1XD1Ev
|
|
|
|
}
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: {{while.end|:6}}
|
2009-11-25 05:15:44 +08:00
|
|
|
// CHECK: store i32 22
|
|
|
|
z = 22;
|
|
|
|
}
|
2009-11-25 08:27:52 +08:00
|
|
|
|
|
|
|
void for_destruct(int z) {
|
|
|
|
// CHECK: define void @_Z12for_destruct
|
2009-11-25 08:29:29 +08:00
|
|
|
// CHECK: call void @_ZN1YC1Ev
|
|
|
|
for(Y y = Y(); X x = X(); ++z)
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: {{for.cond:|:1}}
|
2009-11-25 09:51:31 +08:00
|
|
|
// CHECK: call void @_ZN1XC1Ev
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: {{for.body:|:3}}
|
2009-11-25 08:27:52 +08:00
|
|
|
// CHECK: store i32 23
|
|
|
|
z = 23;
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: {{for.inc:|:4}}
|
|
|
|
// CHECK: br label %{{for.cond.cleanup|7}}
|
|
|
|
// CHECK: {{for.cond.cleanup:|:7}}
|
2009-11-25 09:51:31 +08:00
|
|
|
// CHECK: call void @_ZN1XD1Ev
|
2010-01-14 04:57:29 +08:00
|
|
|
// CHECK: {{for.end:|:9}}
|
2009-11-25 08:29:29 +08:00
|
|
|
// CHECK: call void @_ZN1YD1Ev
|
2009-11-25 08:27:52 +08:00
|
|
|
// CHECK: store i32 24
|
|
|
|
z = 24;
|
|
|
|
}
|