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

Owen Reynolds via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 09:43:19 PDT 2022


gbreynoo added a comment.

I now see what you mean @dblaikie . I believe the mangling is functioning correctly and it's output matches GCC, it is the demangling that is the issue. By following @urnathan's code suggestion the demangled output will differ but I don't think this should be a problem as they are equivalent?



================
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");
----------------
dblaikie wrote:
> gbreynoo wrote:
> > urnathan wrote:
> > > 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?
> > This would output nullptr rather than decltype(nullptr) or nullptr_t. Looking at the spec "a template argument which happens to be a null pointer should mangled as if it were a literal 0 of the appropriate pointer type" which in the case of LDn0E is nullptr_t.
> I think @urnathan is intending to suggest that what this patch currently produces "(decltype(nullptr))0" instead we could/should produce "nullptr". This seems like it would be valid, yeah? 
Hi @dblaikie, I misunderstood the issue. I believe you are both correct and will update the patch appropriately. 


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