summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
authorDon Hinton <hintonda@gmail.com>2019-04-29 18:34:18 +0000
committerDon Hinton <hintonda@gmail.com>2019-04-29 18:34:18 +0000
commit89e583b843b5d2cefee8a486caa4849f3d742e82 (patch)
tree8b4fa90400afbe03559c2e3552f3ab63e6868815 /llvm/lib/Support/CommandLine.cpp
parent0a5c2b244930984f6ad920d901dcc362032a7e85 (diff)
downloadbcm5719-llvm-89e583b843b5d2cefee8a486caa4849f3d742e82.tar.gz
bcm5719-llvm-89e583b843b5d2cefee8a486caa4849f3d742e82.zip
[CommandLine] Don't allow unlimitted dashes for options. Part 1 or 5
Summary: Prior to this patch, the CommandLine parser would strip an unlimitted number of dashes from options. This patch limits it to two. Reviewers: rnk Reviewed By: rnk Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61229 llvm-svn: 359480
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r--llvm/lib/Support/CommandLine.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 7da3862302c..18492e2a189 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -1306,8 +1306,8 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
// option is another positional argument. If so, treat it as an argument,
// otherwise feed it to the eating positional.
ArgName = StringRef(argv[i] + 1);
- // Eat leading dashes.
- while (!ArgName.empty() && ArgName[0] == '-')
+ // Eat second dash.
+ if (!ArgName.empty() && ArgName[0] == '-')
ArgName = ArgName.substr(1);
Handler = LookupOption(*ChosenSubCommand, ArgName, Value);
@@ -1318,8 +1318,8 @@ bool CommandLineParser::ParseCommandLineOptions(int argc,
} else { // We start with a '-', must be an argument.
ArgName = StringRef(argv[i] + 1);
- // Eat leading dashes.
- while (!ArgName.empty() && ArgName[0] == '-')
+ // Eat second dash.
+ if (!ArgName.empty() && ArgName[0] == '-')
ArgName = ArgName.substr(1);
Handler = LookupOption(*ChosenSubCommand, ArgName, Value);
OpenPOWER on IntegriCloud