-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Fix MSVC 1920+ auto NTTP mangling for pointers to members #97007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
762eb6d
4afbc4e
48cbb60
9a06ef3
fd8cbd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// RUN: %clang_cc1 -std=c++17 -fms-compatibility-version=19.20 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-windows-msvc | FileCheck --check-prefix=AFTER %s | ||
// RUN: %clang_cc1 -std=c++17 -fms-compatibility-version=19.14 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-windows-msvc | FileCheck --check-prefix=BEFORE %s | ||
|
||
template <auto a> | ||
class AutoParmTemplate { | ||
public: | ||
AutoParmTemplate() {} | ||
}; | ||
|
||
template <auto a> | ||
auto AutoFunc() { | ||
return a; | ||
} | ||
|
||
struct A {}; | ||
struct B {}; | ||
|
||
struct S { int a; void f(); virtual void g(); }; | ||
struct M : A, B { int a; void f(); virtual void g(); }; | ||
struct V : virtual A { int a; void f(); virtual void g(); }; | ||
|
||
void template_mangling() { | ||
|
||
AutoParmTemplate<&S::f> auto_method_single_inheritance; | ||
// AFTER: call {{.*}} @"??0?$AutoParmTemplate@$MP8S@@EAAXXZ1?f@1@QEAAXXZ@@QEAA@XZ" | ||
// BEFORE: call {{.*}} @"??0?$AutoParmTemplate@$1?f@S@@QEAAXXZ@@QEAA@XZ" | ||
|
||
AutoParmTemplate<&M::f> auto_method_multiple_inheritance; | ||
// AFTER: call {{.*}} @"??0?$AutoParmTemplate@$MP8M@@EAAXXZH?f@1@QEAAXXZA@@@QEAA@XZ" | ||
// BEFORE: call {{.*}} @"??0?$AutoParmTemplate@$H?f@M@@QEAAXXZA@@@QEAA@XZ" | ||
|
||
AutoParmTemplate<&V::f> auto_method_virtual_inheritance; | ||
// AFTER: call {{.*}} @"??0?$AutoParmTemplate@$MP8V@@EAAXXZI?f@1@QEAAXXZA@A@@@QEAA@XZ" | ||
// BEFORE: call {{.*}} @"??0?$AutoParmTemplate@$I?f@V@@QEAAXXZA@A@@@QEAA@XZ" | ||
|
||
AutoFunc<&S::f>(); | ||
// AFTER: call {{.*}} @"??$AutoFunc@$MP8S@@EAAXXZ1?f@1@QEAAXXZ@@YA?A?<auto>@@XZ" | ||
// BEFORE: call {{.*}} @"??$AutoFunc@$1?f@S@@QEAAXXZ@@YA?A?<auto>@@XZ" | ||
|
||
AutoFunc<&M::f>(); | ||
// AFTER: call {{.*}} @"??$AutoFunc@$MP8M@@EAAXXZH?f@1@QEAAXXZA@@@YA?A?<auto>@@XZ" | ||
// BEFORE: call {{.*}} @"??$AutoFunc@$H?f@M@@QEAAXXZA@@@YA?A?<auto>@@XZ" | ||
|
||
AutoFunc<&V::f>(); | ||
// AFTER: call {{.*}} @"??$AutoFunc@$MP8V@@EAAXXZI?f@1@QEAAXXZA@A@@@YA?A?<auto>@@XZ" | ||
// BEFORE: call {{.*}} @"??$AutoFunc@$I?f@V@@QEAAXXZA@A@@@YA?A?<auto>@@XZ" | ||
|
||
AutoParmTemplate<&S::a> auto_data_single_inheritance; | ||
// AFTER: call {{.*}} @"??0?$AutoParmTemplate@$MPEQS@@H07@@QEAA@XZ" | ||
// BEFORE: call {{.*}} @"??0?$AutoParmTemplate@$07@@QEAA@XZ" | ||
|
||
AutoParmTemplate<&M::a> auto_data_multiple_inheritance; | ||
// AFTER: call {{.*}} @"??0?$AutoParmTemplate@$MPEQM@@H0M@@@QEAA@XZ" | ||
// BEFORE: call {{.*}} @"??0?$AutoParmTemplate@$0M@@@QEAA@XZ" | ||
|
||
AutoParmTemplate<&V::a> auto_data_virtual_inheritance; | ||
// AFTER: call {{.*}} @"??0?$AutoParmTemplate@$MPEQV@@HFBA@A@@@QEAA@XZ" | ||
// BEFORE: call {{.*}} @"??0?$AutoParmTemplate@$FBA@A@@@QEAA@XZ" | ||
|
||
AutoFunc<&S::a>(); | ||
// AFTER: call {{.*}} @"??$AutoFunc@$MPEQS@@H07@@YA?A?<auto>@@XZ" | ||
// BEFORE: call {{.*}} @"??$AutoFunc@$07@@YA?A?<auto>@@XZ" | ||
|
||
AutoFunc<&M::a>(); | ||
// AFTER: call {{.*}} @"??$AutoFunc@$MPEQM@@H0M@@@YA?A?<auto>@@XZ" | ||
// BEFORE: call {{.*}} @"??$AutoFunc@$0M@@@YA?A?<auto>@@XZ" | ||
|
||
AutoFunc<&V::a>(); | ||
// AFTER: call {{.*}} @"??$AutoFunc@$MPEQV@@HFBA@A@@@YA?A?<auto>@@XZ" | ||
// BEFORE: call {{.*}} @"??$AutoFunc@$FBA@A@@@YA?A?<auto>@@XZ" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// RUN: %clang_cc1 -std=c++17 -fms-compatibility-version=19.20 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-windows-msvc | FileCheck --check-prefix=AFTER %s | ||
// RUN: %clang_cc1 -std=c++17 -fms-compatibility-version=19.14 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-windows-msvc | FileCheck --check-prefix=BEFORE %s | ||
|
||
template <auto a> | ||
class AutoParmTemplate { | ||
public: | ||
AutoParmTemplate() {} | ||
}; | ||
|
||
template <auto a> | ||
auto AutoFunc() { | ||
return a; | ||
} | ||
|
||
void template_mangling() { | ||
|
||
AutoParmTemplate<nullptr> auto_nullptr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a separate file since In VS2017 this gets mangled without the VS2017 gets around this by erroneously putting all the definitions into COMDAT sections which clang does not do at the moment when trying to be VS2017 compatible. |
||
// AFTER: call {{.*}} @"??0?$AutoParmTemplate@$M$$T0A@@@QEAA@XZ" | ||
// BEFORE: call {{.*}} @"??0?$AutoParmTemplate@$0A@@@QEAA@XZ" | ||
|
||
AutoFunc<nullptr>(); | ||
// AFTER: call {{.*}} @"??$AutoFunc@$M$$T0A@@@YA?A?<auto>@@XZ" | ||
// BEFORE: call {{.*}} @"??$AutoFunc@$0A@@@YA?A?<auto>@@XZ" | ||
} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These use cases appear to be added from, 5518a9d, with support for C++20 nttp changes.
From looking at the code we only hit this path when compiling for C++20 and it also already properly mangles according to VS2019+ by doing
$M <type>
elsewhere.I intend to take a look at C++20 NTTP after this PR and then take a more holistic look to see if we can better merge the C++11-17 and C++20 mangling paths in
MicrosoftMangle.cpp
.