diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2018-12-11 20:19:53 +0000 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2018-12-11 20:19:53 +0000 |
| commit | fb3e58920dcc84edb169d122dd064cfcf1eb1349 (patch) | |
| tree | 9f105248407cec8f3e50e629903c11c9b5d530ed /lldb/tools/driver/Driver.cpp | |
| parent | 853a667812054efb1ce1533d9f299ba95098612a (diff) | |
| download | bcm5719-llvm-fb3e58920dcc84edb169d122dd064cfcf1eb1349.tar.gz bcm5719-llvm-fb3e58920dcc84edb169d122dd064cfcf1eb1349.zip | |
[Driver] Simplify OptionData. NFC
Hopefully this makes the option data easier to understand and maintain.
- Group the member variables.
- Do the initialization in the header as it's less error prone.
- Rename the Clean method. It was called only once and was
re-initializing some but not all (?) members. The only useful thing it
does is dealing with the local lldbinit file so keep that and make the
name reflect that.
llvm-svn: 348894
Diffstat (limited to 'lldb/tools/driver/Driver.cpp')
| -rw-r--r-- | lldb/tools/driver/Driver.cpp | 49 |
1 files changed, 8 insertions, 41 deletions
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index cd61cf66833..8a86fe0bf44 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -120,53 +120,22 @@ Driver::Driver() Driver::~Driver() { g_driver = NULL; } -Driver::OptionData::OptionData() - : m_args(), m_script_lang(lldb::eScriptLanguageDefault), m_core_file(), - m_crash_log(), m_initial_commands(), m_after_file_commands(), - m_after_crash_commands(), m_debug_mode(false), m_source_quietly(false), - m_print_version(false), m_print_python_path(false), m_wait_for(false), - m_repl(false), m_repl_lang(eLanguageTypeUnknown), m_repl_options(), - m_process_name(), m_process_pid(LLDB_INVALID_PROCESS_ID), - m_use_external_editor(false), m_batch(false), m_seen_options() {} - -Driver::OptionData::~OptionData() {} - -void Driver::OptionData::Clear() { - m_args.clear(); - m_script_lang = lldb::eScriptLanguageDefault; - m_initial_commands.clear(); - m_after_file_commands.clear(); - - // If there is a local .lldbinit, add that to the - // list of things to be sourced, if the settings - // permit it. +void Driver::OptionData::AddLocalLLDBInit() { + // If there is a local .lldbinit, add that to the list of things to be + // sourced, if the settings permit it. SBFileSpec local_lldbinit(".lldbinit", true); - SBFileSpec homedir_dot_lldb = SBHostOS::GetUserHomeDirectory(); homedir_dot_lldb.AppendPathComponent(".lldbinit"); - // Only read .lldbinit in the current working directory - // if it's not the same as the .lldbinit in the home - // directory (which is already being read in). + // Only read .lldbinit in the current working directory if it's not the same + // as the .lldbinit in the home directory (which is already being read in). if (local_lldbinit.Exists() && strcmp(local_lldbinit.GetDirectory(), homedir_dot_lldb.GetDirectory()) != 0) { - char path[2048]; - local_lldbinit.GetPath(path, 2047); + char path[PATH_MAX]; + local_lldbinit.GetPath(path, sizeof(path)); InitialCmdEntry entry(path, true, true, true); m_after_file_commands.push_back(entry); } - - m_debug_mode = false; - m_source_quietly = false; - m_print_version = false; - m_print_python_path = false; - m_use_external_editor = false; - m_wait_for = false; - m_process_name.erase(); - m_batch = false; - m_after_crash_commands.clear(); - - m_process_pid = LLDB_INVALID_PROCESS_ID; } void Driver::OptionData::AddInitialCommand(std::string command, @@ -201,8 +170,6 @@ void Driver::OptionData::AddInitialCommand(std::string command, command_set->push_back(InitialCmdEntry(command, is_file, false)); } -void Driver::ResetOptionValues() { m_option_data.Clear(); } - const char *Driver::GetFilename() const { if (m_option_data.m_args.empty()) return NULL; @@ -284,7 +251,7 @@ bool Driver::GetDebugMode() const { return m_option_data.m_debug_mode; } // user only wanted help or version information. SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) { SBError error; - ResetOptionValues(); + m_option_data.AddLocalLLDBInit(); // This is kind of a pain, but since we make the debugger in the Driver's // constructor, we can't know at that point whether we should read in init |

