[Lldb-commits] [lldb] r356459 - Fix a "memset clearing an object of non-trivial type" warning in EmulateInstruction
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 19 08:05:55 PDT 2019
Author: labath
Date: Tue Mar 19 08:05:55 2019
New Revision: 356459
URL: http://llvm.org/viewvc/llvm-project?rev=356459&view=rev
Log:
Fix a "memset clearing an object of non-trivial type" warning in EmulateInstruction
This is a new warning which started appearing as of gcc-8. The Opcode
class has a non-trivial constructor, so the idea of the warning is that
code should use that to initialize the object instead of using memset
(which can perturb class invariants set up by the constructor). In this
case, the Opcode default constructor was already clearing the object's
fields so we can just drop the memset call.
While I'm touching the EmulateInstruction constructor, I also move the
initialization of other members into the class declaration.
Modified:
lldb/trunk/include/lldb/Core/EmulateInstruction.h
lldb/trunk/source/Core/EmulateInstruction.cpp
Modified: lldb/trunk/include/lldb/Core/EmulateInstruction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/EmulateInstruction.h?rev=356459&r1=356458&r2=356459&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/EmulateInstruction.h (original)
+++ lldb/trunk/include/lldb/Core/EmulateInstruction.h Tue Mar 19 08:05:55 2019
@@ -511,12 +511,12 @@ public:
protected:
ArchSpec m_arch;
- void *m_baton;
- ReadMemoryCallback m_read_mem_callback;
- WriteMemoryCallback m_write_mem_callback;
- ReadRegisterCallback m_read_reg_callback;
- WriteRegisterCallback m_write_reg_callback;
- lldb::addr_t m_addr;
+ void *m_baton = nullptr;
+ ReadMemoryCallback m_read_mem_callback = &ReadMemoryDefault;
+ WriteMemoryCallback m_write_mem_callback = &WriteMemoryDefault;
+ ReadRegisterCallback m_read_reg_callback = &ReadRegisterDefault;
+ WriteRegisterCallback m_write_reg_callback = &WriteRegisterDefault;
+ lldb::addr_t m_addr = LLDB_INVALID_ADDRESS;
Opcode m_opcode;
private:
Modified: lldb/trunk/source/Core/EmulateInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=356459&r1=356458&r2=356459&view=diff
==============================================================================
--- lldb/trunk/source/Core/EmulateInstruction.cpp (original)
+++ lldb/trunk/source/Core/EmulateInstruction.cpp Tue Mar 19 08:05:55 2019
@@ -71,14 +71,7 @@ EmulateInstruction::FindPlugin(const Arc
return nullptr;
}
-EmulateInstruction::EmulateInstruction(const ArchSpec &arch)
- : m_arch(arch), m_baton(nullptr), m_read_mem_callback(&ReadMemoryDefault),
- m_write_mem_callback(&WriteMemoryDefault),
- m_read_reg_callback(&ReadRegisterDefault),
- m_write_reg_callback(&WriteRegisterDefault),
- m_addr(LLDB_INVALID_ADDRESS) {
- ::memset(&m_opcode, 0, sizeof(m_opcode));
-}
+EmulateInstruction::EmulateInstruction(const ArchSpec &arch) : m_arch(arch) {}
bool EmulateInstruction::ReadRegister(const RegisterInfo *reg_info,
RegisterValue ®_value) {
More information about the lldb-commits
mailing list