Skip to content

Commit fffc12e

Browse files
ahmedbougachadtapuska
authored andcommitted
[clang] Annotate Cleanup to support ptrauth vtable diversity.
1 parent 7bfcd78 commit fffc12e

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
@@ -143,7 +143,7 @@ class EHScopeStack {
143143
///
144144
/// Cleanup implementations should generally be declared in an
145145
/// anonymous namespace.
146-
class Cleanup {
146+
class LLVM_MOVABLE_POLYMORPHIC_TYPE Cleanup {
147147
// Anchor the construction vtable.
148148
virtual void anchor();
149149

llvm/include/llvm/Support/Compiler.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,4 +696,23 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
696696
#define LLVM_PREFERRED_TYPE(T)
697697
#endif
698698

699+
#ifdef __cplusplus
700+
namespace llvm {
701+
702+
/// \macro LLVM_MOVABLE_POLYMORPHIC_TYPE
703+
/// Configures vtable pointer authentication for a struct to allow the structs
704+
/// to be moved
705+
#if LLVM_HAS_CPP_ATTRIBUTE(clang::ptrauth_vtable_pointer) && \
706+
__has_feature(ptrauth_intrinsics)
707+
#define LLVM_MOVABLE_POLYMORPHIC_TYPE \
708+
[[clang::ptrauth_vtable_pointer(default_key, no_address_discrimination, \
709+
default_extra_discrimination)]]
710+
#else
711+
#define LLVM_MOVABLE_POLYMORPHIC_TYPE
712+
#endif
713+
714+
} // End namespace llvm
715+
716+
#endif // __cplusplus
717+
699718
#endif

0 commit comments

Comments
 (0)