[cfe-dev] CGRecordLayoutBuilder for Microsoft layout.

r4start r4start at gmail.com
Sat Oct 22 12:43:38 PDT 2011


On 22/10/2011 03:12, Eli Friedman wrote:
> 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.



More information about the cfe-dev mailing list