[cxx-abi-dev] mangling for fold-expressions
Richard Smith
richardsmith at google.com
Mon Nov 10 18:54:13 UTC 2014
On 10 November 2014 09:11, Jason Merrill <jason at redhat.com> wrote:
> On 11/08/2014 12:16 PM, Richard Smith wrote:
>
>> <expression> ::=
>> fl <binary operator-name> <expression> # ( ... op pack )
>> fr <binary operator-name> <expression> # ( pack op ... )
>> fx <binary operator-name> <expression> <expression> # ( expr op ...
>> op
>> expr )
>>
>
> Do we really need mangling for the third case? I was thinking it would
> reduce to one of the others plus a normal binary operation.
The extra element is always the innermost element, so it's not equivalent
to a normal binary operator combined with one of the other forms. For
instance:
(1 / ... / divisors)
expands to
((1 / d1) / ...) / dn
There is no way to get the same result with (... / divisors).
And as an extreme case,
template<int> struct X {};
template<int ...N> using Foldr = X<(N + ...)>;
template<int ...A> struct Partial {
template<int ...B> void foldr(Foldr<A..., B..., A..., B...>);
};
template void Partial<1,2>::foldr<3,4>(X<20>);
would mangle as
_ZN7PartialIJLi1ELi2EEE5foldrIJLi3ELi4EEEEv1XIXplLi1EplLi2EfxplT_plLi1EplLi2EfrplT_EE
Note that Foldr<A..., B..., A..., B...> becomes X<(A + ... + (B + ... + (A
+ ... + (B + ...))))> (the unary form turns into the binary form after a
partial substitution).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20141110/a14d114c/attachment.html>
More information about the cxx-abi-dev
mailing list