Skip to content

Commit

Permalink
[LLDB] Applying clang-tidy modernize-use-default-member-init over LLDB
Browse files Browse the repository at this point in the history
Applied modernize-use-default-member-init clang-tidy check over LLDB.
It appears in many files we had already switched to in class member init but
never updated the constructors to reflect that. This check is already present in
the lldb/.clang-tidy config.

Differential Revision: https://reviews.llvm.org/D121481
  • Loading branch information
shafik committed Mar 14, 2022
1 parent c79ab10 commit 28c878a
Show file tree
Hide file tree
Showing 59 changed files with 256 additions and 338 deletions.
2 changes: 1 addition & 1 deletion lldb/source/API/SBBroadcaster.cpp
Expand Up @@ -19,7 +19,7 @@ using namespace lldb_private;
SBBroadcaster::SBBroadcaster() { LLDB_INSTRUMENT_VA(this); }

SBBroadcaster::SBBroadcaster(const char *name)
: m_opaque_sp(new Broadcaster(nullptr, name)), m_opaque_ptr(nullptr) {
: m_opaque_sp(new Broadcaster(nullptr, name)) {
LLDB_INSTRUMENT_VA(this, name);

m_opaque_ptr = m_opaque_sp.get();
Expand Down
7 changes: 3 additions & 4 deletions lldb/source/API/SBListener.cpp
Expand Up @@ -23,12 +23,11 @@ using namespace lldb_private;
SBListener::SBListener() { LLDB_INSTRUMENT_VA(this); }

SBListener::SBListener(const char *name)
: m_opaque_sp(Listener::MakeListener(name)), m_unused_ptr(nullptr) {
: m_opaque_sp(Listener::MakeListener(name)) {
LLDB_INSTRUMENT_VA(this, name);
}

SBListener::SBListener(const SBListener &rhs)
: m_opaque_sp(rhs.m_opaque_sp), m_unused_ptr(nullptr) {
SBListener::SBListener(const SBListener &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
LLDB_INSTRUMENT_VA(this, rhs);
}

Expand All @@ -43,7 +42,7 @@ const lldb::SBListener &SBListener::operator=(const lldb::SBListener &rhs) {
}

SBListener::SBListener(const lldb::ListenerSP &listener_sp)
: m_opaque_sp(listener_sp), m_unused_ptr(nullptr) {}
: m_opaque_sp(listener_sp) {}

SBListener::~SBListener() = default;

Expand Down
3 changes: 1 addition & 2 deletions lldb/source/API/SBPlatform.cpp
Expand Up @@ -48,8 +48,7 @@ struct PlatformConnectOptions {
// PlatformShellCommand
struct PlatformShellCommand {
PlatformShellCommand(llvm::StringRef shell_interpreter,
llvm::StringRef shell_command)
: m_status(0), m_signo(0) {
llvm::StringRef shell_command) {
if (!shell_interpreter.empty())
m_shell = shell_interpreter.str();

Expand Down
5 changes: 1 addition & 4 deletions lldb/source/API/SBQueue.cpp
Expand Up @@ -29,10 +29,7 @@ class QueueImpl {
public:
QueueImpl() {}

QueueImpl(const lldb::QueueSP &queue_sp)
: m_thread_list_fetched(false), m_pending_items_fetched(false) {
m_queue_wp = queue_sp;
}
QueueImpl(const lldb::QueueSP &queue_sp) { m_queue_wp = queue_sp; }

QueueImpl(const QueueImpl &rhs) {
if (&rhs == this)
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Commands/CommandObjectCommands.cpp
Expand Up @@ -1076,7 +1076,7 @@ class CommandObjectPythonFunction : public CommandObjectRaw {
std::string funct, std::string help,
ScriptedCommandSynchronicity synch)
: CommandObjectRaw(interpreter, name), m_function_name(funct),
m_synchro(synch), m_fetched_help_long(false) {
m_synchro(synch) {
if (!help.empty())
SetHelp(help);
else {
Expand Down Expand Up @@ -1139,7 +1139,7 @@ class CommandObjectPythonFunction : public CommandObjectRaw {
private:
std::string m_function_name;
ScriptedCommandSynchronicity m_synchro;
bool m_fetched_help_long;
bool m_fetched_help_long = false;
};

class CommandObjectScriptingObject : public CommandObjectRaw {
Expand Down
14 changes: 6 additions & 8 deletions lldb/source/Commands/CommandObjectMemory.cpp
Expand Up @@ -295,7 +295,6 @@ class CommandObjectMemoryRead : public CommandObjectParsed {
eCommandRequiresTarget | eCommandProcessMustBePaused),
m_format_options(eFormatBytesWithASCII, 1, 8),

m_next_addr(LLDB_INVALID_ADDRESS), m_prev_byte_size(0),
m_prev_format_options(eFormatBytesWithASCII, 1, 8) {
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
Expand Down Expand Up @@ -877,8 +876,8 @@ class CommandObjectMemoryRead : public CommandObjectParsed {
OptionGroupReadMemory m_memory_options;
OptionGroupOutputFile m_outfile_options;
OptionGroupValueObjectDisplay m_varobj_options;
lldb::addr_t m_next_addr;
lldb::addr_t m_prev_byte_size;
lldb::addr_t m_next_addr = LLDB_INVALID_ADDRESS;
lldb::addr_t m_prev_byte_size = 0;
OptionGroupFormat m_prev_format_options;
OptionGroupReadMemory m_prev_memory_options;
OptionGroupOutputFile m_prev_outfile_options;
Expand Down Expand Up @@ -986,7 +985,7 @@ class CommandObjectMemoryFind : public CommandObjectParsed {
class ProcessMemoryIterator {
public:
ProcessMemoryIterator(ProcessSP process_sp, lldb::addr_t base)
: m_process_sp(process_sp), m_base_addr(base), m_is_valid(true) {
: m_process_sp(process_sp), m_base_addr(base) {
lldbassert(process_sp.get() != nullptr);
}

Expand All @@ -1010,7 +1009,7 @@ class CommandObjectMemoryFind : public CommandObjectParsed {
private:
ProcessSP m_process_sp;
lldb::addr_t m_base_addr;
bool m_is_valid;
bool m_is_valid = true;
};
bool DoExecute(Args &command, CommandReturnObject &result) override {
// No need to check "process" for validity as eCommandRequiresProcess
Expand Down Expand Up @@ -1646,8 +1645,7 @@ class CommandObjectMemoryRegion : public CommandObjectParsed {
"an address in the current target process.",
"memory region ADDR",
eCommandRequiresProcess | eCommandTryTargetAPILock |
eCommandProcessMustBeLaunched),
m_prev_end_addr(LLDB_INVALID_ADDRESS) {}
eCommandProcessMustBeLaunched) {}

~CommandObjectMemoryRegion() override = default;

Expand Down Expand Up @@ -1757,7 +1755,7 @@ class CommandObjectMemoryRegion : public CommandObjectParsed {
return m_cmd_name;
}

lldb::addr_t m_prev_end_addr;
lldb::addr_t m_prev_end_addr = LLDB_INVALID_ADDRESS;
};

// CommandObjectMemory
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Commands/CommandObjectMemoryTag.cpp
Expand Up @@ -138,7 +138,7 @@ class CommandObjectMemoryTagWrite : public CommandObjectParsed {
public:
class OptionGroupTagWrite : public OptionGroup {
public:
OptionGroupTagWrite() : m_end_addr(LLDB_INVALID_ADDRESS) {}
OptionGroupTagWrite() {}

~OptionGroupTagWrite() override = default;

Expand Down Expand Up @@ -168,7 +168,7 @@ class CommandObjectMemoryTagWrite : public CommandObjectParsed {
m_end_addr = LLDB_INVALID_ADDRESS;
}

lldb::addr_t m_end_addr;
lldb::addr_t m_end_addr = LLDB_INVALID_ADDRESS;
};

CommandObjectMemoryTagWrite(CommandInterpreter &interpreter)
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Commands/CommandObjectProcess.cpp
Expand Up @@ -1214,7 +1214,7 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed {

class CommandOptions : public Options {
public:
CommandOptions() : m_requested_save_core_style(eSaveCoreUnspecified) {}
CommandOptions() {}

~CommandOptions() override = default;

Expand Down Expand Up @@ -1250,7 +1250,7 @@ class CommandObjectProcessSaveCore : public CommandObjectParsed {
}

// Instance variables to hold the values for command options.
SaveCoreStyle m_requested_save_core_style;
SaveCoreStyle m_requested_save_core_style = eSaveCoreUnspecified;
std::string m_requested_plugin_name;
};

Expand Down
5 changes: 2 additions & 3 deletions lldb/source/Commands/CommandObjectThread.cpp
Expand Up @@ -2184,8 +2184,7 @@ class CommandObjectTraceDumpInstructions
nullptr,
eCommandRequiresProcess | eCommandTryTargetAPILock |
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused |
eCommandProcessMustBeTraced),
m_create_repeat_command_just_invoked(false) {}
eCommandProcessMustBeTraced) {}

~CommandObjectTraceDumpInstructions() override = default;

Expand Down Expand Up @@ -2253,7 +2252,7 @@ class CommandObjectTraceDumpInstructions

// Repeat command helpers
std::string m_repeat_command;
bool m_create_repeat_command_just_invoked;
bool m_create_repeat_command_just_invoked = false;
std::map<lldb::tid_t, std::unique_ptr<TraceInstructionDumper>> m_dumpers;
};

Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Core/Address.cpp
Expand Up @@ -233,7 +233,7 @@ static size_t ReadCStringFromMemory(ExecutionContextScope *exe_scope,
Address::Address(lldb::addr_t abs_addr) : m_section_wp(), m_offset(abs_addr) {}

Address::Address(addr_t address, const SectionList *section_list)
: m_section_wp(), m_offset(LLDB_INVALID_ADDRESS) {
: m_section_wp() {
ResolveAddressUsingFileSections(address, section_list);
}

Expand Down
5 changes: 2 additions & 3 deletions lldb/source/Core/FormatEntity.cpp
Expand Up @@ -263,11 +263,10 @@ constexpr Definition g_root = Entry::DefinitionWithChildren(

FormatEntity::Entry::Entry(llvm::StringRef s)
: string(s.data(), s.size()), printf_format(), children(),
type(Type::String), fmt(lldb::eFormatDefault), number(0), deref(false) {}
type(Type::String) {}

FormatEntity::Entry::Entry(char ch)
: string(1, ch), printf_format(), children(), type(Type::String),
fmt(lldb::eFormatDefault), number(0), deref(false) {}
: string(1, ch), printf_format(), children(), type(Type::String) {}

void FormatEntity::Entry::AppendChar(char ch) {
if (children.empty() || children.back().type != Entry::Type::String)
Expand Down

0 comments on commit 28c878a

Please sign in to comment.