[PATCH] [ms-cxxabi] Correctly compute the size of member pointers

Will Wilson will at indefiant.com
Thu Mar 21 16:22:09 PDT 2013


Oddly enough I've been working on this exact area myself over the last few
days. I could be overlooking something but it appears to be missing support
for the X64 ABI (ie. amd64-pc-win32) which would be a shame not to
support. I've previously spent some time analyzing it and came up with the
following member function pointer sizes:

   - Single inheritance: 1 x sizeof(void*)
   - Multiple inheritance: 2 x sizeof(void*)
   - Virtual inheritance:
      - 32-bit: 3 x sizeof(void*)
      - 64-bit: 2 x sizeof(void*)
   - Unknown inheritance:
      - 32-bit: 4 x sizeof(void*)
      - 64-bit: 3 x sizeof(void*)

As you can see there's a couple of differences based on the architecture
but their pretty minor.

The inheritance keywords should be definitive for the rest of the TU. MSVC
will issue an error should the class definition not match the assigned
inheritance keyword - this is a useful sanity check and probably worth
implementing. The error in question is C2286 and is outlined here:
http://msdn.microsoft.com/en-gb/library/9z8tbhb2.aspx

In addition, MSVC has a nasty corner case. If a member function pointer
is instantiated based on an (as yet) undefined class the class is assigned
the unknown inheritance for the rest of the translation unit - even if the
class is defined later in the TU. I've been wondering how best to model
this persistant state and the only approach I could come up with was to
assign a (currently unimplemented) UnknownInheritanceAttr during sema - but
it's not pretty.

Lastly, I haven't had a chance to revisit it, but MSVC seems to do weird
things with member function pointer alignment. I know this isn't specific
to this patch but I thought I'd mention it. Hopefully I'll get the chance
to research it soon and get to the bottom of the implementation.

- Will


On 21 March 2013 22:56, João Matos <triton at vapor3d.org> wrote:

>
>   Patch looks good to me. Hope this is finally fixed :)
>
> http://llvm-reviews.chandlerc.com/D568
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



-- 
*Indefiant Ltd.*
*
*
Firsby Lodge, New Main Road, Scamblesby, Louth, Lincs LN11 9XH UK
*Tel: +44 20 8123 7663 England Registered No. 07936820 VAT No. **128556202*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130322/7213af3f/attachment.html>


More information about the cfe-commits mailing list