diff --git a/clang/lib/CIR/CodeGen/EHScopeStack.h b/clang/lib/CIR/CodeGen/EHScopeStack.h index 47478f6cf4bb3..c87a6ef9660ad 100644 --- a/clang/lib/CIR/CodeGen/EHScopeStack.h +++ b/clang/lib/CIR/CodeGen/EHScopeStack.h @@ -90,7 +90,7 @@ class EHScopeStack { /// /// Cleanup implementations should generally be declared in an /// anonymous namespace. - class Cleanup { + class LLVM_MOVABLE_POLYMORPHIC_TYPE Cleanup { // Anchor the construction vtable. virtual void anchor(); diff --git a/clang/lib/CodeGen/EHScopeStack.h b/clang/lib/CodeGen/EHScopeStack.h index 54f6ceaa52b95..2dcb75556c4e5 100644 --- a/clang/lib/CodeGen/EHScopeStack.h +++ b/clang/lib/CodeGen/EHScopeStack.h @@ -143,7 +143,7 @@ class EHScopeStack { /// /// Cleanup implementations should generally be declared in an /// anonymous namespace. - class alignas(uint64_t) Cleanup { + class LLVM_MOVABLE_POLYMORPHIC_TYPE alignas(uint64_t) Cleanup { // Anchor the construction vtable. virtual void anchor(); diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h index 297d3e9b04095..56f498a36ae52 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -706,6 +706,15 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); #define LLVM_PREFERRED_TYPE(T) #endif +#if LLVM_HAS_CPP_ATTRIBUTE(clang::ptrauth_vtable_pointer) && \ + (defined(__PTRAUTH__) || __has_feature(ptrauth_calls)) +#define LLVM_MOVABLE_POLYMORPHIC_TYPE \ + [[clang::ptrauth_vtable_pointer(default_key, no_address_discrimination, \ + default_extra_discrimination)]] +#else +#define LLVM_MOVABLE_POLYMORPHIC_TYPE +#endif + /// \macro LLVM_VIRTUAL_ANCHOR_FUNCTION /// This macro is used to adhere to LLVM's policy that each class with a vtable /// must have at least one out-of-line virtual function. This macro allows us