Giter VIP home page Giter VIP logo

Comments (5)

rocallahan avatar rocallahan commented on July 20, 2024

I suspect the same problem could occur with function parameter references, though an example would have to be very complicated.

from cxx-abi.

zygoloid avatar zygoloid commented on July 20, 2024

The original mangled name is invalid. The right way to refer to Rangitoto in the substitution would be S1_, not S2_, which is what compilers produce for examples that mangle that way, and the modified mangling is demangled the same way by libstdc++'s demangler and libc++abi's demangler.

We can reach cases that demonstrate the problem in question with an example like this:

template<typename T> void ignore(T*);
struct Rangitoto {};
struct Foobar {};
template<typename T, void(*)(Foobar*)> void hello(T*) {}
template void hello<Rangitoto, ignore<Foobar> >(Rangitoto*);

Everyone mangles this as _Z5helloI9RangitotoXadL_Z6ignoreI6FoobarEvPT_EEEvS4_. However, libstdc++ demangles that to the source declaration, libc++abi demangles it to a function taking Foobar* instead.

In summary, Clang, GCC, ICC, and the libstdc++ demangler all agree that when a S<n>_ refers to a T<n>_, the T<n>_ is interpreted in the context where the S<n>_ appears, not in its original context; only the libc++abi demangler disagrees. Presumably that is the rule we should use, then. However, see the problem under discussion in #106, which points out that this kind of situation is hard to demangle in general.

from cxx-abi.

rocallahan avatar rocallahan commented on July 20, 2024

In summary, Clang, GCC, ICC, and the libstdc++ demangler all agree that when a S<n>_ refers to a T<n>_, the T<n>_ is interpreted in the context where the S_ appears, not in its original context; .. Presumably that is the rule we should use

That's great news. I hope you're able to update the spec text to clarify that.

from cxx-abi.

rocallahan avatar rocallahan commented on July 20, 2024

For the record, the real-life issue that triggered this bug report was:
gimli-rs/cpp_demangle#165 (comment)
In particular this symbol was generated by (some circa-2018 version of) clang++:

_ZN7mozilla6detail12ListenerImplINS_14AbstractThreadEZNS_20MediaEventSourceImplILNS_14ListenerPolicyE0EJNS_13TimedMetadataEEE15ConnectInternalIS2_NS_12MediaDecoderEMS8_FvOS5_EEENS_8EnableIfIXsr8TakeArgsIT1_EE5valueENS_18MediaEventListenerEE4TypeEPT_PT0_SD_EUlS9_E_JS5_EE17ApplyWithArgsImplISL_EENSC_IXsr8TakeArgsISH_EE5valueEvE4TypeERKSH_S9_

llvm-cxxfilt 11.0 demangles it to

mozilla::EnableIf<TakeArgs<mozilla::AbstractThread>::value, void>::Type mozilla::detail::ListenerImpl<mozilla::AbstractThread, mozilla::EnableIf<TakeArgs<void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&)>::value, mozilla::MediaEventListener>::Type mozilla::MediaEventSourceImpl<(mozilla::ListenerPolicy)0, mozilla::TimedMetadata>::ConnectInternal<mozilla::AbstractThread, mozilla::MediaDecoder, void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&)>(mozilla::AbstractThread*, mozilla::MediaDecoder*, void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&))::'lambda'(mozilla::TimedMetadata&&), mozilla::TimedMetadata>::ApplyWithArgsImpl<mozilla::EnableIf<TakeArgs<void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&)>::value, mozilla::MediaEventListener>::Type mozilla::MediaEventSourceImpl<(mozilla::ListenerPolicy)0, mozilla::TimedMetadata>::ConnectInternal<mozilla::AbstractThread, mozilla::MediaDecoder, void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&)>(mozilla::AbstractThread*, mozilla::MediaDecoder*, void (mozilla::MediaDecoder::*)(mozilla::TimedMetadata&&))::'lambda'(mozilla::TimedMetadata&&)>(mozilla::AbstractThread const&, mozilla::TimedMetadata&&)

while c++filt 2.35 fails to demangle it.

Perhaps that version of clang++ mangled the symbol incorrectly. I would have tried to come up with a minimal C++ testcase but I'm not adept at taking a symbol like that and reverse-engineering some minimal C++ code that produces it...

from cxx-abi.

rocallahan avatar rocallahan commented on July 20, 2024

libc++abi demangles it to a function taking Foobar* instead.

I hope someone fixes this. Once that's fixed, it'll be interesting to see if that changes llvm-cxxfilt's demangling of the Mozilla symbol above.

from cxx-abi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.