From: Don Hinton Date: Mon, 29 Apr 2019 18:34:18 +0000 (+0000) Subject: [CommandLine] Don't allow unlimitted dashes for options. Part 1 or 5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9054a63dc1d54c5b120954f29d306c27faba4099;p=llvm [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359480 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 7da3862302c..18492e2a189 100644 --- a/lib/Support/CommandLine.cpp +++ b/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); diff --git a/test/DebugInfo/X86/array.ll b/test/DebugInfo/X86/array.ll index 6493b10c533..c667a999544 100644 --- a/test/DebugInfo/X86/array.ll +++ b/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) diff --git a/test/DebugInfo/dwarfdump-64-bit-dwarf.test b/test/DebugInfo/dwarfdump-64-bit-dwarf.test index 329dce0136e..af07eaac1f9 100644 --- a/test/DebugInfo/dwarfdump-64-bit-dwarf.test +++ b/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.