[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / dso-local-executable.cpp
blobd021a6a06f0f073903f9a3c427a757eef42b9bff
1 // RUN: %clang_cc1 -triple x86_64-pc-linux -mrelocation-model static -O1 -disable-llvm-passes -emit-llvm %s -o - | FileCheck --check-prefix=STATIC %s
2 // RUN: %clang_cc1 -triple x86_64-pc-linux -mrelocation-model static -fno-plt -O1 -disable-llvm-passes -emit-llvm %s -o - | FileCheck --check-prefix=NOPLT %s
3 // RUN: %clang_cc1 -triple x86_64-w64-mingw32 -O1 -disable-llvm-passes -emit-llvm %s -o - | FileCheck --check-prefix=MINGW %s
5 // STATIC-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
6 // STATIC-DAG: @_ZTS1C = linkonce_odr dso_local constant
7 // STATIC-DAG: @_ZTI1C = linkonce_odr dso_local constant
8 // STATIC-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
9 // STATIC-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
10 // STATIC-DAG: define dso_local void @_ZN1CC2Ev(
11 // STATIC-DAG: define dso_local void @_ZN1CC1Ev(
12 // STATIC-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
14 // NOPLT-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
15 // NOPLT-DAG: @_ZTS1C = linkonce_odr dso_local constant
16 // NOPLT-DAG: @_ZTI1C = linkonce_odr dso_local constant
17 // NOPLT-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
18 // NOPLT-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
19 // NOPLT-DAG: define dso_local void @_ZN1CC2Ev(
20 // NOPLT-DAG: define dso_local void @_ZN1CC1Ev(
21 // NOPLT-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
23 // MINGW-DAG: @_ZTV1C = linkonce_odr dso_local unnamed_addr constant
24 // MINGW-DAG: @_ZTS1C = linkonce_odr dso_local constant
25 // MINGW-DAG: @_ZTI1C = linkonce_odr dso_local constant
26 // MINGW-DAG: @_ZZ14useStaticLocalvE3obj = linkonce_odr dso_local global
27 // MINGW-DAG: @_ZGVZN5guard1gEvE1a = linkonce_odr dso_local global
28 // MINGW-DAG: define dso_local void @_ZN1CC2Ev(
29 // MINGW-DAG: define dso_local void @_ZN1CC1Ev(
30 // MINGW-DAG: define linkonce_odr dso_local void @_ZN1C3fooEv(
32 struct C {
33 C();
34 virtual void foo() {}
36 C::C() {}
38 struct HasVTable {
39 virtual void f();
41 inline HasVTable &useStaticLocal() {
42 static HasVTable obj;
43 return obj;
45 void useit() {
46 useStaticLocal();
49 namespace guard {
50 int f();
51 inline int g() {
52 static int a = f();
53 return a;
55 int h() {
56 return g();
58 } // namespace guard
61 // STATIC-DAG: @_ZN5test23barIiE1xE = available_externally dso_local constant i32
62 // STATIC-DAG: define available_externally dso_local void @_ZN5test23barIcEC1Ev(
63 // NOPLT-DAG: @_ZN5test23barIiE1xE = available_externally dso_local constant i32
64 // NOPLT-DAG: define available_externally void @_ZN5test23barIcEC1Ev(
65 // MINGW-DAG: @_ZN5test23barIiE1xE = available_externally constant i32
66 // MINGW-DAG: define available_externally dso_local void @_ZN5test23barIcEC1Ev(
67 namespace test2 {
68 void foo();
69 template <typename T>
70 struct bar {
71 virtual void zed();
72 static const int x = 42;
73 bar() { foo(); }
75 extern template class bar<char>;
76 bar<char> abc;
77 const int *getX() {
78 return &bar<int>::x;
80 } // namespace test2