llvm-project/clang/test/CodeGenCXX/mangle-itanium-ptrauth.cpp
Akira Hatanaka b03558080e
[ItaniumMangle] Make sure class types are added to the dictionary of substitution candidates when compiling for older ABIs (#138947)
`mangleCXXRecordDecl` should add class types to the substitution
dictionary unless it is called by `mangleCXXCtorVTable` (see
https://github.com/llvm/llvm-project/pull/109970 for why that is
needed).

This fixes a mis-compile caused by
https://github.com/llvm/llvm-project/pull/132401, which started calling
`mangleCXXRecordDecl` in `CXXNameMangler::mangleType(const
MemberPointerType *T)`.

rdar://149307496
2025-05-28 11:49:40 -07:00

27 lines
1.1 KiB
C++

// RUN: %clang_cc1 -std=c++11 -fptrauth-intrinsics -fptrauth-calls -emit-llvm -o - -triple=arm64-apple-ios %s | FileCheck %s
// RUN: %clang_cc1 -std=c++11 -fptrauth-intrinsics -fptrauth-calls -emit-llvm -o - -triple=aarch64-linux-gnu %s | FileCheck %s
// RUN: %clang_cc1 -std=c++11 -fptrauth-intrinsics -fptrauth-calls -emit-llvm -o - -triple=arm64-apple-ios -fclang-abi-compat=4 %s | FileCheck %s
// clang previously emitted an incorrect discriminator for the member function
// pointer because of a bug in the mangler.
// CHECK: @_ZN17test_substitution5funcsE = global [1 x { i64, i64 }] [{ i64, i64 } { i64 ptrtoint (ptr ptrauth (ptr @_ZN17test_substitution1S1fEPvS1_, i32 0, i64 48995) to i64), i64 0 }], align 8
namespace test_substitution {
struct S { int f(void *, void *); };
typedef int (S::*s_func)(void *, void *);
s_func funcs[] = { (s_func)(&S::f) };
}
// CHECK: define {{.*}}void @_Z3fooPU9__ptrauthILj3ELb1ELj234EEPi(
void foo(int * __ptrauth(3, 1, 234) *) {}
template <class T>
void foo(T t) {}
// CHECK: define weak_odr void @_Z3fooIPU9__ptrauthILj1ELb0ELj64EEPiEvT_(
template void foo<int * __ptrauth(1, 0, 64) *>(int * __ptrauth(1, 0, 64) *);