Skip to content

Commit 6981eb5

Browse files
committed
[clang] Annotate Cleanup to support ptrauth vtable diversity.
1 parent e74fef2 commit 6981eb5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

clang/lib/CodeGen/EHScopeStack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class EHScopeStack {
138138
///
139139
/// Cleanup implementations should generally be declared in an
140140
/// anonymous namespace.
141-
class Cleanup {
141+
class LLVM_MOVABLE_POLYMORPHIC_TYPE Cleanup {
142142
// Anchor the construction vtable.
143143
virtual void anchor();
144144

llvm/include/llvm/Support/Compiler.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,4 +569,23 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
569569
#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION
570570
#endif
571571

572+
#ifdef __cplusplus
573+
namespace llvm {
574+
575+
/// \macro LLVM_MOVABLE_POLYMORPHIC_TYPE
576+
/// Configures vtable pointer authentication for a struct to allow the structs
577+
/// to be moved
578+
#if LLVM_HAS_CPP_ATTRIBUTE(clang::ptrauth_vtable_pointer) && \
579+
__has_feature(ptrauth_intrinsics)
580+
#define LLVM_MOVABLE_POLYMORPHIC_TYPE \
581+
[[clang::ptrauth_vtable_pointer(default_key, no_address_discrimination, \
582+
default_extra_discrimination)]]
583+
#else
584+
#define LLVM_MOVABLE_POLYMORPHIC_TYPE
585+
#endif
586+
587+
} // End namespace llvm
588+
589+
#endif // __cplusplus
590+
572591
#endif

0 commit comments

Comments
 (0)