2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
|
2010-01-26 12:02:23 +08:00
|
|
|
|
|
|
|
// CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
|
2010-02-07 10:03:08 +08:00
|
|
|
|
2011-03-22 14:58:49 +08:00
|
|
|
// CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 16
|
2010-05-25 12:30:21 +08:00
|
|
|
// CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0
|
|
|
|
// CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0
|
2010-02-07 10:03:08 +08:00
|
|
|
|
2009-08-09 05:45:14 +08:00
|
|
|
struct A {
|
|
|
|
A();
|
|
|
|
~A();
|
|
|
|
};
|
|
|
|
|
|
|
|
void f() {
|
2011-09-14 06:21:56 +08:00
|
|
|
// CHECK: load atomic i8* bitcast (i64* @_ZGVZ1fvE1a to i8*) acquire, align 1
|
2010-05-05 23:38:32 +08:00
|
|
|
// CHECK: call i32 @__cxa_guard_acquire
|
|
|
|
// CHECK: call void @_ZN1AC1Ev
|
2009-12-10 09:05:11 +08:00
|
|
|
// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @_ZZ1fvE1a, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
|
2010-09-08 09:44:27 +08:00
|
|
|
// CHECK: call void @__cxa_guard_release
|
2009-08-09 05:45:14 +08:00
|
|
|
static A a;
|
|
|
|
}
|
|
|
|
|
2009-12-10 09:05:11 +08:00
|
|
|
void g() {
|
2009-12-17 00:59:22 +08:00
|
|
|
// CHECK: call noalias i8* @_Znwm(i64 1)
|
2009-12-10 09:05:11 +08:00
|
|
|
// CHECK: call void @_ZN1AC1Ev(
|
|
|
|
static A& a = *new A;
|
|
|
|
}
|
2010-01-26 12:02:23 +08:00
|
|
|
|
|
|
|
int a();
|
|
|
|
void h() {
|
|
|
|
static const int i = a();
|
|
|
|
}
|
2010-02-07 10:03:08 +08:00
|
|
|
|
|
|
|
inline void h2() {
|
|
|
|
static int i = a();
|
|
|
|
}
|
|
|
|
|
|
|
|
void h3() {
|
|
|
|
h2();
|
|
|
|
}
|
2010-05-04 05:39:56 +08:00
|
|
|
|
|
|
|
// PR6980: this shouldn't crash
|
|
|
|
namespace test0 {
|
|
|
|
struct A { A(); };
|
|
|
|
__attribute__((noreturn)) int throw_exception();
|
|
|
|
|
|
|
|
void test() {
|
|
|
|
throw_exception();
|
|
|
|
static A r;
|
|
|
|
}
|
|
|
|
}
|
2010-05-25 12:30:21 +08:00
|
|
|
|
|
|
|
namespace test1 {
|
2011-03-22 14:58:49 +08:00
|
|
|
// CHECK: define internal i32 @_ZN5test1L6getvarEi(
|
2010-05-25 12:30:21 +08:00
|
|
|
static inline int getvar(int index) {
|
|
|
|
static const int var[] = { 1, 0, 2, 4 };
|
|
|
|
return var[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void test() { (void) getvar(2); }
|
|
|
|
}
|