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 ↗ | (On Diff #193307) | 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 ↗ | (On Diff #193307) | 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) |
Thanks. I took the behaviour from --no-demangle in llvm-symbolizer, so I can't exactly take all the credit!
tools/llvm-nm/llvm-nm.cpp | ||
---|---|---|
2083 ↗ | (On Diff #193307) | Sounds good. |
2085 ↗ | (On Diff #193307) | Thanks. I placed it here, because the equivalent code in llvm-symbolizer is at this location. I can move it though. |
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 ↗ | (On Diff #193466) | 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.