150 lines · cpp
1// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=NORMAL2// RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -triple=x86_64-pc-win32 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=MSVCCOMPAT3// CHECK: ; ModuleID 4 5struct A {6 inline void f();7};8 9// NORMAL-NOT: define{{.*}} void @_ZN1A1fEv10// MSVCCOMPAT-NOT: define{{.*}} void @"?f@A@@QEAAXXZ"11void A::f() { }12 13template<typename> struct B { };14 15template<> struct B<char> {16 inline void f();17};18 19// NORMAL-NOT: _ZN1BIcE1fEv20// MSVCCOMPAT-NOT: @"?f@?$B@D@@QEAAXXZ"21void B<char>::f() { }22 23// We need a final CHECK line here.24 25// NORMAL-LABEL: define{{.*}} void @_Z1fv26// MSVCCOMPAT-LABEL: define dso_local void @"?f@@YAXXZ"27void f() { }28 29inline void f1(int);30 31// NORMAL-LABEL: define linkonce_odr void @_Z2f1i32// MSVCCOMPAT-LABEL: define linkonce_odr dso_local void @"?f1@@YAXH@Z"33void f1(int) { }34 35void test_f1() { f1(17); }36 37// PR878938namespace test1 {39 template <typename T> class ClassTemplate {40 private:41 friend void T::func();42 void g() {}43 };44 45 // NORMAL-LABEL: define linkonce_odr void @_ZN5test11C4funcEv(46 // MSVCCOMPAT-LABEL: define linkonce_odr dso_local void @"?func@C@test1@@QEAAXXZ"(47 48 class C {49 public:50 void func() {51 ClassTemplate<C> ct;52 ct.g();53 }54 };55 56 void f() {57 C c;58 c.func();59 }60}61 62// PR1325263namespace test2 {64 struct A;65 void f(const A& a);66 struct A {67 friend void f(const A& a) { } 68 };69 void g() {70 A a;71 f(a);72 }73 // NORMAL-LABEL: define linkonce_odr void @_ZN5test21fERKNS_1AE74 // MSVCCOMPAT-LABEL: define linkonce_odr dso_local void @"?f@test2@@YAXAEBUA@1@@Z"75}76 77// NORMAL-NOT: _Z17ExternAndInlineFnv78// MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?ExternAndInlineFn@@YAXXZ"79extern inline void ExternAndInlineFn() {}80 81// NORMAL-NOT: _Z18InlineThenExternFnv82// MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?InlineThenExternFn@@YAXXZ"83inline void InlineThenExternFn() {}84extern void InlineThenExternFn();85 86// NORMAL-LABEL: define{{.*}} void @_Z18ExternThenInlineFnv87// MSVCCOMPAT-LABEL: define dso_local void @"?ExternThenInlineFn@@YAXXZ"88extern void ExternThenInlineFn() {}89 90// NORMAL-NOT: _Z25ExternThenInlineThenDefFnv91// MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?ExternThenInlineThenDefFn@@YAXXZ"92extern void ExternThenInlineThenDefFn();93inline void ExternThenInlineThenDefFn();94void ExternThenInlineThenDefFn() {}95 96// NORMAL-NOT: _Z25InlineThenExternThenDefFnv97// MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?InlineThenExternThenDefFn@@YAXXZ"98inline void InlineThenExternThenDefFn();99extern void InlineThenExternThenDefFn();100void InlineThenExternThenDefFn() {}101 102// NORMAL-NOT: _Z17ExternAndConstexprFnv103// MSVCCOMPAT-LABEL: define weak_odr dso_local noundef i32 @"?ExternAndConstexprFn@@YAHXZ"104extern constexpr int ExternAndConstexprFn() { return 0; }105 106// NORMAL-NOT: _Z11ConstexprFnv107// MSVCCOMPAT-NOT: @"?ConstexprFn@@YAHXZ"108constexpr int ConstexprFn() { return 0; }109 110template <typename T>111extern inline void ExternInlineOnPrimaryTemplate(T);112 113// NORMAL-LABEL: define{{.*}} void @_Z29ExternInlineOnPrimaryTemplateIiEvT_114// MSVCCOMPAT-LABEL: define dso_local void @"??$ExternInlineOnPrimaryTemplate@H@@YAXH@Z"115template <>116void ExternInlineOnPrimaryTemplate(int) {}117 118template <typename T>119extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(T);120 121// NORMAL-NOT: _Z46ExternInlineOnPrimaryTemplateAndSpecializationIiEvT_122// MSVCCOMPAT-LABEL: define weak_odr dso_local void @"??$ExternInlineOnPrimaryTemplateAndSpecialization@H@@YAXH@Z"123template <>124extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(int) {}125 126struct TypeWithInlineMethods {127 // NORMAL-NOT: _ZN21TypeWithInlineMethods9StaticFunEv128 // MSVCCOMPAT-NOT: @"?StaticFun@TypeWithInlineMethods@@SAXXZ"129 static void StaticFun() {}130 // NORMAL-NOT: _ZN21TypeWithInlineMethods12NonStaticFunEv131 // MSVCCOMPAT-NOT: @"?NonStaticFun@TypeWithInlineMethods@@QEAAXXZ"132 void NonStaticFun() { StaticFun(); }133};134 135namespace PR22959 {136template <typename>137struct S;138 139S<int> Foo();140 141template <typename>142struct S {143 friend S<int> Foo();144};145 146__attribute__((used)) inline S<int> Foo() { return S<int>(); }147// NORMAL-LABEL: define linkonce_odr void @_ZN7PR229593FooEv(148// MSVCCOMPAT-LABEL: define linkonce_odr dso_local i8 @"?Foo@PR22959@@YA?AU?$S@H@1@XZ"(149}150