2015-03-14 02:26:17 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - -triple=i386-pc-win32 -std=c++11 %s -fcxx-exceptions -fms-extensions | FileCheck %s
|
2016-01-26 09:12:17 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - -triple=i386-pc-win32 -std=c++11 %s -fcxx-exceptions -fms-extensions -DSTD | FileCheck %s
|
2015-03-05 08:46:22 +08:00
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-DAG: @"??_R0?AUY@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".?AUY@@\00" }, comdat
|
|
|
|
// CHECK-DAG: @"_CT??_R0?AUY@@@8??0Y@@QAE@ABU0@@Z8" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 4, i8* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUY@@@8" to i8*), i32 0, i32 -1, i32 0, i32 8, i8* bitcast (%struct.Y* (%struct.Y*, %struct.Y*, i32)* @"??0Y@@QAE@ABU0@@Z" to i8*) }, section ".xdata", comdat
|
|
|
|
// CHECK-DAG: @"??_R0?AUZ@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".?AUZ@@\00" }, comdat
|
|
|
|
// CHECK-DAG: @"_CT??_R0?AUZ@@@81" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUZ@@@8" to i8*), i32 0, i32 -1, i32 0, i32 1, i8* null }, section ".xdata", comdat
|
|
|
|
// CHECK-DAG: @"??_R0?AUW@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".?AUW@@\00" }, comdat
|
|
|
|
// CHECK-DAG: @"_CT??_R0?AUW@@@8??0W@@QAE@ABU0@@Z44" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 4, i8* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUW@@@8" to i8*), i32 4, i32 -1, i32 0, i32 4, i8* bitcast (%struct.W* (%struct.W*, %struct.W*, i32)* @"??0W@@QAE@ABU0@@Z" to i8*) }, section ".xdata", comdat
|
|
|
|
// CHECK-DAG: @"??_R0?AUM@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".?AUM@@\00" }, comdat
|
|
|
|
// CHECK-DAG: @"_CT??_R0?AUM@@@818" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUM@@@8" to i8*), i32 8, i32 -1, i32 0, i32 1, i8* null }, section ".xdata", comdat
|
|
|
|
// CHECK-DAG: @"??_R0?AUV@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".?AUV@@\00" }, comdat
|
|
|
|
// CHECK-DAG: @"_CT??_R0?AUV@@@81044" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor7* @"??_R0?AUV@@@8" to i8*), i32 0, i32 4, i32 4, i32 1, i8* null }, section ".xdata", comdat
|
2015-03-11 03:01:51 +08:00
|
|
|
// CHECK-DAG: @"_CTA5?AUY@@" = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.5 { i32 5, [5 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0?AUY@@@8??0Y@@QAE@ABU0@@Z8", %eh.CatchableType* @"_CT??_R0?AUZ@@@81", %eh.CatchableType* @"_CT??_R0?AUW@@@8??0W@@QAE@ABU0@@Z44", %eh.CatchableType* @"_CT??_R0?AUM@@@818", %eh.CatchableType* @"_CT??_R0?AUV@@@81044"] }, section ".xdata", comdat
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-DAG: @"_TI5?AUY@@" = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* bitcast (void (%struct.Y*)* @"??_DY@@QAEXXZ" to i8*), i8* null, i8* bitcast (%eh.CatchableTypeArray.5* @"_CTA5?AUY@@" to i8*) }, section ".xdata", comdat
|
|
|
|
// CHECK-DAG: @"_CT??_R0?AUDefault@@@8??_ODefault@@QAEXAAU0@@Z1" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor13* @"??_R0?AUDefault@@@8" to i8*), i32 0, i32 -1, i32 0, i32 1, i8* bitcast (void (%struct.Default*, %struct.Default*)* @"??_ODefault@@QAEXAAU0@@Z" to i8*) }, section ".xdata", comdat
|
2019-10-31 05:38:11 +08:00
|
|
|
// CHECK-DAG: @"_CT??_R0?AUDeletedCopy@@@81" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor17* @"??_R0?AUDeletedCopy@@@8" to i8*), i32 0, i32 -1, i32 0, i32 1, i8* null }, section ".xdata", comdat
|
|
|
|
// CHECk-DAG: @"_CT??_R0?AUMoveOnly@@@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor14* @"??_R0?AUMoveOnly@@@8" to i8*), i32 0, i321-1, i32 0, i32 4, i8* null }, section ".xdata", comda
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-DAG: @"_CT??_R0?AUVariadic@@@8??_OVariadic@@QAEXAAU0@@Z1" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor14* @"??_R0?AUVariadic@@@8" to i8*), i32 0, i32 -1, i32 0, i32 1, i8* bitcast (void (%struct.Variadic*, %struct.Variadic*)* @"??_OVariadic@@QAEXAAU0@@Z" to i8*) }, section ".xdata", comdat
|
|
|
|
// CHECK-DAG: @"_CT??_R0?AUTemplateWithDefault@@@8??$?_OH@TemplateWithDefault@@QAEXAAU0@@Z1" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor25* @"??_R0?AUTemplateWithDefault@@@8" to i8*), i32 0, i32 -1, i32 0, i32 1, i8* bitcast (void (%struct.TemplateWithDefault*, %struct.TemplateWithDefault*)* @"??$?_OH@TemplateWithDefault@@QAEXAAU0@@Z" to i8*) }, section ".xdata", comdat
|
2015-03-13 01:44:49 +08:00
|
|
|
// CHECK-DAG: @"_CTA2$$T" = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.2 { i32 2, [2 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0$$T@84", %eh.CatchableType* @"_CT??_R0PAX@84"] }, section ".xdata", comdat
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-DAG: @"_CT??_R0P6AXXZ@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i8* bitcast (%rtti.TypeDescriptor7* @"??_R0P6AXXZ@8" to i8*), i32 0, i32 -1, i32 0, i32 4, i8* null }, section ".xdata", comdat
|
2015-04-04 13:37:48 +08:00
|
|
|
// CHECK-DAG: @_CTA1P6AXXZ = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0P6AXXZ@84"] }, section ".xdata", comdat
|
|
|
|
// CHECK-DAG: @_TI1P6AXXZ = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @_CTA1P6AXXZ to i8*) }, section ".xdata", comdat
|
2016-07-12 12:42:50 +08:00
|
|
|
// CHECK-DAG: @_TIU2PAPFAH = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 4, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.2* @_CTA2PAPFAH to i8*) }, section ".xdata", comdat
|
|
|
|
// CHECK-DAG: @_CTA2PAPFAH = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.2 { i32 2, [2 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0PAPFAH@84", %eh.CatchableType* @"_CT??_R0PAX@84"] }, section ".xdata", comdat
|
[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
|
|
|
// CHECK-DAG: @"_TI1?AUFoo@?A0x{{[^@]*}}@@" = internal unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @"_CTA1?AUFoo@?A0x{{[^@]*}}@@" to i8*) }, section ".xdata"
|
2015-03-05 08:46:22 +08:00
|
|
|
|
|
|
|
|
|
|
|
struct N { ~N(); };
|
|
|
|
struct M : private N {};
|
|
|
|
struct X {};
|
|
|
|
struct Z {};
|
|
|
|
struct V : private X {};
|
|
|
|
struct W : M, virtual V {};
|
|
|
|
struct Y : Z, W, virtual V {};
|
|
|
|
|
|
|
|
void f(const Y &y) {
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: @"?f@@YAXABUY@@@Z"
|
2021-11-09 01:09:49 +08:00
|
|
|
// CHECK: call x86_thiscallcc %struct.Y* @"??0Y@@QAE@ABU0@@Z"(%struct.Y* {{[^,]*}} %[[mem:.*]], %struct.Y*
|
2015-03-05 08:46:22 +08:00
|
|
|
// CHECK: %[[cast:.*]] = bitcast %struct.Y* %[[mem]] to i8*
|
2015-03-07 07:45:20 +08:00
|
|
|
// CHECK: call void @_CxxThrowException(i8* %[[cast]], %eh.ThrowInfo* @"_TI5?AUY@@")
|
|
|
|
throw y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void g(const int *const *y) {
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: @"?g@@YAXPBQBH@Z"
|
2015-03-07 07:45:20 +08:00
|
|
|
// CHECK: call void @_CxxThrowException(i8* %{{.*}}, %eh.ThrowInfo* @_TIC2PAPBH)
|
2015-03-05 08:46:22 +08:00
|
|
|
throw y;
|
|
|
|
}
|
2015-03-12 02:36:39 +08:00
|
|
|
|
2016-07-12 12:42:50 +08:00
|
|
|
void h(__unaligned int * __unaligned *y) {
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: @"?h@@YAXPFAPFAH@Z"
|
2016-07-12 12:42:50 +08:00
|
|
|
// CHECK: call void @_CxxThrowException(i8* %{{.*}}, %eh.ThrowInfo* @_TIU2PAPFAH)
|
|
|
|
throw y;
|
|
|
|
}
|
|
|
|
|
2015-03-12 02:36:39 +08:00
|
|
|
struct Default {
|
|
|
|
Default(Default &, int = 42);
|
|
|
|
};
|
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: @"??_ODefault@@QAEXAAU0@@Z"
|
2015-03-12 02:36:39 +08:00
|
|
|
// CHECK: %[[src_addr:.*]] = alloca
|
|
|
|
// CHECK: %[[this_addr:.*]] = alloca
|
|
|
|
// CHECK: store {{.*}} %src, {{.*}} %[[src_addr]], align 4
|
|
|
|
// CHECK: store {{.*}} %this, {{.*}} %[[this_addr]], align 4
|
|
|
|
// CHECK: %[[this:.*]] = load {{.*}} %[[this_addr]]
|
|
|
|
// CHECK: %[[src:.*]] = load {{.*}} %[[src_addr]]
|
2021-11-09 01:09:49 +08:00
|
|
|
// CHECK: call x86_thiscallcc {{.*}} @"??0Default@@QAE@AAU0@H@Z"({{.*}} %[[this]], {{.*}} %[[src]], i32 42)
|
2015-03-12 02:36:39 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
|
|
|
|
void h(Default &d) {
|
|
|
|
throw d;
|
|
|
|
}
|
|
|
|
|
2019-10-31 05:38:11 +08:00
|
|
|
struct DeletedCopy {
|
|
|
|
DeletedCopy();
|
|
|
|
DeletedCopy(DeletedCopy &&);
|
|
|
|
DeletedCopy(const DeletedCopy &) = delete;
|
|
|
|
};
|
|
|
|
void throwDeletedCopy() { throw DeletedCopy(); }
|
|
|
|
|
|
|
|
|
|
|
|
struct MoveOnly {
|
|
|
|
MoveOnly();
|
|
|
|
MoveOnly(MoveOnly &&);
|
|
|
|
~MoveOnly();
|
|
|
|
MoveOnly(const MoveOnly &) = delete;
|
|
|
|
|
|
|
|
// For some reason this subobject was important for reproducing PR43680
|
|
|
|
struct HasCopy {
|
|
|
|
HasCopy();
|
|
|
|
HasCopy(const HasCopy &o);
|
|
|
|
~HasCopy();
|
|
|
|
int x;
|
|
|
|
} sub;
|
|
|
|
};
|
|
|
|
|
|
|
|
void throwMoveOnly() { throw MoveOnly(); }
|
|
|
|
|
2015-03-12 02:36:39 +08:00
|
|
|
struct Variadic {
|
|
|
|
Variadic(Variadic &, ...);
|
|
|
|
};
|
|
|
|
|
|
|
|
void i(Variadic &v) {
|
|
|
|
throw v;
|
|
|
|
}
|
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: @"??_OVariadic@@QAEXAAU0@@Z"
|
2015-03-12 02:36:39 +08:00
|
|
|
// CHECK: %[[src_addr:.*]] = alloca
|
|
|
|
// CHECK: %[[this_addr:.*]] = alloca
|
|
|
|
// CHECK: store {{.*}} %src, {{.*}} %[[src_addr:.*]], align
|
|
|
|
// CHECK: store {{.*}} %this, {{.*}} %[[this_addr:.*]], align
|
|
|
|
// CHECK: %[[this:.*]] = load {{.*}} %[[this_addr]]
|
|
|
|
// CHECK: %[[src:.*]] = load {{.*}} %[[src_addr]]
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK: call {{.*}} @"??0Variadic@@QAA@AAU0@ZZ"({{.*}} %[[this]], {{.*}} %[[src]])
|
2015-03-12 02:36:39 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
|
|
|
|
struct TemplateWithDefault {
|
|
|
|
template <typename T>
|
|
|
|
static int f() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
template <typename T = int>
|
|
|
|
TemplateWithDefault(TemplateWithDefault &, T = f<T>());
|
|
|
|
};
|
|
|
|
|
|
|
|
void j(TemplateWithDefault &twd) {
|
|
|
|
throw twd;
|
|
|
|
}
|
2015-03-13 01:44:49 +08:00
|
|
|
|
2015-03-14 02:26:17 +08:00
|
|
|
|
2015-03-13 01:44:49 +08:00
|
|
|
void h() {
|
|
|
|
throw nullptr;
|
|
|
|
}
|
2015-03-14 02:26:17 +08:00
|
|
|
|
2016-01-26 09:12:17 +08:00
|
|
|
#ifdef STD
|
2015-03-14 02:26:17 +08:00
|
|
|
namespace std {
|
|
|
|
template <typename T>
|
|
|
|
void *__GetExceptionInfo(T);
|
|
|
|
}
|
2016-01-26 09:12:17 +08:00
|
|
|
#else
|
|
|
|
template <typename T>
|
|
|
|
void *__GetExceptionInfo(T);
|
|
|
|
#endif
|
|
|
|
using namespace std;
|
2015-03-14 02:26:17 +08:00
|
|
|
|
|
|
|
void *GetExceptionInfo_test0() {
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: @"?GetExceptionInfo_test0@@YAPAXXZ"
|
2015-03-14 02:26:17 +08:00
|
|
|
// CHECK: ret i8* bitcast (%eh.ThrowInfo* @_TI1H to i8*)
|
2016-01-26 09:12:17 +08:00
|
|
|
return __GetExceptionInfo(0);
|
2015-03-14 02:26:17 +08:00
|
|
|
}
|
2015-04-04 13:37:48 +08:00
|
|
|
|
|
|
|
void *GetExceptionInfo_test1() {
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: @"?GetExceptionInfo_test1@@YAPAXXZ"
|
2015-04-04 13:37:48 +08:00
|
|
|
// CHECK: ret i8* bitcast (%eh.ThrowInfo* @_TI1P6AXXZ to i8*)
|
2016-01-26 09:12:17 +08:00
|
|
|
return __GetExceptionInfo<void (*)()>(&h);
|
2015-04-04 13:37:48 +08:00
|
|
|
}
|
2018-06-21 05:12:20 +08:00
|
|
|
|
|
|
|
// PR36327: Try an exception type with no linkage.
|
|
|
|
namespace { struct Foo { } foo_exc; }
|
|
|
|
|
|
|
|
void *GetExceptionInfo_test2() {
|
|
|
|
// CHECK-LABEL: @"?GetExceptionInfo_test2@@YAPAXXZ"
|
[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
|
|
|
// CHECK: ret i8* bitcast (%eh.ThrowInfo* @"_TI1?AUFoo@?A0x{{[^@]*}}@@" to i8*)
|
2018-06-21 05:12:20 +08:00
|
|
|
return __GetExceptionInfo(foo_exc);
|
|
|
|
}
|