[PATCH] D150568: OptTable: stop parsing options after "--" alone.
Tim Northover via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 25 06:24:48 PDT 2023
t.p.northover updated this revision to Diff 525575.
t.p.northover added a comment.
Test was leaving stray files in the source dir.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150568/new/
https://reviews.llvm.org/D150568
Files:
llvm/test/tools/llvm-nm/option--.test
llvm/tools/llvm-nm/Opts.td
llvm/tools/llvm-nm/llvm-nm.cpp
Index: llvm/tools/llvm-nm/llvm-nm.cpp
===================================================================
--- llvm/tools/llvm-nm/llvm-nm.cpp
+++ llvm/tools/llvm-nm/llvm-nm.cpp
@@ -2470,6 +2470,11 @@
error("bad number of arguments (must be two arguments)",
"for the -s option");
+ // Everything after `--` on its own should be considered an input file.
+ if (opt::Arg *A = Args.getLastArgNoClaim(OPT_DASH_DASH))
+ InputFilenames.insert(InputFilenames.end(), A->getValues().begin(),
+ A->getValues().end());
+
if (InputFilenames.empty())
InputFilenames.push_back("a.out");
if (InputFilenames.size() > 1)
Index: llvm/tools/llvm-nm/Opts.td
===================================================================
--- llvm/tools/llvm-nm/Opts.td
+++ llvm/tools/llvm-nm/Opts.td
@@ -81,3 +81,5 @@
def : F<"v", "Alias for --numeric-sort">, Alias<numeric_sort>;
def : F<"V", "Alias for --version">, Alias<version>;
def : F<"W", "Alias for --no-weak">, Alias<no_weak>;
+
+def DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>;
Index: llvm/test/tools/llvm-nm/option--.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-nm/option--.test
@@ -0,0 +1,14 @@
+; RUN: not llvm-nm -- -weird-filename-that-doesnt-exist 2>&1 | FileCheck %s --check-prefix=CHECK-NOTOPT
+; CHECK-NOTOPT: error: -weird-filename-that-doesnt-exist: No such file or directory
+
+; RUN: mkdir -p %t && cd %t
+; RUN: llvm-as < %s > -.bc
+; RUN: llvm-nm -- -.bc | FileCheck %s
+
+; RUN: llvm-as < %s > --
+; RUN: llvm-nm -- -- | FileCheck %s
+
+; CHECK: foo
+define void @foo() {
+ ret void
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150568.525575.patch
Type: text/x-patch
Size: 1667 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230525/132160a6/attachment.bin>
More information about the llvm-commits
mailing list