[llvm] r351481 - [demangler] Ignore leading underscores if present

Duncan Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 23 12:48:20 PST 2019


+John and Nick

I'm not sure this is the right thing to do.

I believe there was an intentional decision way back when (before my time) to require clients to strip the leading underscore.  c++filt on my desktop does this (passing `-_` by default, which means symbols without the leading underscore don't get demangled).

Nick and John, do you have any recollection of why the demangler was restrictive like this?  Any thoughts on whether it's problematic to relax it?

> On 2019 Jan  17, at 13:37, Erik Pilkington via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> Author: epilk
> Date: Thu Jan 17 13:37:36 2019
> New Revision: 351481
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=351481&view=rev
> Log:
> [demangler] Ignore leading underscores if present
> 
> On MacOS, symbols start with a leading underscore, so just parse and
> ignore it if present.
> 
> Modified:
>    llvm/trunk/include/llvm/Demangle/ItaniumDemangle.h
> 
> Modified: llvm/trunk/include/llvm/Demangle/ItaniumDemangle.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Demangle/ItaniumDemangle.h?rev=351481&r1=351480&r2=351481&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Demangle/ItaniumDemangle.h (original)
> +++ llvm/trunk/include/llvm/Demangle/ItaniumDemangle.h Thu Jan 17 13:37:36 2019
> @@ -5143,7 +5143,7 @@ AbstractManglingParser<Derived, Alloc>::
> // extension      ::= ___Z <encoding> _block_invoke_<decimal-digit>+
> template <typename Derived, typename Alloc>
> Node *AbstractManglingParser<Derived, Alloc>::parse() {
> -  if (consumeIf("_Z")) {
> +  if (consumeIf("_Z") || consumeIf("__Z")) {
>     Node *Encoding = getDerived().parseEncoding();
>     if (Encoding == nullptr)
>       return nullptr;
> @@ -5156,7 +5156,7 @@ Node *AbstractManglingParser<Derived, Al
>     return Encoding;
>   }
> 
> -  if (consumeIf("___Z")) {
> +  if (consumeIf("___Z") || consumeIf("____Z")) {
>     Node *Encoding = getDerived().parseEncoding();
>     if (Encoding == nullptr || !consumeIf("_block_invoke"))
>       return nullptr;
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list