llvm.org GIT mirror llvm / b06ccef
Options: explicit handling of -- Clients of the option parsing library should handle it explicitly using a KIND_REMAINING_ARGS option. Clang and lld have been updated in r188316 and r188318, respectively. Also fix -Wsign-compare warning in the option parsing test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188323 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 6 years ago
2 changed file(s) with 1 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
258258 continue;
259259 }
260260
261 // FIXME: Remove once clients are updated to use a KIND_REMAINING_ARGS
262 // option to handle this explicitly instead.
263 if (Str == "--") {
264 // Everything after -- is a filename.
265 ++Index;
266
267 assert(TheInputOptionID != 0 && "Invalid input option ID.");
268 while (Index < End) {
269 Args->append(new Arg(getOption(TheInputOptionID),
270 Args->getArgString(Index), Index,
271 Args->getArgString(Index)));
272 ++Index;
273 }
274 break;
275 }
276
277261 unsigned Prev = Index;
278262 Arg *A = ParseOneArg(*Args, Index, FlagsToInclude, FlagsToExclude);
279263 assert(Index > Prev && "Parser failed to consume argument.");
156156 EXPECT_EQ(AL->getAllArgValues(OPT_B)[1], "bar");
157157 }
158158
159 TEST(Option, DashDash) {
160 TestOptTable T;
161 unsigned MAI, MAC;
162
163 const char *MyArgs[] = { "-A", "--", "-B", "--" };
164 OwningPtr AL(T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));
165 EXPECT_TRUE(AL->hasArg(OPT_A));
166 EXPECT_FALSE(AL->hasArg(OPT_B));
167 EXPECT_EQ(AL->getAllArgValues(OPT_INPUT).size(), 2U);
168 EXPECT_EQ(AL->getAllArgValues(OPT_INPUT)[0], "-B");
169 EXPECT_EQ(AL->getAllArgValues(OPT_INPUT)[1], "--");
170 }
171
172159 TEST(Option, SlurpEmpty) {
173160 TestOptTable T;
174161 unsigned MAI, MAC;
177164 OwningPtr AL(T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));
178165 EXPECT_TRUE(AL->hasArg(OPT_A));
179166 EXPECT_TRUE(AL->hasArg(OPT_Slurp));
180 EXPECT_EQ(AL->getAllArgValues(OPT_Slurp).size(), 0);
167 EXPECT_EQ(AL->getAllArgValues(OPT_Slurp).size(), 0U);
181168 }
182169
183170 TEST(Option, Slurp) {