[PATCH] D61229: [CommandLine] Don't allow unlimitted dashes for options.

Don Hinton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 27 10:59:51 PDT 2019


hintonda created this revision.
hintonda added a reviewer: rnk.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Prior to this patch, the CommandLine parser would strip an
unlimitted number of dashes from options.  This patch limits it to
two.

This is the first of a set of patches that address how dashes are
handled by the CommandLine parser.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61229

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


Index: llvm/test/DebugInfo/dwarfdump-64-bit-dwarf.test
===================================================================
--- llvm/test/DebugInfo/dwarfdump-64-bit-dwarf.test
+++ llvm/test/DebugInfo/dwarfdump-64-bit-dwarf.test
@@ -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.
Index: llvm/test/DebugInfo/X86/array.ll
===================================================================
--- llvm/test/DebugInfo/X86/array.ll
+++ llvm/test/DebugInfo/X86/array.ll
@@ -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: llvm/lib/Support/CommandLine.cpp
===================================================================
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -1306,8 +1306,8 @@
       // 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 @@
 
     } 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61229.196979.patch
Type: text/x-patch
Size: 2039 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190427/074f7b5c/attachment.bin>


More information about the llvm-commits mailing list