GNU nm has --no-demangle, so llvm-nm should too. It disables the --demangle switch. The patch also allows --demangle to be specified multiple times (the last of all --no-demangle/--demangle switches takes precedence).
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
tools/llvm-nm/llvm-nm.cpp | ||
---|---|---|
2083 | Can you add a test case that ensures getPosition() returns the last occurrence? |
Seems llvm-nm is inconsistent.
- -no-dyldinfo can't be used with -add-dyldinfo/-dyldinfo-only
- -no-sort always overrides all other kinds of sorts.
And this patch implements the correct behavior of the normal option the first time it seems.
tools/llvm-nm/llvm-nm.cpp | ||
---|---|---|
2085 | I am not sure this piece of code should be right here. It is placed before the llvm::InitializeAll* calls, what is a bit too far from where the other values (like OutputFormat) |
We spoke too soon. Updating the test as @rupprecht suggested highlighted an issue where the switches cannot appear multiple times on the command-line. There's no good reason why they shouldn't (aside from tidiness), and I have encountered build systems and scripts where appending options to an existing command-line is about the only choice available, even if it means duplicate options, so we should allow multiple occurrences. I'll update the patch accordingly.
Address review comments:
- Update test
- Add cl::ZeroOrMore to switches
- Move logic a bit later
Given the issue I ran into, could I get this reviewed again before submitting, please.
LGTM, comment inline.
test/tools/llvm-nm/X86/demangle.ll | ||
---|---|---|
23 | It feels to me a bit excessive to test all possible combination with aliases. ; RUN: llvm-nm --demangle --no-demangle %t.o | FileCheck --check-prefix="MANGLED" %s ; RUN: llvm-nm --no-demangle --demangle %t.o | FileCheck --check-prefix="DEMANGLED" %s ; RUN: llvm-nm --no-demangle --demangle --no-demangle %t.o | FileCheck --check-prefix="MANGLED" %s ; RUN: llvm-nm --demangle --no-demangle --demangle %t.o | FileCheck --check-prefix="DEMANGLED" %s Otherwise, we might end up with a crazy amount of lines in the tests. |
Oh, that's weird. Why isn't that the default?
Not necessarily just for this reason, but it would fix it -- we should probably switch the tools to use liboption, which was discussed on the mailing list some time last year. Anyway, what was submitted lgtm.
It feels to me a bit excessive to test all possible combination with aliases.
I think lines 4 and 5 of this test are used to demonstrate that -C and --demangle are equal.
(and the testing of cl::opt vs cl::alias interaction is done in llvm\unittests\Support\CommandLineTest.cpp already).
So I would not do it. And do just:
Otherwise, we might end up with a crazy amount of lines in the tests.
Up to you probably.