forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix MSVC 1920+ auto NTTP mangling for pointers to members (llvm#97007)
Fixes llvm#70899. This is a continuation of llvm#92477 for pointers to member data and pointers to member functions. The mangled name must be prefixed with `$M <mangled-type>` for the deduced type of the nttp parameter.
- Loading branch information
Showing
6 changed files
with
204 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
clang/test/CodeGenCXX/mangle-ms-auto-templates-memptrs.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
24 changes: 24 additions & 0 deletions
24
clang/test/CodeGenCXX/mangle-ms-auto-templates-nullptr.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
// 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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters