Thanks for the explanation, makes total sense.<div><br></div><div>I'll just update my code to parse code for each ABI.<br><div><br><div class="gmail_quote">On Mon, Aug 20, 2012 at 12:14 AM, Sean Silva <span dir="ltr"><<a href="mailto:silvas@purdue.edu" target="_blank">silvas@purdue.edu</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">> By the way, is there any reason ABI dependent stuff could not be abstracted<br>
> from the actual AST? It just feels wasteful to have to parse code twice to<br>
> get layout and mangling information.<br>
<br>
</div>Consider:<br>
<br>
char arr[sizeof(class Foo) == sizeof_foo_with_itanium_ABI ? 1 : -1 ];<br>
<br>
or<br>
<br>
struct what_size_am_i {<br>
char arr[sizeof(class Foo) == sizeof_foo_with_itanium_ABI ? 5 : 10 ];<br>
};<br>
<br>
So to get back to your original question of<br>
<div class="im"><br>
> By the way, is there any reason ABI dependent stuff could not be abstracted<br>
> from the actual AST?<br>
<br>
</div>There is a good reason, and that is that struct layout (and mangling<br>
too, considering templates) can be made to depend on the ABI in<br>
arbitrarily complicated ways.<br>
<span class="HOEnZb"><font color="#888888"><br>
--Sean Silva<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Sun, Aug 19, 2012 at 6:50 PM, Joćo Matos <<a href="mailto:ripzonetriton@gmail.com">ripzonetriton@gmail.com</a>> wrote:<br>
> I am creating my own mangler instance. The problem is that it takes an AST<br>
> context, which has it's own CXXABI object, and it can't be changed.<br>
><br>
> And you are right, it's probably not correct under all the circumstances,<br>
> I'll change my code to make an AST for each different ABI. I had not<br>
> remembered about template parameters, that is a good reason.<br>
><br>
> By the way, is there any reason ABI dependent stuff could not be abstracted<br>
> from the actual AST? It just feels wasteful to have to parse code twice to<br>
> get layout and mangling information.<br>
><br>
> On Sun, Aug 19, 2012 at 10:41 PM, John McCall <<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>> wrote:<br>
>><br>
>> On Aug 19, 2012, at 2:55 AM, Joćo Matos wrote:<br>
>> > Well, my use case is for doing name mangling correctly with the MS and<br>
>> > Itanium manglers.<br>
>><br>
>> You want to take an existing AST and apply both MS and Itanium manglings<br>
>> to it,<br>
>> regardless of which ABI it was parsed under?  I think the correct approach<br>
>> is to<br>
>> explicitly create your own mangler instance, rather than relying on the<br>
>> information<br>
>> from the ASTContext to make one.<br>
>><br>
>> Whether this is actually sensible depends on what you're really trying to<br>
>> do.<br>
>> Sean's point that the ABI can substantially affect the AST isn't just<br>
>> notional —<br>
>> most of the time, things like sizes aren't mangled, but if they're used as<br>
>> a<br>
>> template argument they certainly will be.<br>
>><br>
>> John.<br>
><br>
><br>
><br>
><br>
> --<br>
> Joćo Matos<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Joćo Matos<br>
</div></div>