[PATCH] D124010: [llvm-cxxfilt] Unable to demangle a template argument which happens to be a null pointer

Nathan Sidwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 05:59:21 PDT 2022


urnathan requested changes to this revision.
urnathan added a comment.
This revision now requires changes to proceed.

You need to modify libcxxabi/src/demangle/ItaniumDemangle.h and deploy the cp-to-llvm.sh script therein.



================
Comment at: llvm/include/llvm/Demangle/ItaniumDemangle.h:4357-4360
+    // A template argument which happens to be a null pointer is mangled as if
+    // it were a literal 0 of the appropriate pointer type.
+    if (consumeIf("Dn0E"))
+      return make<EnumLiteral>(make<NameType>("std::nullptr_t"), "0");
----------------
Why demangle this differently to just 'nullptr'?  I notice GNU's demangler does that:
```
zathras:11>c++filt _Z1fIDnLDn0EEvv
void f<decltype(nullptr), (decltype(nullptr))0>()
```
It would seem 
```
if (consumeIf("Dn") && (consumeIf ('0'), consumeIf ('E'))
  return make<NameType>("nullptr");
return nullptr;
```
would suffice?


================
Comment at: llvm/test/tools/llvm-cxxfilt/null-pointer-template-arg.test:1-12
+# As stated in the Itanium C++ ABI mangling section:A template argument
+# which happens to be a null pointer is mangled as if it were a literal
+# 0 of the appropriate pointer type; for example, "LPi0E" or "LDn0E".
+
+# RUN: llvm-cxxfilt _Z1fIDnLDnEEvv | FileCheck %s --check-prefix=NULLPTR
+# NULLPTR: void f<std::nullptr_t, nullptr>()
+
----------------
demangler tests are in libcxxabi/test/test_demangle.pass.cpp you'll see there's a massive array of tuples.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124010/new/

https://reviews.llvm.org/D124010



More information about the llvm-commits mailing list