Skip to content

Commit

Permalink
Fix a bug exposed by lli
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3049 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Jul 24, 2002
1 parent e2c677f commit faba809
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 deletions lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,17 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
unsigned ValNo = 0;
for (unsigned j = 1, e = PositionalOpts.size(); j != e; ++j)
if (RequiresValue(PositionalOpts[j]))
ErrorParsing |=
ProvidePositionalOption(PositionalOpts[j], PositionalVals[ValNo++]);
ErrorParsing |= ProvidePositionalOption(PositionalOpts[j],
PositionalVals[ValNo++]);

// Handle the case where there is just one positional option, and it's
// optional. In this case, we want to give JUST THE FIRST option to the
// positional option and keep the rest for the consume after. The above
// loop would have assigned no values to positional options in this case.
//
if (PositionalOpts.size() == 2 && ValNo == 0)
ErrorParsing |= ProvidePositionalOption(PositionalOpts[1],
PositionalVals[ValNo++]);

// Handle over all of the rest of the arguments to the
// cl::ConsumeAfter command line option...
Expand Down
13 changes: 11 additions & 2 deletions support/lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,17 @@ void cl::ParseCommandLineOptions(int &argc, char **argv,
unsigned ValNo = 0;
for (unsigned j = 1, e = PositionalOpts.size(); j != e; ++j)
if (RequiresValue(PositionalOpts[j]))
ErrorParsing |=
ProvidePositionalOption(PositionalOpts[j], PositionalVals[ValNo++]);
ErrorParsing |= ProvidePositionalOption(PositionalOpts[j],
PositionalVals[ValNo++]);

// Handle the case where there is just one positional option, and it's
// optional. In this case, we want to give JUST THE FIRST option to the
// positional option and keep the rest for the consume after. The above
// loop would have assigned no values to positional options in this case.
//
if (PositionalOpts.size() == 2 && ValNo == 0)
ErrorParsing |= ProvidePositionalOption(PositionalOpts[1],
PositionalVals[ValNo++]);

// Handle over all of the rest of the arguments to the
// cl::ConsumeAfter command line option...
Expand Down

0 comments on commit faba809

Please sign in to comment.