[Lldb-commits] [PATCH] D103483: [lldb] Convert the default constructor’s member initializers into default member initializers
Shafik Yaghmour via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 2 14:45:20 PDT 2021
shafik added a comment.
Thank you for doing this! This will be a big improvement.
I am not done going through this change but I think it will require a bit more careful look though to make sure we are getting the maximum benefit from this refactor.
================
Comment at: lldb/include/lldb/Utility/VMRange.h:29
- VMRange() : m_base_addr(0), m_byte_size(0) {}
+ VMRange() {}
----------------
`= default`
================
Comment at: lldb/source/API/SBBroadcaster.cpp:19
-SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(nullptr) {
+SBBroadcaster::SBBroadcaster() : m_opaque_sp() {
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBroadcaster);
----------------
We don't need `m_opaque_sp()` this is a `std::shared_ptr` the default constructor will do the right thing.
================
Comment at: lldb/source/API/SBBroadcaster.cpp:24
SBBroadcaster::SBBroadcaster(const char *name)
: m_opaque_sp(new Broadcaster(nullptr, name)), m_opaque_ptr(nullptr) {
LLDB_RECORD_CONSTRUCTOR(SBBroadcaster, (const char *), name);
----------------
We don't need `m_opaque_ptr(nullptr)`
================
Comment at: lldb/source/API/SBCommandReturnObject.cpp:25
SBCommandReturnObjectImpl()
- : m_ptr(new CommandReturnObject(false)), m_owned(true) {}
+ : m_ptr(new CommandReturnObject(false)) {}
SBCommandReturnObjectImpl(CommandReturnObject &ref)
----------------
We can remove ` m_ptr(new CommandReturnObject(false))` and use `=default`
================
Comment at: lldb/source/API/SBCommandReturnObject.cpp:44
private:
CommandReturnObject *m_ptr;
+ bool m_owned = true;
----------------
`CommandReturnObject *m_ptr = new CommandReturnObject(false)`
Note, this is ok w/ the other constructors b/c [class.base.init/p10](http://eel.is/c++draft/class.base.init#10) tell us
> If a given non-static data member has both a default member initializer and a mem-initializer, the initialization specified by the mem-initializer is performed, and the non- static data member's default member initializer is ignored.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103483/new/
https://reviews.llvm.org/D103483
More information about the lldb-commits
mailing list