CGRecordLayoutBuilder for Microsoft layout.

Hi!

I attached a patch with the implementation of CGRecordLayoutBuilder, which is building layout like MSVC.
Also patch includes bug fix for RecordLayoutBuilder.

Could somebody review this patch?

  - Dmitry.

ms_code_gen.patch (13.6 KB)

Would you mind rebasing on top of r142325? I got a bit carried away
while I was reviewing your patch.

-Eli

Here is a new patch with some fixes.

  - Dmitry.

Sorry, I forgot attach a patch.

  - Dmitry.

ms_codegen.patch (14.5 KB)

ping... What about my patch?

  - Dmitry.

Applied some more changes to ASTRecordLayout based on your changes,
and added tests for the current CodeGen types.

As for the CodeGen bits, they look more complicated than they should
be; as far as I can tell, the current CodeGen bits are doing the right
thing right now, ignoring the fact that they put padding where the
vfptr and the vbptr should be. Adding those should be a trivial
patch. Is there something I'm missing?

-Eli

As for the CodeGen bits, they look more complicated than they should
be;

You add vfptroffset it will be very helpful, I'll try to make my code simpler.

  as far as I can tell, the current CodeGen bits are doing the right
thing right now,

Not quite, for example (class D & G from test code)
struct H : public G,
            public virtual D
{
     virtual ~H(){}
};
code in svn will built
     0 | struct H
     0 | struct G (base)
     0 | int g_field
     4 | (H vftable pointer)
     8 | (H vbtable pointer)
   16 | class D (virtual base)
   16 | (D vftable pointer)
   24 | double a
%struct.H = type { %struct.G, [12 x i8], %class.D }

but right layout is
     0 | struct H
     0 | (H vtable pointer)
     8 | (H vbtable pointer)
     4 | struct G (base)
     4 | int g_field
   16 | class D (virtual base)
   16 | (D vtable pointer)
   24 | double a
%struct.H = type { i32 (...)**, %struct.G, i32*, [4 x i8], %class.D } or
%struct.H = type { [4 x i8], %struct.G, [8 x i8], %class.D }

So all complicated code needs only for microsoft "madness" like this.
About example, I'll fix it in few days and publish patch.

  - Dmitry.

This patch fixes the bug.

  - Dmitry.

ms-layout.patch (3.05 KB)