[Lldb-commits] [lldb] r286747 - Make OptionParser::Parse() take StringRef.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Sat Nov 12 20:24:39 PST 2016
Author: zturner
Date: Sat Nov 12 22:24:38 2016
New Revision: 286747
URL: http://llvm.org/viewvc/llvm-project?rev=286747&view=rev
Log:
Make OptionParser::Parse() take StringRef.
Modified:
lldb/trunk/include/lldb/Host/OptionParser.h
lldb/trunk/source/Host/common/OptionParser.cpp
lldb/trunk/source/Interpreter/Args.cpp
Modified: lldb/trunk/include/lldb/Host/OptionParser.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/OptionParser.h?rev=286747&r1=286746&r2=286747&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/OptionParser.h (original)
+++ lldb/trunk/include/lldb/Host/OptionParser.h Sat Nov 12 22:24:38 2016
@@ -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();
Modified: lldb/trunk/source/Host/common/OptionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/OptionParser.cpp?rev=286747&r1=286746&r2=286747&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/OptionParser.cpp (original)
+++ lldb/trunk/source/Host/common/OptionParser.cpp Sat Nov 12 22:24:38 2016
@@ -28,7 +28,7 @@ void OptionParser::Prepare(std::unique_l
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 *
++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; }
Modified: lldb/trunk/source/Interpreter/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=286747&r1=286746&r2=286747&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Args.cpp (original)
+++ lldb/trunk/source/Interpreter/Args.cpp Sat Nov 12 22:24:38 2016
@@ -457,9 +457,9 @@ Error Args::ParseOptions(Options &option
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(Option
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,
More information about the lldb-commits
mailing list