diff options
| author | Zachary Turner <zturner@google.com> | 2016-09-22 20:22:55 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2016-09-22 20:22:55 +0000 |
| commit | 1f0f5b5b9eeaea93126583b40070091baf3bc92d (patch) | |
| tree | 93be6068ce5a7314fb9bfdf0621f65c03b3cad0b /lldb/source/Target | |
| parent | 387eb83a509926ed6bd36591d1f235335ec215c0 (diff) | |
| download | bcm5719-llvm-1f0f5b5b9eeaea93126583b40070091baf3bc92d.tar.gz bcm5719-llvm-1f0f5b5b9eeaea93126583b40070091baf3bc92d.zip | |
Convert option tables to ArrayRefs.
This change is very mechanical. All it does is change the
signature of `Options::GetDefinitions()` and `OptionGroup::
GetDefinitions()` to return an `ArrayRef<OptionDefinition>`
instead of a `const OptionDefinition *`. In the case of the
former, it deletes the sentinel entry from every table, and
in the case of the latter, it removes the `GetNumDefinitions()`
method from the interface. These are no longer necessary as
`ArrayRef` carries its own length.
In the former case, iteration was done by using a sentinel
entry, so there was no knowledge of length. Because of this
the individual option tables were allowed to be defined below
the corresponding class (after all, only a pointer was needed).
Now, however, the length must be known at compile time to
construct the `ArrayRef`, and as a result it is necessary to
move every option table before its corresponding class. This
results in this CL looking very big, but in terms of substance
there is not much here.
Differential revision: https://reviews.llvm.org/D24834
llvm-svn: 282188
Diffstat (limited to 'lldb/source/Target')
| -rw-r--r-- | lldb/source/Target/Platform.cpp | 20 | ||||
| -rw-r--r-- | lldb/source/Target/Process.cpp | 8 |
2 files changed, 9 insertions, 19 deletions
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 6b0e0989cc4..73f28ecd843 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -1387,8 +1387,7 @@ static OptionDefinition g_caching_option_table[] = { "Path in which to store local copies of files."}, }; -const lldb_private::OptionDefinition * -OptionGroupPlatformRSync::GetDefinitions() { +llvm::ArrayRef<OptionDefinition> OptionGroupPlatformRSync::GetDefinitions() { return g_rsync_option_table; } @@ -1431,16 +1430,12 @@ OptionGroupPlatformRSync::SetOptionValue(uint32_t option_idx, return error; } -uint32_t OptionGroupPlatformRSync::GetNumDefinitions() { - return llvm::array_lengthof(g_rsync_option_table); -} - lldb::BreakpointSP Platform::SetThreadCreationBreakpoint(lldb_private::Target &target) { return lldb::BreakpointSP(); } -const lldb_private::OptionDefinition *OptionGroupPlatformSSH::GetDefinitions() { +llvm::ArrayRef<OptionDefinition> OptionGroupPlatformSSH::GetDefinitions() { return g_ssh_option_table; } @@ -1473,12 +1468,7 @@ OptionGroupPlatformSSH::SetOptionValue(uint32_t option_idx, return error; } -uint32_t OptionGroupPlatformSSH::GetNumDefinitions() { - return llvm::array_lengthof(g_ssh_option_table); -} - -const lldb_private::OptionDefinition * -OptionGroupPlatformCaching::GetDefinitions() { +llvm::ArrayRef<OptionDefinition> OptionGroupPlatformCaching::GetDefinitions() { return g_caching_option_table; } @@ -1505,10 +1495,6 @@ lldb_private::Error OptionGroupPlatformCaching::SetOptionValue( return error; } -uint32_t OptionGroupPlatformCaching::GetNumDefinitions() { - return llvm::array_lengthof(g_caching_option_table); -} - size_t Platform::GetEnvironment(StringList &environment) { environment.Clear(); return false; diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 7837881fb82..458cce00374 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -529,7 +529,7 @@ Error ProcessLaunchCommandOptions::SetOptionValue( return error; } -OptionDefinition ProcessLaunchCommandOptions::g_option_table[] = { +static OptionDefinition g_process_launch_options[] = { {LLDB_OPT_SET_ALL, false, "stop-at-entry", 's', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."}, @@ -576,7 +576,11 @@ OptionDefinition ProcessLaunchCommandOptions::g_option_table[] = { {LLDB_OPT_SET_4, false, "shell-expand-args", 'X', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Set whether to shell expand arguments to the process when launching."}, - {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}}; +}; + +llvm::ArrayRef<OptionDefinition> ProcessLaunchCommandOptions::GetDefinitions() { + return g_process_launch_options; +} bool ProcessInstanceInfoMatch::NameMatches(const char *process_name) const { if (m_name_match_type == eNameMatchIgnore || process_name == nullptr) |

