[cfe-commits] [patch] CXXABI getter/setter

Sean Silva silvas at purdue.edu
Sun Aug 19 16:14:47 PDT 2012


> By the way, is there any reason ABI dependent stuff could not be abstracted
> from the actual AST? It just feels wasteful to have to parse code twice to
> get layout and mangling information.

Consider:

char arr[sizeof(class Foo) == sizeof_foo_with_itanium_ABI ? 1 : -1 ];

or

struct what_size_am_i {
char arr[sizeof(class Foo) == sizeof_foo_with_itanium_ABI ? 5 : 10 ];
};

So to get back to your original question of

> By the way, is there any reason ABI dependent stuff could not be abstracted
> from the actual AST?

There is a good reason, and that is that struct layout (and mangling
too, considering templates) can be made to depend on the ABI in
arbitrarily complicated ways.

--Sean Silva

On Sun, Aug 19, 2012 at 6:50 PM, João Matos <ripzonetriton at gmail.com> wrote:
> I am creating my own mangler instance. The problem is that it takes an AST
> context, which has it's own CXXABI object, and it can't be changed.
>
> And you are right, it's probably not correct under all the circumstances,
> I'll change my code to make an AST for each different ABI. I had not
> remembered about template parameters, that is a good reason.
>
> By the way, is there any reason ABI dependent stuff could not be abstracted
> from the actual AST? It just feels wasteful to have to parse code twice to
> get layout and mangling information.
>
> On Sun, Aug 19, 2012 at 10:41 PM, John McCall <rjmccall at apple.com> wrote:
>>
>> On Aug 19, 2012, at 2:55 AM, João Matos wrote:
>> > Well, my use case is for doing name mangling correctly with the MS and
>> > Itanium manglers.
>>
>> You want to take an existing AST and apply both MS and Itanium manglings
>> to it,
>> regardless of which ABI it was parsed under?  I think the correct approach
>> is to
>> explicitly create your own mangler instance, rather than relying on the
>> information
>> from the ASTContext to make one.
>>
>> Whether this is actually sensible depends on what you're really trying to
>> do.
>> Sean's point that the ABI can substantially affect the AST isn't just
>> notional —
>> most of the time, things like sizes aren't mangled, but if they're used as
>> a
>> template argument they certainly will be.
>>
>> John.
>
>
>
>
> --
> João Matos




More information about the cfe-commits mailing list