[llvm] [llvm-cxxfilt] Add --quote option to quote demangled function names (PR #111871)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 11 00:52:20 PDT 2024


================
@@ -0,0 +1,12 @@
+// Show that llvm-cxxfilt --quote can emit quoted demangled symbols but not
+// without double-quoting in the case they are already quoted
+
+RUN: llvm-cxxfilt --quote < %s | FileCheck %s
+      cir.call @_ZN3aie4tileILi1ELi4EE7programIZ4mainE3$_0EEvOT_(%2, %7) : (!cir.ptr<!ty_aie3A3Atile3C12C_43E>, !cir.ptr<!ty_anon2E0_>) -> () loc(#loc74)
----------------
jh7370 wrote:

It looks to me like this test is overly complicated for what actually needs testing. If I understand it correctly, an input of something like the following would be sufficient to test the case with and without a quote:
```
_Z3barv "_Z3barv"
```
which I believe would turn into:
```
"bar()" "bar()"
```
(or if there was a bug, it might become `"bar()" ""bar()"", for example)

I'd also add two additional test cases:
1) A case that doesn't result in demangling (to show that only successfully demangled names are quoted)
2) A case that shows the behaviour if --quote is specified with the mangled name as one of the command-line arguments (e.g. `llvm-cxxfilt --quote _Z3barv`). I don't think quotes can appear in mangled names, so I don't think we need to show the "no double-quoting" behaviour in this case.
3) A case that exercises the behaviour when an "import thunk for" prefix is added. Aside: I wonder if this case should be always quoted with `--quote`?

Finally, it may make the test cleaner to not use `< %s` and instead redirect the stdin cases from a separate file, possibly created via `split-file`. This would prevent things like the RUN and CHECK lines themselves from being fed into llvm-cxxfilt. This would also allow you to add `--match-full-lines` or similar, to make sure there's no unexpected quotes being added, since `CHECK: bar()` doesn't prevent quotes from existing.

https://github.com/llvm/llvm-project/pull/111871


More information about the llvm-commits mailing list