DavidSpickett created this revision.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136584

Files:
  lldb/include/lldb/Core/EmulateInstruction.h
  lldb/include/lldb/lldb-private-types.h


Index: lldb/include/lldb/lldb-private-types.h
===================================================================
--- lldb/include/lldb/lldb-private-types.h
+++ 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 @@
                                           byte_size);
   }
 };
+static_assert(std::is_trivial<RegisterInfo>::value,
+              "RegisterInfo must be trivial.");
 
 /// Registers are grouped into register sets
 struct RegisterSet {
Index: lldb/include/lldb/Core/EmulateInstruction.h
===================================================================
--- lldb/include/lldb/Core/EmulateInstruction.h
+++ lldb/include/lldb/Core/EmulateInstruction.h
@@ -189,7 +189,7 @@
 
   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 @@
 
       uint32_t isa;
     } info;
+    static_assert(std::is_trivial<ContextInfo>::value,
+                  "ContextInfo must be trivial.");
 
     Context() = default;
 


Index: lldb/include/lldb/lldb-private-types.h
===================================================================
--- lldb/include/lldb/lldb-private-types.h
+++ 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 @@
                                           byte_size);
   }
 };
+static_assert(std::is_trivial<RegisterInfo>::value,
+              "RegisterInfo must be trivial.");
 
 /// Registers are grouped into register sets
 struct RegisterSet {
Index: lldb/include/lldb/Core/EmulateInstruction.h
===================================================================
--- lldb/include/lldb/Core/EmulateInstruction.h
+++ lldb/include/lldb/Core/EmulateInstruction.h
@@ -189,7 +189,7 @@
 
   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 @@
 
       uint32_t isa;
     } info;
+    static_assert(std::is_trivial<ContextInfo>::value,
+                  "ContextInfo must be trivial.");
 
     Context() = default;
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits] [PATCH] D13... David Spickett via Phabricator via lldb-commits

Reply via email to