2010-02-05 01:06:52 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O3 | FileCheck %s
|
2009-11-21 01:27:56 +08:00
|
|
|
|
2010-02-05 01:06:52 +08:00
|
|
|
namespace {
|
|
|
|
|
2010-02-05 01:23:15 +08:00
|
|
|
static int ctorcalls;
|
|
|
|
static int dtorcalls;
|
2010-02-05 01:06:52 +08:00
|
|
|
|
|
|
|
struct A {
|
2010-02-05 01:23:15 +08:00
|
|
|
A() : i(0) { ctorcalls++; }
|
|
|
|
~A() { dtorcalls++; }
|
2009-11-21 01:27:56 +08:00
|
|
|
int i;
|
2010-02-05 01:26:01 +08:00
|
|
|
|
|
|
|
friend const A& operator<<(const A& a, int n) {
|
|
|
|
return a;
|
|
|
|
}
|
2009-11-21 01:27:56 +08:00
|
|
|
};
|
|
|
|
|
2010-02-05 01:06:52 +08:00
|
|
|
void g(int) { }
|
2010-02-05 01:26:01 +08:00
|
|
|
void g(const A&) { }
|
2009-11-21 01:27:56 +08:00
|
|
|
|
2010-02-05 01:06:52 +08:00
|
|
|
void f1(bool b) {
|
|
|
|
g(b ? A().i : 0);
|
|
|
|
g(b || A().i);
|
|
|
|
g(b && A().i);
|
2010-02-05 01:26:01 +08:00
|
|
|
g(b ? A() << 1 : A() << 2);
|
2010-02-05 01:06:52 +08:00
|
|
|
}
|
2009-11-21 01:27:56 +08:00
|
|
|
|
2010-02-05 01:06:52 +08:00
|
|
|
struct Checker {
|
|
|
|
Checker() {
|
|
|
|
f1(true);
|
|
|
|
f1(false);
|
|
|
|
}
|
|
|
|
};
|
2009-11-21 01:27:56 +08:00
|
|
|
|
2010-02-05 01:06:52 +08:00
|
|
|
Checker c;
|
|
|
|
|
|
|
|
}
|
2009-11-21 01:27:56 +08:00
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define i32 @_Z12getCtorCallsv()
|
2010-02-05 01:23:15 +08:00
|
|
|
int getCtorCalls() {
|
2010-02-05 01:29:32 +08:00
|
|
|
// CHECK: ret i32 5
|
2010-02-05 01:23:15 +08:00
|
|
|
return ctorcalls;
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define i32 @_Z12getDtorCallsv()
|
2010-02-05 01:23:15 +08:00
|
|
|
int getDtorCalls() {
|
2010-02-05 01:29:32 +08:00
|
|
|
// CHECK: ret i32 5
|
2010-02-05 01:23:15 +08:00
|
|
|
return dtorcalls;
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define zeroext i1 @_Z7successv()
|
2010-02-05 01:23:15 +08:00
|
|
|
bool success() {
|
|
|
|
// CHECK: ret i1 true
|
|
|
|
return ctorcalls == dtorcalls;
|
2009-11-21 01:27:56 +08:00
|
|
|
}
|