2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -fno-rtti -emit-llvm %s -o - -triple=i386-pc-win32 >%t 2>&1
|
2013-10-09 17:23:58 +08:00
|
|
|
// RUN: FileCheck --check-prefix=MANGLING %s < %t
|
|
|
|
// RUN: FileCheck --check-prefix=XMANGLING %s < %t
|
|
|
|
// RUN: FileCheck --check-prefix=CODEGEN %s < %t
|
2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -fno-rtti -emit-llvm %s -o - -triple=x86_64-pc-win32 2>&1 | FileCheck --check-prefix=MANGLING-X64 %s
|
2013-10-09 17:23:58 +08:00
|
|
|
|
|
|
|
void foo(void *);
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
virtual ~A();
|
|
|
|
virtual void public_f();
|
|
|
|
// Make sure we don't emit unneeded thunks:
|
2018-03-17 04:36:49 +08:00
|
|
|
// XMANGLING-NOT: @"?public_f@A@@QAEXXZ"
|
2013-10-09 17:23:58 +08:00
|
|
|
protected:
|
|
|
|
virtual void protected_f();
|
|
|
|
private:
|
|
|
|
virtual void private_f();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B {
|
|
|
|
virtual ~B();
|
|
|
|
virtual void public_f();
|
|
|
|
protected:
|
|
|
|
virtual void protected_f();
|
|
|
|
private:
|
|
|
|
virtual void private_f();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct C : A, B {
|
|
|
|
C();
|
|
|
|
|
|
|
|
virtual ~C();
|
2018-03-17 04:36:49 +08:00
|
|
|
// MANGLING-DAG: declare {{.*}} @"??1C@@UAE@XZ"({{.*}})
|
|
|
|
// MANGLING-DAG: define {{.*}} @"??_GC@@UAEPAXI@Z"({{.*}})
|
|
|
|
// MANGLING-DAG: define {{.*}} @"??_EC@@W3AEPAXI@Z"({{.*}}) {{.*}} comdat
|
|
|
|
// MANGLING-X64-DAG: declare {{.*}} @"??1C@@UEAA@XZ"({{.*}})
|
|
|
|
// MANGLING-X64-DAG: define {{.*}} @"??_GC@@UEAAPEAXI@Z"({{.*}})
|
|
|
|
// MANGLING-X64-DAG: define {{.*}} @"??_EC@@W7EAAPEAXI@Z"({{.*}}) {{.*}} comdat
|
2013-10-09 17:23:58 +08:00
|
|
|
|
|
|
|
// Overrides public_f() of two subobjects with distinct vfptrs, thus needs a thunk.
|
|
|
|
virtual void public_f();
|
2018-03-17 04:36:49 +08:00
|
|
|
// MANGLING-DAG: @"?public_f@C@@UAEXXZ"
|
|
|
|
// MANGLING-DAG: @"?public_f@C@@W3AEXXZ"
|
|
|
|
// MANGLING-X64-DAG: @"?public_f@C@@UEAAXXZ"
|
|
|
|
// MANGLING-X64-DAG: @"?public_f@C@@W7EAAXXZ"
|
2013-10-09 17:23:58 +08:00
|
|
|
protected:
|
|
|
|
virtual void protected_f();
|
2018-03-17 04:36:49 +08:00
|
|
|
// MANGLING-DAG: @"?protected_f@C@@MAEXXZ"
|
|
|
|
// MANGLING-DAG: @"?protected_f@C@@O3AEXXZ"
|
|
|
|
// MANGLING-X64-DAG: @"?protected_f@C@@MEAAXXZ"
|
|
|
|
// MANGLING-X64-DAG: @"?protected_f@C@@O7EAAXXZ"
|
2013-10-09 17:23:58 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual void private_f();
|
2018-03-17 04:36:49 +08:00
|
|
|
// MANGLING-DAG: @"?private_f@C@@EAEXXZ"
|
|
|
|
// MANGLING-DAG: @"?private_f@C@@G3AEXXZ"
|
|
|
|
// MANGLING-X64-DAG: @"?private_f@C@@EEAAXXZ"
|
|
|
|
// MANGLING-X64-DAG: @"?private_f@C@@G7EAAXXZ"
|
2013-10-09 17:23:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
C::C() {} // Emits vftable and forces thunk generation.
|
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CODEGEN-LABEL: define linkonce_odr dso_local x86_thiscallcc i8* @"??_EC@@W3AEPAXI@Z"(%struct.C* %this, i32 %should_call_delete) {{.*}} comdat
|
2015-02-28 03:18:17 +08:00
|
|
|
// CODEGEN: getelementptr i8, i8* {{.*}}, i32 -4
|
2013-10-09 17:23:58 +08:00
|
|
|
// FIXME: should actually call _EC, not _GC.
|
2018-03-17 04:36:49 +08:00
|
|
|
// CODEGEN: call x86_thiscallcc i8* @"??_GC@@UAEPAXI@Z"
|
2013-10-09 17:23:58 +08:00
|
|
|
// CODEGEN: ret
|
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CODEGEN-LABEL: define linkonce_odr dso_local x86_thiscallcc void @"?public_f@C@@W3AEXXZ"(%struct.C*
|
2015-02-28 03:18:17 +08:00
|
|
|
// CODEGEN: getelementptr i8, i8* {{.*}}, i32 -4
|
2018-03-17 04:36:49 +08:00
|
|
|
// CODEGEN: call x86_thiscallcc void @"?public_f@C@@UAEXXZ"(%struct.C*
|
2013-10-09 17:23:58 +08:00
|
|
|
// CODEGEN: ret
|
|
|
|
|
|
|
|
void zoo(C* obj) {
|
|
|
|
delete obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct D {
|
|
|
|
virtual B* goo();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct E : D {
|
2013-10-30 19:55:43 +08:00
|
|
|
E();
|
2013-10-09 17:23:58 +08:00
|
|
|
virtual C* goo();
|
2018-03-17 04:36:49 +08:00
|
|
|
// MANGLING-DAG: @"?goo@E@@UAEPAUC@@XZ"
|
|
|
|
// MANGLING-DAG: @"?goo@E@@QAEPAUB@@XZ"
|
|
|
|
// MANGLING-X64-DAG: @"?goo@E@@UEAAPEAUC@@XZ"
|
|
|
|
// MANGLING-X64-DAG: @"?goo@E@@QEAAPEAUB@@XZ"
|
2013-10-09 17:23:58 +08:00
|
|
|
};
|
|
|
|
|
2013-10-30 19:55:43 +08:00
|
|
|
E::E() {} // Emits vftable and forces thunk generation.
|
2013-10-09 17:23:58 +08:00
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CODEGEN-LABEL: define weak_odr dso_local x86_thiscallcc %struct.C* @"?goo@E@@QAEPAUB@@XZ"{{.*}} comdat
|
|
|
|
// CODEGEN: call x86_thiscallcc %struct.C* @"?goo@E@@UAEPAUC@@XZ"
|
2015-02-28 03:18:17 +08:00
|
|
|
// CODEGEN: getelementptr inbounds i8, i8* {{.*}}, i32 4
|
2013-10-09 17:23:58 +08:00
|
|
|
// CODEGEN: ret
|
|
|
|
|
|
|
|
struct F : virtual A, virtual B {
|
2013-10-30 19:55:43 +08:00
|
|
|
virtual void own_method();
|
2013-10-09 17:23:58 +08:00
|
|
|
virtual ~F();
|
|
|
|
};
|
|
|
|
|
|
|
|
F f; // Just make sure we don't crash, e.g. mangling the complete dtor.
|
|
|
|
|
|
|
|
struct G : C { };
|
|
|
|
|
|
|
|
struct H : E {
|
|
|
|
virtual G* goo();
|
2018-03-17 04:36:49 +08:00
|
|
|
// MANGLING-DAG: @"?goo@H@@UAEPAUG@@XZ"
|
|
|
|
// MANGLING-DAG: @"?goo@H@@QAEPAUB@@XZ"
|
|
|
|
// MANGLING-DAG: @"?goo@H@@QAEPAUC@@XZ"
|
|
|
|
// MANGLING-X64-DAG: @"?goo@H@@UEAAPEAUG@@XZ"
|
|
|
|
// MANGLING-X64-DAG: @"?goo@H@@QEAAPEAUB@@XZ"
|
|
|
|
// MANGLING-X64-DAG: @"?goo@H@@QEAAPEAUC@@XZ"
|
2013-10-09 17:23:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
H h;
|
|
|
|
|
2013-10-30 19:55:43 +08:00
|
|
|
struct I : D {
|
|
|
|
I();
|
|
|
|
virtual F* goo();
|
|
|
|
};
|
|
|
|
|
|
|
|
I::I() {} // Emits vftable and forces thunk generation.
|
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CODEGEN-LABEL: define weak_odr dso_local x86_thiscallcc %struct.{{[BF]}}* @"?goo@I@@QAEPAUB@@XZ"{{.*}} comdat
|
|
|
|
// CODEGEN: %[[ORIG_RET:.*]] = call x86_thiscallcc %struct.F* @"?goo@I@@UAEPAUF@@XZ"
|
2013-10-30 19:55:43 +08:00
|
|
|
// CODEGEN: %[[ORIG_RET_i8:.*]] = bitcast %struct.F* %[[ORIG_RET]] to i8*
|
2015-02-28 03:18:17 +08:00
|
|
|
// CODEGEN: %[[VBPTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ORIG_RET_i8]], i32 4
|
2014-10-23 01:26:00 +08:00
|
|
|
// CODEGEN: %[[VBPTR:.*]] = bitcast i8* %[[VBPTR_i8]] to i32**
|
2015-02-28 05:19:58 +08:00
|
|
|
// CODEGEN: %[[VBTABLE:.*]] = load i32*, i32** %[[VBPTR]]
|
2015-02-28 03:18:17 +08:00
|
|
|
// CODEGEN: %[[VBASE_OFFSET_PTR:.*]] = getelementptr inbounds i32, i32* %[[VBTABLE]], i32 2
|
2015-02-28 05:19:58 +08:00
|
|
|
// CODEGEN: %[[VBASE_OFFSET:.*]] = load i32, i32* %[[VBASE_OFFSET_PTR]]
|
2015-02-28 03:18:17 +08:00
|
|
|
// CODEGEN: %[[RES_i8:.*]] = getelementptr inbounds i8, i8* %[[VBPTR_i8]], i32 %[[VBASE_OFFSET]]
|
2013-10-30 19:55:43 +08:00
|
|
|
// CODEGEN: %[[RES:.*]] = bitcast i8* %[[RES_i8]] to %struct.F*
|
|
|
|
// CODEGEN: phi %struct.F* {{.*}} %[[RES]]
|
|
|
|
// CODEGEN: ret %struct.{{[BF]}}*
|
|
|
|
|
2013-10-12 04:46:27 +08:00
|
|
|
namespace CrashOnThunksForAttributedType {
|
|
|
|
// We used to crash on this because the type of foo is an AttributedType, not
|
|
|
|
// FunctionType, and we had to look through the sugar.
|
|
|
|
struct A {
|
|
|
|
virtual void __stdcall foo();
|
|
|
|
};
|
|
|
|
struct B {
|
|
|
|
virtual void __stdcall foo();
|
|
|
|
};
|
|
|
|
struct C : A, B {
|
|
|
|
virtual void __stdcall foo();
|
|
|
|
};
|
|
|
|
C c;
|
|
|
|
}
|
2014-06-07 04:04:01 +08:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
struct E : D {
|
|
|
|
E();
|
|
|
|
virtual C* goo();
|
|
|
|
};
|
|
|
|
E::E() {}
|
|
|
|
E e;
|
|
|
|
// Class with internal linkage has internal linkage thunks.
|
[MS] Mangle a hash of the main file path into anonymous namespaces
Summary:
This is needed to avoid conflicts in mangled names for codeview types in
anonymous namespaces. In CodeView, types refer to each other typically
through forward declarations, which contain mangled names. These names
have to be unique, otherwise the debugger will look up the mangled name
and find the wrong definition.
Furthermore, ThinLTO will deduplicate the types, and debug info
verification can fail when the types have the wrong sizes. This is
PR38608.
Fixes PR38609.
Reviewers: majnemer, inglorion, hans
Subscribers: mehdi_amini, aprantl, JDevlieghere, dexonsmith, cfe-commits
Differential Revision: https://reviews.llvm.org/D50877
llvm-svn: 340079
2018-08-18 04:59:27 +08:00
|
|
|
// CODEGEN: define internal x86_thiscallcc %struct.C* @"?goo@E@?A0x{{[^@]*}}@@QAEPAUB@@XZ"
|
2014-06-07 04:04:01 +08:00
|
|
|
}
|