<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/109130>109130</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Demangler does not demangle a valid name produced by clang compiler
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ioannco
      </td>
    </tr>
</table>

<pre>
    # Issue description

LLVM demangler fails to decode Itanium mangled name 

`_ZN3foocvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEv` 
which encodes 
`foo::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>()`
while other demanglers (i.e `c++filt`) do not fail. 

## How to reproduce

`example.cpp`:
```cpp
#include <iostream>

class foo {
public:
  operator std::string() {return {};};
};

int main() {
  (std::string) foo();
};
```

```shell
$ clang++ example.cpp -o example
$ llvm-nm example | llvm-cxxfilt example
```

output:
```
0000000000003dc0 d _DYNAMIC
0000000000004000 d _GLOBAL_OFFSET_TABLE_
00000000000010b0 t _GLOBAL__sub_I_example.cpp
0000000000002000 R _IO_stdin_used
 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
00000000000011e0 W _ZN3foocvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEv
 U std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()@GLIBCXX_3.4.21
                 U std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()@GLIBCXX_3.4.21
                 U std::ios_base::Init::Init()@GLIBCXX_3.4
                 U std::ios_base::Init::~Init()@GLIBCXX_3.4
0000000000004049 b std::__ioinit
0000000000002138 r __FRAME_END__
0000000000002004 r __GNU_EH_FRAME_HDR
0000000000004048 D __TMC_END__
000000000000037c r __abi_tag
0000000000004048 B __bss_start
                 U __cxa_atexit@GLIBC_2.2.5
                 w __cxa_finalize@GLIBC_2.2.5
0000000000001080 t __cxx_global_var_init
0000000000004038 D __data_start
0000000000001160 t __do_global_dtors_aux
0000000000003db8 d __do_global_dtors_aux_fini_array_entry
0000000000004040 D __dso_handle
0000000000003da8 d __frame_dummy_init_array_entry
 w __gmon_start__
                 U __libc_start_main@GLIBC_2.34
0000000000004048 D _edata
0000000000004050 B _end
000000000000120c T _fini
0000000000001000 T _init
00000000000010c0 T _start
0000000000004048 b completed.0
0000000000004038 W data_start
00000000000010f0 t deregister_tm_clones
00000000000011a0 t frame_dummy
00000000000011b0 T main
0000000000001120 t register_tm_clones
```

demangle of line 
`00000000000011e0 W _ZN3foocvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEv`
has failed.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEV0tv27oS_jX0ZlCDouTXwgs_WwNJCjTube_dEBRJ2bygRIOkUucs-tsPqEcsx3IX5xTnBIYiiTPfzHwzGg6Zc-pQSDlHoyUarQes9Edj58qwouBmkBrxOkckhp1zpQQhHbfq5JUpEF4jvKivDw__eQQhc1YctLSQMaUdeANCciMk7DwrVJlDvS6gYLmErj4aY_q_pzgzhr88PfsJpfx8jqKIpMwpTp23qjjs-LOPIn5klnrLlHc7vnlmO77ZbDYvaIwbxB9HxY8gi2DZwRt-ZgyKFyhemJO0zBsLzov6TWOtfuhaRPEqmENkdRHu2G-X482VBNPa8GChsx5EpojM0Bi_eaklGH-U9kKcA0SmaigBjTFHZInIMlPaByUyA2GgML4id3jNHolDhj6ZH4FzK0_WiJLLdwTLM8tPWg756RQA48tK_QvvWzhVcF0KCSheKeO8lSwPIXQAuWbOQWYMoMmyfnUqU634GzDALdMNrRUVQdFKX9qigpisUdxeazvd--qqCg85U8VFv7WEyPTGxix417Dei9kG_o6n-ueOUuuWjwS4ZgEzZAQ6RMIH0z5eZLV-yT8UebsAaLKq3_HzOaTznUafG6b0p9Lf5qh-xJ2_WHAMAuj6v0-Lx93qViDBu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