]> granicus.if.org Git - llvm/commitdiff
[CommandLine] Don't allow unlimitted dashes for options. Part 1 or 5
authorDon Hinton <hintonda@gmail.com>
Mon, 29 Apr 2019 18:34:18 +0000 (18:34 +0000)
committerDon Hinton <hintonda@gmail.com>
Mon, 29 Apr 2019 18:34:18 +0000 (18:34 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359480 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/CommandLine.cpp
test/DebugInfo/X86/array.ll
test/DebugInfo/dwarfdump-64-bit-dwarf.test

index 7da3862302c9f294c1e57892479240d86908b071..18492e2a189423474b92b9125ed1c5331c9279f9 100644 (file)
@@ -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);
index 6493b10c53398c56e8eff85afc2b9ee66fdca105..c667a99954484cfbf8b4ef8362259a1924bcedca 100644 (file)
@@ -13,7 +13,7 @@
 ; }
 ;
 ; RUN: llc -filetype=asm %s -o - | FileCheck %s
-; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump -v - ---debug-info | FileCheck %s --check-prefix=DWARF
+; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump -v - --debug-info | FileCheck %s --check-prefix=DWARF
 
 ; CHECK-LABEL: _main:
 ; CHECK: movaps {{.*}}, (%rsp)
index 329dce0136e84273109b8150c825c4e168713c38..af07eaac1f93db8b1df39915505bc7f7e7e5df14 100644 (file)
@@ -1,5 +1,5 @@
 RUN: llvm-dwarfdump %p/Inputs/dwarfdump.elf-mips64-64-bit-dwarf \
-RUN:   ---debug-line | FileCheck %s
+RUN:   --debug-line | FileCheck %s
 
 # FIXME: llvm-dwarfdump's support for 64-bit dwarf is currently limited to
 # .debug_line.