Skip to content
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

[clang][ItaniumMangle] Mangle friend function templates with a constr… #110247

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ Bug Fixes to C++ Support
- Fixed an assertion failure in debug mode, and potential crashes in release mode, when
diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter.
- Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326)
- Mangle friend function templates with a constraint that depends on a template parameter from an enclosing template as members of the enclosing class. (#GH110247)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const Decl *D) {
if (VD->isExternC())
return getASTContext().getTranslationUnitDecl();

if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
if (const auto *FD = D->getAsFunction()) {
if (FD->isExternC())
return getASTContext().getTranslationUnitDecl();
// Member-like constrained friends are mangled as if they were members of
Expand Down
29 changes: 26 additions & 3 deletions clang/test/CodeGenCXX/mangle-concept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,53 @@ namespace test2 {
};

A<int> ai;
A<bool> aj;

// CHECK-LABEL: define {{.*}}@{{.*}}test2{{.*}}use
void use() {
// CHECK: call {{.*}}@_ZN5test21AIiEF1fEzQ4TrueIT_E(
// CLANG17: call {{.*}}@_ZN5test21fEz(
f(ai);
// CHECK: call {{.*}}@_ZN5test2F1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
// CHECK: call {{.*}}@_ZN5test21AIiEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
usx95 marked this conversation as resolved.
Show resolved Hide resolved
// CLANG17: call {{.*}}@_ZN5test21gIvEEvz(
g(ai);
// CHECK: call {{.*}}@_ZN5test21hIvEEvzQ4TrueITL0__E(
// CLANG17: call {{.*}}@_ZN5test21hIvEEvz(
h(ai);
// CHECK: call {{.*}}@_ZN5test2F1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
// CHECK: call {{.*}}@_ZN5test21AIiEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
// CLANG17: call {{.*}}@_ZN5test21iIvEEvz(
i(ai);
// CHECK: call {{.*}}@_ZN5test21jIvQ4TrueITL0__EEEvz(
// CLANG17: call {{.*}}@_ZN5test21jIvEEvz(
j(ai);
// CHECK: call {{.*}}@_ZN5test2F1kITk4TruevQ4TrueIT_EEEvz(
// CHECK: call {{.*}}@_ZN5test21AIiEF1kITk4TruevQ4TrueIT_EEEvz(
// CLANG17: call {{.*}}@_ZN5test21kIvEEvz(
k(ai);
// CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(
// CLANG17: call {{.*}}@_ZN5test21lIvEEvz(
l(ai);

// CHECK: call {{.*}}@_ZN5test21AIbEF1fEzQ4TrueIT_E(
// CLANG17: call {{.*}}@_ZN5test21fEz(
f(aj);
// CHECK: call {{.*}}@_ZN5test21AIbEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
// CLANG17: call {{.*}}@_ZN5test21gIvEEvz(
g(aj);
// CHECK: call {{.*}}@_ZN5test21hIvEEvzQ4TrueITL0__E(
// CLANG17: call {{.*}}@_ZN5test21hIvEEvz(
h(aj);
// CHECK: call {{.*}}@_ZN5test21AIbEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
// CLANG17: call {{.*}}@_ZN5test21iIvEEvz(
i(aj);
// CHECK: call {{.*}}@_ZN5test21jIvQ4TrueITL0__EEEvz(
// CLANG17: call {{.*}}@_ZN5test21jIvEEvz(
j(aj);
// CHECK: call {{.*}}@_ZN5test21AIbEF1kITk4TruevQ4TrueIT_EEEvz(
// CLANG17: call {{.*}}@_ZN5test21kIvEEvz(
k(aj);
// CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(
// CLANG17: call {{.*}}@_ZN5test21lIvEEvz(
l(aj);
}
}

Expand Down
10 changes: 7 additions & 3 deletions libcxxabi/test/test_demangle.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30128,11 +30128,15 @@ const char* cases[][2] =
// C++20 concepts, see https://github.com/itanium-cxx-abi/cxx-abi/issues/24.
{"_Z2f0IiE1SIX1CIT_EEEv", "S<C<int>> f0<int>()"},
{"_ZN5test21AIiEF1fEzQ4TrueIT_E", "test2::A<int>::friend f(...) requires True<T>"},
{"_ZN5test2F1gIvEEvzQaa4TrueIT_E4TrueITL0__E", "void test2::friend g<void>(...) requires True<T> && True<TL0_>"},
{"_ZN5test21AIbEF1fEzQ4TrueIT_E", "test2::A<bool>::friend f(...) requires True<T>"},
{"_ZN5test21AIiEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E", "void test2::A<int>::friend g<void>(...) requires True<T> && True<TL0_>"},
{"_ZN5test21AIbEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E", "void test2::A<bool>::friend g<void>(...) requires True<T> && True<TL0_>"},
{"_ZN5test21hIvEEvzQ4TrueITL0__E", "void test2::h<void>(...) requires True<TL0_>"},
{"_ZN5test2F1iIvQaa4TrueIT_E4TrueITL0__EEEvz", "void test2::friend i<void>(...)"},
{"_ZN5test21AIiEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz", "void test2::A<int>::friend i<void>(...)"},
{"_ZN5test21AIbEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz", "void test2::A<bool>::friend i<void>(...)"},
{"_ZN5test21jIvQ4TrueITL0__EEEvz", "void test2::j<void>(...)"},
{"_ZN5test2F1kITk4TruevQ4TrueIT_EEEvz", "void test2::friend k<void>(...)"},
{"_ZN5test21AIiEF1kITk4TruevQ4TrueIT_EEEvz", "void test2::A<int>::friend k<void>(...)"},
{"_ZN5test21AIbEF1kITk4TruevQ4TrueIT_EEEvz", "void test2::A<bool>::friend k<void>(...)"},
{"_ZN5test21lITk4TruevEEvz", "void test2::l<void>(...)"},
{"_ZN5test31dITnDaLi0EEEvv", "void test3::d<0>()"},
{"_ZN5test31eITnDcLi0EEEvv", "void test3::e<0>()"},
Expand Down
Loading