Skip to content

Commit 91e3fb3

Browse files
authored
[clang][Itanium Mangle] Enable mangling of enclosing class for member… (#110503)
…-like friend function templates only if ` -fclang-abi-compat>19`.
1 parent c6b12bc commit 91e3fb3

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ ABI Changes in This Version
104104

105105
- Fixed Microsoft name mangling of placeholder, auto and decltype(auto), return types for MSVC 1920+. This change resolves incompatibilities with code compiled by MSVC 1920+ but will introduce incompatibilities with code compiled by earlier versions of Clang unless such code is built with the compiler option -fms-compatibility-version=19.14 to imitate the MSVC 1914 mangling behavior.
106106
- Fixed the Itanium mangling of the construction vtable name. This change will introduce incompatibilities with code compiled by Clang 19 and earlier versions, unless the -fclang-abi-compat=19 option is used. (#GH108015)
107+
- Mangle member-like friend function templates as members of the enclosing class. (#GH110247, #GH110503)
107108

108109
AST Dumping Potentially Breaking Changes
109110
----------------------------------------
@@ -466,7 +467,6 @@ Bug Fixes to C++ Support
466467
diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter.
467468
- Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326)
468469
- Fixed an issue deducing non-type template arguments of reference type. (#GH73460)
469-
- Mangle friend function templates with a constraint that depends on a template parameter from an enclosing template as members of the enclosing class. (#GH110247)
470470
- Fixed an issue in constraint evaluation, where type constraints on the lambda expression
471471
containing outer unexpanded parameters were not correctly expanded. (#GH101754)
472472
- Fixed a bug in constraint expression comparison where the ``sizeof...`` expression was not handled properly

clang/include/clang/Basic/LangOptions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,10 @@ class LangOptionsBase {
241241

242242
/// Attempt to be ABI-compatible with code generated by Clang 19.0.x.
243243
/// This causes clang to:
244-
/// - Incorrectly mangles the 'base type' substitutions of the CXX
244+
/// - Incorrectly mangle the 'base type' substitutions of the CXX
245245
/// construction vtable because it hasn't added 'type' as a substitution.
246+
/// - Skip mangling enclosing class templates of member-like friend
247+
/// function templates.
246248
Ver19,
247249

248250
/// Conform to the underlying platform's C and C++ ABIs as closely

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,10 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const Decl *D) {
693693
if (VD->isExternC())
694694
return getASTContext().getTranslationUnitDecl();
695695

696-
if (const auto *FD = D->getAsFunction()) {
696+
if (const auto *FD = getASTContext().getLangOpts().getClangABICompat() >
697+
LangOptions::ClangABI::Ver19
698+
? D->getAsFunction()
699+
: dyn_cast<FunctionDecl>(D)) {
697700
if (FD->isExternC())
698701
return getASTContext().getTranslationUnitDecl();
699702
// Member-like constrained friends are mangled as if they were members of

clang/test/CodeGenCXX/mangle-concept.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -verify -std=c++20 -emit-llvm -triple %itanium_abi_triple -o - %s -fclang-abi-compat=latest | FileCheck %s
2+
// RUN: %clang_cc1 -verify -std=c++20 -emit-llvm -triple %itanium_abi_triple -o - %s -fclang-abi-compat=19 | FileCheck %s --check-prefix=CLANG19
23
// RUN: %clang_cc1 -verify -std=c++20 -emit-llvm -triple %itanium_abi_triple -o - %s -fclang-abi-compat=17 | FileCheck %s --check-prefix=CLANG17
34
// expected-no-diagnostics
45

@@ -59,18 +60,21 @@ namespace test2 {
5960
// CLANG17: call {{.*}}@_ZN5test21fEz(
6061
f(ai);
6162
// CHECK: call {{.*}}@_ZN5test21AIiEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
63+
// CLANG19: call {{.*}}@_ZN5test2F1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
6264
// CLANG17: call {{.*}}@_ZN5test21gIvEEvz(
6365
g(ai);
6466
// CHECK: call {{.*}}@_ZN5test21hIvEEvzQ4TrueITL0__E(
6567
// CLANG17: call {{.*}}@_ZN5test21hIvEEvz(
6668
h(ai);
6769
// CHECK: call {{.*}}@_ZN5test21AIiEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
70+
// CLANG19: call {{.*}}@_ZN5test2F1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
6871
// CLANG17: call {{.*}}@_ZN5test21iIvEEvz(
6972
i(ai);
7073
// CHECK: call {{.*}}@_ZN5test21jIvQ4TrueITL0__EEEvz(
7174
// CLANG17: call {{.*}}@_ZN5test21jIvEEvz(
7275
j(ai);
7376
// CHECK: call {{.*}}@_ZN5test21AIiEF1kITk4TruevQ4TrueIT_EEEvz(
77+
// CLANG19: call {{.*}}@_ZN5test2F1kITk4TruevQ4TrueIT_EEEvz(
7478
// CLANG17: call {{.*}}@_ZN5test21kIvEEvz(
7579
k(ai);
7680
// CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(

0 commit comments

Comments
 (0)