<div dir="ltr">On Wed, Aug 28, 2013 at 11:13 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Aug 28, 2013, at 9:56 PM, David Majnemer <<a href="mailto:david.majnemer@gmail.com">david.majnemer@gmail.com</a>> wrote:<br>

> A little backstory:<br>
><br>
> I am working on improving the mangling non-type template arguments that bind pointers to members for the MS ABI and have hit on something rather unfortunate: mangling them is equivalent to mangling their offset in the record as a literal. The "obvious" thing to do would be to ask CodeGen what that constant offset would be, however that would be a layering violation because mangling happens in AST, not CodeGen.<br>

<br>
</div>Record layout is performed on the AST, and offsets of struct members can easily be recovered there, modulo the -1 vs. 0 difference for null member pointers.<br>
<div class="im"><br>
> I'd like to know if the layer that mangling happens in is a consequence of design, or a philosophical choice or some other necessity.<br>
<br>
</div>It was actually originally in IR-gen and got hoisted to AST because (1) it doesn’t rely on any “deep” IR-gen data structures and (2) people asked for it to be thusly hoisted.  I don’t see any reason to return it to IR-gen.<br>

<div class="im"><br>
> Answering this question would tell me if we could move mangling out or AST and into CodeGen or if I should instead move the member pointer layout calculation to MicrosoftCXXABI.cpp<br>
<br>
</div>If you need proper member pointer layout in the AST, I have no issue with recording member pointer layout there.  Almost every reason that justifies struct layout being in the AST applies equally to member pointer layout, at least once you’ve settled that the MS dialect really is a separate universe from the language-as-standardized.<br>

<span class="HOEnZb"><font color="#888888"><br>
John.</font></span></blockquote></div><br></div><div class="gmail_extra">Thanks for the clarification! For the record, I need the real deal layout as they produce manglings that are sensitive to vbtable/vftable distinctions.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">-- </div><div class="gmail_extra">David Majnemer</div></div>