[cfe-dev] [libc++abi] Why is cxa_demangle.h a public header?
Howard Hinnant
hhinnant at apple.com
Sat Jun 8 16:21:07 PDT 2013
On Jun 8, 2013, at 7:10 PM, Howard Hinnant <hhinnant at apple.com> wrote:
> On Jun 8, 2013, at 6:28 PM, Matthew Dempsky <matthew at dempsky.org> wrote:
>
>> On Sat, Jun 8, 2013 at 8:02 AM, Howard Hinnant <hhinnant at apple.com> wrote:
>>> Because when I was first asked to write the demangler I was also asked to have it create a syntax tree and expose that syntax tree for use by the compiler and/or debugger.
>>>
>>> That design hasn't worked out. I'm currently working on an alternative. A tool for the compiler and/or debugger could still be done, but it makes more sense to have that be a separate tool, as opposed to bundling it into the demangler.
>>
>> Makes sense. Thanks for the explanation!
>>
>>> I'm hoping to get rid of this shortly.
>>
>> Do you have a timeline for this or any notes about your new plans? Is
>> it still worth sending patches against the current code?
>
> Days not weeks. I haven't looked at your patches yet, but they are registered on my to-do list which has gotten rather lengthy while I work on the demangler.
>
> The parsing code is staying approximately the same, modulo bug fixes and C++11 additions. Everything having to do with the syntax tree (everything derived from __node) is gone. Instead the parsing is generating a stack of pairs of strings. At parsing end the stack should be size 1, and the concatenation of the two strings in the pair is the demangled string.
>
> The pair exists to aid demangling references/pointers to functions/arrays. The functions/arrays demangle into a first part and second part, and pointers/references get inserted in between the two parts.
>
> Parameter packs demangle to a stack of string_pairs of length 0 or more.
>
> Substitutions are stored as a vector of stacks of string pairs. This is necessary to properly store a parameter pack as a substitution.
>
> Template parameters are stored as a stack of substitutions.
>
> What would help most right now is code examples which mangle names which the current demangler does not handle. For example I am currently creating a code example that will mangle an expression involving nullptr.
Got that one:
template <bool b>
struct X
{
X();
};
// _Z1fIiEDTeqfp_LDnEEPT_ -> decltype((fp) == (std::nullptr_t)) f<int>(int*)
template <class T>
auto
f(T* p) -> decltype(p == nullptr)
{
return p == nullptr;
}
void
test()
{
f<int>(nullptr);
}
Howard
More information about the cfe-dev
mailing list