return new Arg(getOption(TheUnknownOptionID), Str, Index++, Str);
}
-InputArgList *OptTable::ParseArgs(const char *const *ArgBegin,
- const char *const *ArgEnd,
+InputArgList *OptTable::ParseArgs(ArrayRef<const char *> ArgArr,
unsigned &MissingArgIndex,
unsigned &MissingArgCount,
unsigned FlagsToInclude,
unsigned FlagsToExclude) const {
- InputArgList *Args = new InputArgList(ArgBegin, ArgEnd);
+ InputArgList *Args = new InputArgList(ArgArr.begin(), ArgArr.end());
// FIXME: Handle '@' args (or at least error on them).
MissingArgIndex = MissingArgCount = 0;
- unsigned Index = 0, End = ArgEnd - ArgBegin;
+ unsigned Index = 0, End = ArgArr.size();
while (Index < End) {
// Ingore nullptrs, they are response file's EOL markers
if (Args->getArgString(Index) == nullptr) {
TEST(Option, OptionParsing) {
TestOptTable T;
unsigned MAI, MAC;
- std::unique_ptr<InputArgList> AL(
- T.ParseArgs(std::begin(Args), std::end(Args), MAI, MAC));
+ std::unique_ptr<InputArgList> AL(T.ParseArgs(Args, MAI, MAC));
// Check they all exist.
EXPECT_TRUE(AL->hasArg(OPT_A));
std::unique_ptr<InputArgList> AL;
// Exclude flag3 to avoid parsing as OPT_SLASH_C.
- AL.reset(T.ParseArgs(std::begin(Args), std::end(Args), MAI, MAC,
+ AL.reset(T.ParseArgs(Args, MAI, MAC,
/*FlagsToInclude=*/0,
/*FlagsToExclude=*/OptFlag3));
EXPECT_TRUE(AL->hasArg(OPT_A));
EXPECT_FALSE(AL->hasArg(OPT_SLASH_C));
// Exclude flag1 to avoid parsing as OPT_C.
- AL.reset(T.ParseArgs(std::begin(Args), std::end(Args), MAI, MAC,
+ AL.reset(T.ParseArgs(Args, MAI, MAC,
/*FlagsToInclude=*/0,
/*FlagsToExclude=*/OptFlag1));
EXPECT_TRUE(AL->hasArg(OPT_B));
EXPECT_TRUE(AL->hasArg(OPT_SLASH_C));
const char *NewArgs[] = { "/C", "foo", "--C=bar" };
- AL.reset(T.ParseArgs(std::begin(NewArgs), std::end(NewArgs), MAI, MAC));
+ AL.reset(T.ParseArgs(NewArgs, MAI, MAC));
EXPECT_TRUE(AL->hasArg(OPT_SLASH_C));
EXPECT_TRUE(AL->hasArg(OPT_C));
EXPECT_EQ(AL->getLastArgValue(OPT_SLASH_C), "foo");
unsigned MAI, MAC;
const char *MyArgs[] = { "-I" };
- std::unique_ptr<InputArgList> AL(
- T.ParseArgs(std::begin(MyArgs), std::end(MyArgs), MAI, MAC));
+ std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));
EXPECT_TRUE(AL->hasArg(OPT_H));
}
unsigned MAI, MAC;
const char *MyArgs[] = { "-J", "-Joo" };
- std::unique_ptr<InputArgList> AL(
- T.ParseArgs(std::begin(MyArgs), std::end(MyArgs), MAI, MAC));
+ std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));
EXPECT_TRUE(AL->hasArg(OPT_B));
EXPECT_EQ(AL->getAllArgValues(OPT_B)[0], "foo");
EXPECT_EQ(AL->getAllArgValues(OPT_B)[1], "bar");
unsigned MAI, MAC;
const char *MyArgs[] = { "-a", "-joo" };
- std::unique_ptr<InputArgList> AL(
- T.ParseArgs(std::begin(MyArgs), std::end(MyArgs), MAI, MAC));
+ std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));
EXPECT_TRUE(AL->hasArg(OPT_A));
EXPECT_TRUE(AL->hasArg(OPT_B));
}
unsigned MAI, MAC;
const char *MyArgs[] = { "-a", "-joo" };
- std::unique_ptr<InputArgList> AL(
- T.ParseArgs(std::begin(MyArgs), std::end(MyArgs), MAI, MAC));
+ std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));
EXPECT_FALSE(AL->hasArg(OPT_A));
EXPECT_FALSE(AL->hasArg(OPT_B));
}
unsigned MAI, MAC;
const char *MyArgs[] = { "-A", "-slurp" };
- std::unique_ptr<InputArgList> AL(
- T.ParseArgs(std::begin(MyArgs), std::end(MyArgs), MAI, MAC));
+ std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));
EXPECT_TRUE(AL->hasArg(OPT_A));
EXPECT_TRUE(AL->hasArg(OPT_Slurp));
EXPECT_EQ(AL->getAllArgValues(OPT_Slurp).size(), 0U);
unsigned MAI, MAC;
const char *MyArgs[] = { "-A", "-slurp", "-B", "--", "foo" };
- std::unique_ptr<InputArgList> AL(
- T.ParseArgs(std::begin(MyArgs), std::end(MyArgs), MAI, MAC));
+ std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));
EXPECT_EQ(AL->size(), 2U);
EXPECT_TRUE(AL->hasArg(OPT_A));
EXPECT_FALSE(AL->hasArg(OPT_B));
// Check that a flag alias provides an empty argument to a joined option.
const char *MyArgs[] = { "-K" };
- std::unique_ptr<InputArgList> AL(
- T.ParseArgs(std::begin(MyArgs), std::end(MyArgs), MAI, MAC));
+ std::unique_ptr<InputArgList> AL(T.ParseArgs(MyArgs, MAI, MAC));
EXPECT_EQ(AL->size(), 1U);
EXPECT_TRUE(AL->hasArg(OPT_B));
EXPECT_EQ(AL->getAllArgValues(OPT_B).size(), 1U);