[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / CodeGenCXX / inline-functions.cpp
blob549682ed094bd25cc0b60a41574d90f91da94eb5
1 // RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=NORMAL
2 // RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -triple=x86_64-pc-win32 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=MSVCCOMPAT
3 // CHECK: ; ModuleID
5 struct A {
6 inline void f();
7 };
9 // NORMAL-NOT: define{{.*}} void @_ZN1A1fEv
10 // MSVCCOMPAT-NOT: define{{.*}} void @"?f@A@@QEAAXXZ"
11 void A::f() { }
13 template<typename> struct B { };
15 template<> struct B<char> {
16 inline void f();
19 // NORMAL-NOT: _ZN1BIcE1fEv
20 // MSVCCOMPAT-NOT: @"?f@?$B@D@@QEAAXXZ"
21 void B<char>::f() { }
23 // We need a final CHECK line here.
25 // NORMAL-LABEL: define{{.*}} void @_Z1fv
26 // MSVCCOMPAT-LABEL: define dso_local void @"?f@@YAXXZ"
27 void f() { }
29 // <rdar://problem/8740363>
30 inline void f1(int);
32 // NORMAL-LABEL: define linkonce_odr void @_Z2f1i
33 // MSVCCOMPAT-LABEL: define linkonce_odr dso_local void @"?f1@@YAXH@Z"
34 void f1(int) { }
36 void test_f1() { f1(17); }
38 // PR8789
39 namespace test1 {
40 template <typename T> class ClassTemplate {
41 private:
42 friend void T::func();
43 void g() {}
46 // NORMAL-LABEL: define linkonce_odr void @_ZN5test11C4funcEv(
47 // MSVCCOMPAT-LABEL: define linkonce_odr dso_local void @"?func@C@test1@@QEAAXXZ"(
49 class C {
50 public:
51 void func() {
52 ClassTemplate<C> ct;
53 ct.g();
57 void f() {
58 C c;
59 c.func();
63 // PR13252
64 namespace test2 {
65 struct A;
66 void f(const A& a);
67 struct A {
68 friend void f(const A& a) { }
70 void g() {
71 A a;
72 f(a);
74 // NORMAL-LABEL: define linkonce_odr void @_ZN5test21fERKNS_1AE
75 // MSVCCOMPAT-LABEL: define linkonce_odr dso_local void @"?f@test2@@YAXAEBUA@1@@Z"
78 // NORMAL-NOT: _Z17ExternAndInlineFnv
79 // MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?ExternAndInlineFn@@YAXXZ"
80 extern inline void ExternAndInlineFn() {}
82 // NORMAL-NOT: _Z18InlineThenExternFnv
83 // MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?InlineThenExternFn@@YAXXZ"
84 inline void InlineThenExternFn() {}
85 extern void InlineThenExternFn();
87 // NORMAL-LABEL: define{{.*}} void @_Z18ExternThenInlineFnv
88 // MSVCCOMPAT-LABEL: define dso_local void @"?ExternThenInlineFn@@YAXXZ"
89 extern void ExternThenInlineFn() {}
91 // NORMAL-NOT: _Z25ExternThenInlineThenDefFnv
92 // MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?ExternThenInlineThenDefFn@@YAXXZ"
93 extern void ExternThenInlineThenDefFn();
94 inline void ExternThenInlineThenDefFn();
95 void ExternThenInlineThenDefFn() {}
97 // NORMAL-NOT: _Z25InlineThenExternThenDefFnv
98 // MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?InlineThenExternThenDefFn@@YAXXZ"
99 inline void InlineThenExternThenDefFn();
100 extern void InlineThenExternThenDefFn();
101 void InlineThenExternThenDefFn() {}
103 // NORMAL-NOT: _Z17ExternAndConstexprFnv
104 // MSVCCOMPAT-LABEL: define weak_odr dso_local noundef i32 @"?ExternAndConstexprFn@@YAHXZ"
105 extern constexpr int ExternAndConstexprFn() { return 0; }
107 // NORMAL-NOT: _Z11ConstexprFnv
108 // MSVCCOMPAT-NOT: @"?ConstexprFn@@YAHXZ"
109 constexpr int ConstexprFn() { return 0; }
111 template <typename T>
112 extern inline void ExternInlineOnPrimaryTemplate(T);
114 // NORMAL-LABEL: define{{.*}} void @_Z29ExternInlineOnPrimaryTemplateIiEvT_
115 // MSVCCOMPAT-LABEL: define dso_local void @"??$ExternInlineOnPrimaryTemplate@H@@YAXH@Z"
116 template <>
117 void ExternInlineOnPrimaryTemplate(int) {}
119 template <typename T>
120 extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(T);
122 // NORMAL-NOT: _Z46ExternInlineOnPrimaryTemplateAndSpecializationIiEvT_
123 // MSVCCOMPAT-LABEL: define weak_odr dso_local void @"??$ExternInlineOnPrimaryTemplateAndSpecialization@H@@YAXH@Z"
124 template <>
125 extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(int) {}
127 struct TypeWithInlineMethods {
128 // NORMAL-NOT: _ZN21TypeWithInlineMethods9StaticFunEv
129 // MSVCCOMPAT-NOT: @"?StaticFun@TypeWithInlineMethods@@SAXXZ"
130 static void StaticFun() {}
131 // NORMAL-NOT: _ZN21TypeWithInlineMethods12NonStaticFunEv
132 // MSVCCOMPAT-NOT: @"?NonStaticFun@TypeWithInlineMethods@@QEAAXXZ"
133 void NonStaticFun() { StaticFun(); }
136 namespace PR22959 {
137 template <typename>
138 struct S;
140 S<int> Foo();
142 template <typename>
143 struct S {
144 friend S<int> Foo();
147 __attribute__((used)) inline S<int> Foo() { return S<int>(); }
148 // NORMAL-LABEL: define linkonce_odr void @_ZN7PR229593FooEv(
149 // MSVCCOMPAT-LABEL: define linkonce_odr dso_local i8 @"?Foo@PR22959@@YA?AU?$S@H@1@XZ"(