Skip to content

Commit c8d44a5

Browse files
author
git apple-llvm automerger
committed
Merge commit 'a867bd53e861' from llvm.org/release/21.x into stable/21.x
2 parents b5cd2a1 + a867bd5 commit c8d44a5

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,9 @@ ASTContext::PointerAuthContent ASTContext::findPointerAuthContent(QualType T) {
18421842
assert(isPointerAuthenticationAvailable());
18431843

18441844
T = T.getCanonicalType();
1845+
if (T->isDependentType())
1846+
return PointerAuthContent::None;
1847+
18451848
if (T.hasAddressDiscriminatedPointerAuth())
18461849
return PointerAuthContent::AddressDiscriminatedData;
18471850
const RecordDecl *RD = T->getAsRecordDecl();

clang/test/SemaCXX/ptrauth-type-traits.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
// expected-no-diagnostics
99

1010
#ifdef __PTRAUTH__
11-
11+
#define PTRAUTH_ENABLED 1
1212
#define NonAddressDiscriminatedVTablePtrAttr \
1313
[[clang::ptrauth_vtable_pointer(process_independent, no_address_discrimination, no_extra_discrimination)]]
1414
#define AddressDiscriminatedVTablePtrAttr \
1515
[[clang::ptrauth_vtable_pointer(process_independent, address_discrimination, no_extra_discrimination)]]
1616
#define ADDR_DISC_ENABLED true
1717
#else
18+
#define PTRAUTH_ENABLED 0
1819
#define NonAddressDiscriminatedVTablePtrAttr
1920
#define AddressDiscriminatedVTablePtrAttr
2021
#define ADDR_DISC_ENABLED false
@@ -399,3 +400,38 @@ static_assert(!ASSIGNABLE_WRAPPER(RelocatableAddressDiscriminatedPrimaryBase));
399400
static_assert(!ASSIGNABLE_WRAPPER(RelocatableAddressDiscriminatedSecondaryBase));
400401
static_assert(!ASSIGNABLE_WRAPPER(EmbdeddedAddressDiscriminatedPolymorphicClass));
401402
static_assert(!ASSIGNABLE_WRAPPER(RelocatableEmbdeddedAddressDiscriminatedPolymorphicClass));
403+
404+
namespace GH159505 {
405+
class A {
406+
virtual void f();
407+
};
408+
409+
template <int N> struct B {
410+
class C : A {
411+
A a[N];
412+
} d;
413+
};
414+
415+
template <int N> struct C {
416+
void *__ptrauth(1,1,1) ptr[N];
417+
static_assert(PTRAUTH_ENABLED != __is_trivially_copyable(decltype(ptr)));
418+
};
419+
template <class T, bool isPtrauth> struct D {
420+
T ptr;
421+
static_assert(isPtrauth != __is_trivially_copyable(decltype(ptr)));
422+
};
423+
424+
425+
template <class T> using Ptr = T * __ptrauth(1,1,1);
426+
template <class T> void test() {
427+
static_assert(PTRAUTH_ENABLED != __is_trivially_copyable(Ptr<T>));
428+
}
429+
430+
auto f = test<int>;
431+
static_assert(!__is_trivially_copyable(B<1>));
432+
static_assert(PTRAUTH_ENABLED != __is_trivially_copyable(C<1>));
433+
434+
435+
D<void *, false> d_void;
436+
D<void * __ptrauth(1,1,1), PTRAUTH_ENABLED> d_void_ptrauth;
437+
}

0 commit comments

Comments
 (0)