diff options
| author | Zachary Turner <zturner@google.com> | 2016-11-13 04:24:38 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2016-11-13 04:24:38 +0000 |
| commit | e706c1d9d91ecec741ef1dacdef629f3f8cb5f35 (patch) | |
| tree | db2827edc2248dd0bcf5c959085ea5960397d92f | |
| parent | 706d897d8a110b0392aff9b0f05e282dad2586ba (diff) | |
| download | bcm5719-llvm-e706c1d9d91ecec741ef1dacdef629f3f8cb5f35.tar.gz bcm5719-llvm-e706c1d9d91ecec741ef1dacdef629f3f8cb5f35.zip | |
Make OptionParser::Parse() take StringRef.
llvm-svn: 286747
| -rw-r--r-- | lldb/include/lldb/Host/OptionParser.h | 4 | ||||
| -rw-r--r-- | lldb/source/Host/common/OptionParser.cpp | 5 | ||||
| -rw-r--r-- | lldb/source/Interpreter/Args.cpp | 12 |
3 files changed, 12 insertions, 9 deletions
diff --git a/lldb/include/lldb/Host/OptionParser.h b/lldb/include/lldb/Host/OptionParser.h index b390e459bcd..1b0dc4ae19e 100644 --- a/lldb/include/lldb/Host/OptionParser.h +++ b/lldb/include/lldb/Host/OptionParser.h @@ -13,6 +13,8 @@ #include <mutex> #include <string> +#include "llvm/ADT/StringRef.h" + struct option; namespace lldb_private { @@ -36,7 +38,7 @@ public: static void EnableError(bool error); - static int Parse(int argc, char *const argv[], const char *optstring, + static int Parse(int argc, char *const argv[], llvm::StringRef optstring, const Option *longopts, int *longindex); static char *GetOptionArgument(); diff --git a/lldb/source/Host/common/OptionParser.cpp b/lldb/source/Host/common/OptionParser.cpp index 053179c19ee..d78bf335b40 100644 --- a/lldb/source/Host/common/OptionParser.cpp +++ b/lldb/source/Host/common/OptionParser.cpp @@ -28,7 +28,7 @@ void OptionParser::Prepare(std::unique_lock<std::mutex> &lock) { void OptionParser::EnableError(bool error) { opterr = error ? 1 : 0; } -int OptionParser::Parse(int argc, char *const argv[], const char *optstring, +int OptionParser::Parse(int argc, char *const argv[], llvm::StringRef optstring, const Option *longopts, int *longindex) { std::vector<option> opts; while (longopts->definition != nullptr) { @@ -41,7 +41,8 @@ int OptionParser::Parse(int argc, char *const argv[], const char *optstring, ++longopts; } opts.push_back(option()); - return getopt_long_only(argc, argv, optstring, &opts[0], longindex); + std::string opt_cstr = optstring; + return getopt_long_only(argc, argv, opt_cstr.c_str(), &opts[0], longindex); } char *OptionParser::GetOptionArgument() { return optarg; } diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index a2f18882b0e..b989ee1f218 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/lldb/source/Interpreter/Args.cpp @@ -457,9 +457,9 @@ Error Args::ParseOptions(Options &options, ExecutionContext *execution_context, int val; while (1) { int long_options_index = -1; - val = - OptionParser::Parse(GetArgumentCount(), GetArgumentVector(), - sstr.GetData(), long_options, &long_options_index); + val = OptionParser::Parse(GetArgumentCount(), GetArgumentVector(), + sstr.GetString(), long_options, + &long_options_index); if (val == -1) break; @@ -1175,9 +1175,9 @@ void Args::ParseArgsForCompletion(Options &options, bool missing_argument = false; int long_options_index = -1; - val = - OptionParser::Parse(dummy_vec.size() - 1, &dummy_vec[0], sstr.GetData(), - long_options, &long_options_index); + val = OptionParser::Parse(dummy_vec.size() - 1, &dummy_vec[0], + sstr.GetString(), long_options, + &long_options_index); if (val == -1) { // When we're completing a "--" which is the last option on line, |

