[PATCH] D39539: [Support] Don't error out on multiple occurrances of an Optional flag

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 2 02:31:31 PDT 2017


mstorsjo created this revision.

This allows doing e.g. "llvm-nm -g -g", which binutils nm doesn't error out on, and which some projects' build systems can end up doing in some cases. Allowing that seems like a better target than trying to avoid user projects passing multiple -g parameters to $NM.

Not sure if this is the best way, or if these kinds of flags within llvm-nm should be updated to a different type instead?


https://reviews.llvm.org/D39539

Files:
  lib/Support/CommandLine.cpp
  test/tools/llvm-nm/X86/externalonly.test


Index: test/tools/llvm-nm/X86/externalonly.test
===================================================================
--- test/tools/llvm-nm/X86/externalonly.test
+++ test/tools/llvm-nm/X86/externalonly.test
@@ -1,4 +1,5 @@
 # RUN: llvm-nm -g %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s
+# RUN: llvm-nm -g -g %p/Inputs/hello.obj.macho-x86_64 | FileCheck %s
 
 # CHECK-NOT: EH_frame0
 # CHECK: _main
Index: lib/Support/CommandLine.cpp
===================================================================
--- lib/Support/CommandLine.cpp
+++ lib/Support/CommandLine.cpp
@@ -1358,8 +1358,6 @@
 
   switch (getNumOccurrencesFlag()) {
   case Optional:
-    if (NumOccurrences > 1)
-      return error("may only occur zero or one times!", ArgName);
     break;
   case Required:
     if (NumOccurrences > 1)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39539.121259.patch
Type: text/x-patch
Size: 803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171102/0f5470f1/attachment.bin>


More information about the llvm-commits mailing list