]> granicus.if.org Git - llvm/commitdiff
Update llvm-nm -s to use a multi-var option
authorMichael Trent <mtrent@apple.com>
Sat, 18 May 2019 03:17:27 +0000 (03:17 +0000)
committerMichael Trent <mtrent@apple.com>
Sat, 18 May 2019 03:17:27 +0000 (03:17 +0000)
Summary:
Previously llvm-nm relied on a positional parameter to read two values
into the SegSect list. This worked, but required the "-s" paramater and
its arguments to be the last elements on the command-line.

The CommandLine library now supports mutli-var parameters, so it can
naturally deal with "-s" expecting two arguments, and now the input file
can appear anywhere (within reason) in the command line invocation. E.g.

    llvm-nm -s __TEXT __text /bin/ls
    llvm-nm /bin/ls -s __TEXT __text

rdar://27284011

Reviewers: lhames, pete

Reviewed By: pete

Subscribers: rupprecht, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D62070

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

tools/llvm-nm/llvm-nm.cpp

index f427f3764972995ad43ca8ecdebeb0106b1aa668..f21978d50cc12d855d957ba46a5fdcb235d85bb1 100644 (file)
@@ -183,12 +183,7 @@ cl::alias JustSymbolNames("j", cl::desc("Alias for --just-symbol-name"),
 cl::opt<bool> SpecialSyms("special-syms",
                           cl::desc("No-op. Used for GNU compatibility only"));
 
-// FIXME: This option takes exactly two strings and should be allowed anywhere
-// on the command line.  Such that "llvm-nm -s __TEXT __text foo.o" would work.
-// But that does not as the CommandLine Library does not have a way to make
-// this work.  For now the "-s __TEXT __text" has to be last on the command
-// line.
-cl::list<std::string> SegSect("s", cl::Positional, cl::ZeroOrMore,
+cl::list<std::string> SegSect("s", cl::multi_val(2), cl::ZeroOrMore,
                               cl::value_desc("segment section"), cl::Hidden,
                               cl::desc("Dump only symbols from this segment "
                                        "and section name, Mach-O only"),