blob: d8b789943a430942efc6869ac58f195dada10d47 [file] [log] [blame]
John McCall20bb1752012-05-01 06:13:13 +00001// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
2
3struct S {
4 S() {}
5 ~S() {}
6} s;
7
8// CHECK: define internal void [[INIT_s:@.*global_var.*]] nounwind
Timur Iskhodzhanov8f88a1d2012-07-12 09:50:54 +00009// CHECK: call x86_thiscallcc void @"\01??0S@@QAE@XZ"
John McCall20bb1752012-05-01 06:13:13 +000010// CHECK: call i32 @atexit(void ()* @"__dtor_\01?s@@3US@@A")
11// CHECK: ret void
12
13// CHECK: define internal void @"__dtor_\01?s@@3US@@A"() nounwind {
Timur Iskhodzhanov8f88a1d2012-07-12 09:50:54 +000014// CHECK: call x86_thiscallcc void @"\01??1S@@QAE@XZ"
John McCall20bb1752012-05-01 06:13:13 +000015// CHECK: ret void
16
17// Force WeakODRLinkage by using templates
18class A {
19 public:
20 A() {}
21 ~A() {}
22};
23
24template<typename T>
25class B {
26 public:
27 static A foo;
28};
29
30template<typename T> A B<T>::foo;
31
32void force_usage() {
33 (void)B<int>::foo; // (void) - force usage
34}
35
36// CHECK: define internal void [[INIT_foo:@.*global_var.*]] nounwind
Timur Iskhodzhanov8f88a1d2012-07-12 09:50:54 +000037// CHECK: call x86_thiscallcc void @"\01??0A@@QAE@XZ"
John McCall20bb1752012-05-01 06:13:13 +000038// CHECK: call i32 @atexit(void ()* [[FOO_DTOR:@"__dtor_.*foo@.*]])
39// CHECK: ret void
40
Timur Iskhodzhanov8f88a1d2012-07-12 09:50:54 +000041// CHECK: define linkonce_odr x86_thiscallcc void @"\01??0A@@QAE@XZ"
John McCall20bb1752012-05-01 06:13:13 +000042
Timur Iskhodzhanov8f88a1d2012-07-12 09:50:54 +000043// CHECK: define linkonce_odr x86_thiscallcc void @"\01??1A@@QAE@XZ"
John McCall20bb1752012-05-01 06:13:13 +000044
45// CHECK: define internal void [[FOO_DTOR]]
Timur Iskhodzhanov8f88a1d2012-07-12 09:50:54 +000046// CHECK: call x86_thiscallcc void @"\01??1A@@QAE@XZ"{{.*}}foo
John McCall20bb1752012-05-01 06:13:13 +000047// CHECK: ret void
48
49// CHECK: define internal void @_GLOBAL__I_a() nounwind {
50// CHECK: call void [[INIT_s]]
51// CHECK: call void [[INIT_foo]]
52// CHECK: ret void