-
Notifications
You must be signed in to change notification settings - Fork 15.2k
release/21.x: [clang][PAC] Don't try to diagnose use of pointer auth on dependent types #159505 (#159859) #161288
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
Conversation
|
@ahatanak What do you think about merging this PR to the release branch? |
|
@llvm/pr-subscribers-clang Author: None (llvmbot) ChangesBackport f6c711b Requested by: @ojhunt Full diff: https://github.com/llvm/llvm-project/pull/161288.diff 2 Files Affected:
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 92d1b536e474b..862f1d5741c5b 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1725,6 +1725,9 @@ ASTContext::PointerAuthContent ASTContext::findPointerAuthContent(QualType T) {
assert(isPointerAuthenticationAvailable());
T = T.getCanonicalType();
+ if (T->isDependentType())
+ return PointerAuthContent::None;
+
if (T.hasAddressDiscriminatedPointerAuth())
return PointerAuthContent::AddressDiscriminatedData;
const RecordDecl *RD = T->getAsRecordDecl();
diff --git a/clang/test/SemaCXX/ptrauth-type-traits.cpp b/clang/test/SemaCXX/ptrauth-type-traits.cpp
index aefbd63fa1677..a81ef1cce25b6 100644
--- a/clang/test/SemaCXX/ptrauth-type-traits.cpp
+++ b/clang/test/SemaCXX/ptrauth-type-traits.cpp
@@ -8,13 +8,14 @@
// expected-no-diagnostics
#ifdef __PTRAUTH__
-
+#define PTRAUTH_ENABLED 1
#define NonAddressDiscriminatedVTablePtrAttr \
[[clang::ptrauth_vtable_pointer(process_independent, no_address_discrimination, no_extra_discrimination)]]
#define AddressDiscriminatedVTablePtrAttr \
[[clang::ptrauth_vtable_pointer(process_independent, address_discrimination, no_extra_discrimination)]]
#define ADDR_DISC_ENABLED true
#else
+#define PTRAUTH_ENABLED 0
#define NonAddressDiscriminatedVTablePtrAttr
#define AddressDiscriminatedVTablePtrAttr
#define ADDR_DISC_ENABLED false
@@ -399,3 +400,38 @@ static_assert(!ASSIGNABLE_WRAPPER(RelocatableAddressDiscriminatedPrimaryBase));
static_assert(!ASSIGNABLE_WRAPPER(RelocatableAddressDiscriminatedSecondaryBase));
static_assert(!ASSIGNABLE_WRAPPER(EmbdeddedAddressDiscriminatedPolymorphicClass));
static_assert(!ASSIGNABLE_WRAPPER(RelocatableEmbdeddedAddressDiscriminatedPolymorphicClass));
+
+namespace GH159505 {
+ class A {
+ virtual void f();
+ };
+
+ template <int N> struct B {
+ class C : A {
+ A a[N];
+ } d;
+ };
+
+ template <int N> struct C {
+ void *__ptrauth(1,1,1) ptr[N];
+ static_assert(PTRAUTH_ENABLED != __is_trivially_copyable(decltype(ptr)));
+ };
+ template <class T, bool isPtrauth> struct D {
+ T ptr;
+ static_assert(isPtrauth != __is_trivially_copyable(decltype(ptr)));
+ };
+
+
+ template <class T> using Ptr = T * __ptrauth(1,1,1);
+ template <class T> void test() {
+ static_assert(PTRAUTH_ENABLED != __is_trivially_copyable(Ptr<T>));
+ }
+
+ auto f = test<int>;
+ static_assert(!__is_trivially_copyable(B<1>));
+ static_assert(PTRAUTH_ENABLED != __is_trivially_copyable(C<1>));
+
+
+ D<void *, false> d_void;
+ D<void * __ptrauth(1,1,1), PTRAUTH_ENABLED> d_void_ptrauth;
+}
|
…ypes llvm#159505 (llvm#159859) We can't give a correct answer for dependent types, so for now just report no ptrauth involves if the type being queried is dependent. In future we may want to distinguigh the `None` vs `Dependent` cases but that does not seem warranted for now. Fixes llvm#159505 (cherry picked from commit f6c711b)
|
@ojhunt (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. |
Fix error when performing bitwise layout queries of uninstantiated template types containing pointer authenticated fields and bases. |
Backport f6c711b
Requested by: @ojhunt