Author: David Spickett Date: 2022-10-24T10:16:29Z New Revision: 8d06ef5658187bf6a3eda61a5ec3627c1ff33fb8
URL: https://github.com/llvm/llvm-project/commit/8d06ef5658187bf6a3eda61a5ec3627c1ff33fb8 DIFF: https://github.com/llvm/llvm-project/commit/8d06ef5658187bf6a3eda61a5ec3627c1ff33fb8.diff LOG: [LLDB] Check that RegisterInfo and ContextInfo are trivial RegisterInfo is often initialised with a memcpy, and ContextInfo does not run destructors for anything within it. This was discussed in https://reviews.llvm.org/D134041. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D136584 Added: Modified: lldb/include/lldb/Core/EmulateInstruction.h lldb/include/lldb/lldb-private-types.h Removed: ################################################################################ diff --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h index 65b7982c36a0b..64633e9cf29be 100644 --- a/lldb/include/lldb/Core/EmulateInstruction.h +++ b/lldb/include/lldb/Core/EmulateInstruction.h @@ -189,7 +189,7 @@ class EmulateInstruction : public PluginInterface { public: enum InfoType GetInfoType() const { return info_type; } - union { + union ContextInfo { struct RegisterPlusOffset { RegisterInfo reg; // base register int64_t signed_offset; // signed offset added to base register @@ -241,6 +241,8 @@ class EmulateInstruction : public PluginInterface { uint32_t isa; } info; + static_assert(std::is_trivial<ContextInfo>::value, + "ContextInfo must be trivial."); Context() = default; diff --git a/lldb/include/lldb/lldb-private-types.h b/lldb/include/lldb/lldb-private-types.h index 1b0d263e2073b..edc1c78985bdd 100644 --- a/lldb/include/lldb/lldb-private-types.h +++ b/lldb/include/lldb/lldb-private-types.h @@ -15,6 +15,8 @@ #include "llvm/ADT/ArrayRef.h" +#include <type_traits> + namespace llvm { namespace sys { class DynamicLibrary; @@ -70,6 +72,8 @@ struct RegisterInfo { byte_size); } }; +static_assert(std::is_trivial<RegisterInfo>::value, + "RegisterInfo must be trivial."); /// Registers are grouped into register sets struct RegisterSet { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits