Issue 58197
Summary [libcxxabi] Possibly incorrectly mangled name with conditional templates
Labels libc++abi
Assignees
Reporter Michael137
    Found by @var-const when investigating why LLDB fails demangle certain symbols.

Tried on llvm.org top-of-tree as of `9abeb0cbd983c7e32a729e333b033673546e5485` on MacOS

```
namespace std {                                                      
namespace ranges {                                               
                                                                 
template <bool>                                                  
struct IfImpl {                                                  
    template <class IfRes>                                       
    using Select = IfRes;                                        
};                                                               
                                                                 
template <bool Cond, class IfRes>                                
using If = typename IfImpl<Cond>::template Select<IfRes>;        
                                                                 
template <class>                                                 
concept AlwaysTrue = true;                                       
                                                                 
template <class T>                                               
using conditional_template = If<AlwaysTrue<T>, int*>;            
                                                                 
template<typename T>                                             
struct True {                                                    
    static const bool value = true;                              
};                                                               
                                                                 
template <class T>                                               
using conditional_template_no_concept = If<True<T>::value, int*>;
                                                                 
}  // namespace ranges                                           
                                                                 
template <class T>                                               
std::ranges::conditional_template<T> k() {                       
    return {};                                                   
}           
} // namespace std

int main() {
    std::k<int>();
}
```

With Clang the DWARF linkage name for this is:
`_ZSt1kISt3FooENSt6ranges6IfImplIL_ZNS1_10AlwaysTrueIT_EEEE6SelectIPiEEv`, which `c++filt` isn't able to demangle.

GCC on the other hand detangles this into `_ZSt1kIiENSt6ranges6IfImplIX10AlwaysTrueIT_EEE6SelectIPiEEv`.

```
$ c++filt -n _ZSt1kIiENSt6ranges6IfImplIX10AlwaysTrueIT_EEE6SelectIPiEEv
std::ranges::IfImpl<AlwaysTrue<int> >::Select<int*> std::k<int>()

$ c++filt -n _ZSt1kISt3FooENSt6ranges6IfImplIXL_ZNS1_10AlwaysTrueIT_EEEEE6SelectIPiEEv
_ZSt1kISt3FooENSt6ranges6IfImplIXL_ZNS1_10AlwaysTrueIT_EEEEE6SelectIPiEEv
```

Any idea what the issue here might be?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to