<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div><span>Sure, I started a previous thread about this:</span></div><div><span><br></span></div><div><span><a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-September/016941.html">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-September/016941.html</a><br></span></div><div><a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-September/016942.html">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-September/016942.html</a><br></div><div><a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-September/016944.html">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-September/016944.html</a><br></div><div><a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-September/016970.html">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-September/016970.html</a><br></div><div><br></div><div>It boils down to two problems I've
 had:</div><div><br></div><div>* If there is a double anywhere in a struct, MSVC pads the vftbl pointer.</div><div>* The <span class="Apple-style-span" style="font-family: monospace; white-space: pre; font-size: 16px; ">IsPODForThePurposeOfLayout</span> check is invalid for MS targets and so you get a different layout depending upon whether your type has a struct or not.</div><div><br></div><div>I suggested a simple patch in my last post that fixes these. My test cases so far are here:</div><div><br></div><div><a href="https://bitbucket.org/dwilliamson/clreflect/src/tip/src/clReflectTest/TestOffsets.cpp">https://bitbucket.org/dwilliamson/clreflect/src/tip/src/clReflectTest/TestOffsets.cpp</a><br></div><div><br></div><div>my patch works for all of them but unfortunately I haven't had time to sync to the lastest build of clang so I'm not in a position to submit a patch.</div><div><br></div><div>It would be nice if we could figure something out
 that solves the biggest number of cases :)</div><div><br></div><div>Cheers,</div><div>- Don</div><div><br></div><div style="font-size: 10pt; font-family: arial, helvetica, sans-serif; "><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><font size="2" face="Arial"><hr size="1"><b><span style="font-weight:bold;">From:</span></b> r4start <r4start@gmail.com><br><b><span style="font-weight: bold;">To:</span></b> Don Williamson <don.williamson@yahoo.com><br><b><span style="font-weight: bold;">Cc:</span></b> cfe-dev@cs.uiuc.edu<br><b><span style="font-weight: bold;">Sent:</span></b> Thursday, September 15, 2011 12:06 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [cfe-dev] Implementation of MSRecordLayoutBuilder.<br></font><br><meta http-equiv="x-dns-prefetch-control" content="off"><div id="yiv787442229">
  

    
  
  
    On 15/09/2011 14:52, Don Williamson wrote:
    <blockquote type="cite">
      <div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-size: 10pt; font-family: arial, helvetica, sans-serif; ">
        <div><span>Hi Dmitry,</span></div>
        <div><span><br>
          </span></div>
        <div><span>I'm really interested in the original test cases you
            have that failed with the original implementation of the
            record layout builder - could you share them?</span></div>
        <div><span><br>
          </span></div>
        <div><span>How does your current patch work with the following
            test:</span></div>
        <div><span><br>
          </span></div>
        <div><span>#pragma pack(push, 8)</span></div>
        <div><span>class B {</span></div>
        <div><span>public:</span></div>
        <div>  virtual void b(){}</div>
        <div>  int a;</div>
        <div>  double b;</div>
        <div><span>};</span></div>
        <div><span>#pragma pack(pop)</span></div>
        <div><span><br>
          </span></div>
        <div><span>Have you also tried test cases with and without
            constructors?</span></div>
        <div><span><br>
          </span></div>
        <div><span>Thanks,</span></div>
        <div><span>- Don</span></div>
        <div><br>
        </div>
        <div style="font-size: 10pt; font-family: arial, helvetica, sans-serif; ">
          <div style="font-size: 12pt; font-family: times, serif; "><font face="Arial" size="2">
              <hr size="1"><b><span style="font-weight:bold;">From:</span></b>
              r4start <a rel="nofollow" class="yiv787442229moz-txt-link-rfc2396E" ymailto="mailto:r4start@gmail.com" target="_blank" href="mailto:r4start@gmail.com"><r4start@gmail.com></a><br>
              <b><span style="font-weight:bold;">To:</span></b> John
              McCall <a rel="nofollow" class="yiv787442229moz-txt-link-rfc2396E" ymailto="mailto:rjmccall@apple.com" target="_blank" href="mailto:rjmccall@apple.com"><rjmccall@apple.com></a><br>
              <b><span style="font-weight:bold;">Cc:</span></b>
              <a rel="nofollow" class="yiv787442229moz-txt-link-abbreviated" ymailto="mailto:cfe-dev@cs.uiuc.edu" target="_blank" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
              <b><span style="font-weight:bold;">Sent:</span></b>
              Thursday, September 15, 2011 11:20 AM<br>
              <b><span style="font-weight:bold;">Subject:</span></b>
              Re: [cfe-dev] Implementation of MSRecordLayoutBuilder.<br>
            </font><br>
            On 15/09/2011 00:39, r4start wrote:<br>
            > On 15/09/2011 00:36, John McCall wrote:<br>
            >> On Sep 14, 2011, at 1:33 PM, r4start wrote:<br>
            >> <br>
            >>> On 15/09/2011 00:24, John McCall wrote:<br>
            >>>> On Sep 14, 2011, at 1:23 PM, r4start wrote:<br>
            >>>>> On 14/09/2011 21:53, John McCall wrote:<br>
            >>>>>> On Sep 14, 2011, at 4:05 AM,
            r4start wrote:<br>
            >>>>>> <br>
            >>>>>>> On 14/09/2011 00:42, r4start
            wrote:<br>
            >>>>>>>> On 14/09/2011 00:37, Eli
            Friedman wrote:<br>
            >>>>>>>>> On Mon, Sep 12, 2011 at
            11:45 PM, r4start<<a rel="nofollow" ymailto="mailto:r4start@gmail.com" target="_blank" href="mailto:r4start@gmail.com">r4start@gmail.com</a>> 
              wrote:<br>
            >>>>>>>>>> On 12/09/2011
            21:57, r4start wrote:<br>
            >>>>>>>>>>> On 12/09/2011
            21:37, Eli Friedman wrote:<br>
            >>>>>>>>>>>> On Mon, Sep
            12, 2011 at 8:56 AM, r4start<<a rel="nofollow" ymailto="mailto:r4start@gmail.com" target="_blank" href="mailto:r4start@gmail.com">r4start@gmail.com</a>> 
                wrote:<br>
            >>>>>>>>>>>>> Hi,<br>
            >>>>>>>>>>>>> I have
            some prototype code for MSRecordLayoutBuilder. I test<br>
            >>>>>>>>>>>>> this
            code<br>
            >>>>>>>>>>>>> with
            MSVS 2010 and \Zp8 compiler option. On simple examples it<br>
            >>>>>>>>>>>>> seems
            to<br>
            >>>>>>>>>>>>> work
            properly.<br>
            >>>>>>>>>>>>> <br>
            >>>>>>>>>>>>> Is it
            interesting to the clang project?<br>
            >>>>>>>>>>>> We
            certainly want to fix any cases where clang does not do
            struct<br>
            >>>>>>>>>>>> layout
            consistently with MSVC on Windows.  It's hard to comment on<br>
            >>>>>>>>>>>> your patch
            without seeing it.<br>
            >>>>>>>>>>>> <br>
            >>>>>>>>>>>> -Eli<br>
            >>>>>>>>>>> Now I'm not at
            work. When I come to work I'll send a patch.<br>
            >>>>>>>>>>> <br>
            >>>>>>>>>>> - Dmitry<br>
            >>>>>>>>>> Here is patch for
            MSRecordLayoutBuilder.<br>
            >>>>>>>>> I think it would be
            better to integrate the checks into the main<br>
            >>>>>>>>> RecordLayoutBuilder
            class rather than subclassing it.<br>
            >>>>>>>>> <br>
            >>>>>>>>> Please include tests in
            your patch.  (See test/CodeGen/ms_struct.c for<br>
            >>>>>>>>> an example.)<br>
            >>>>>>>>> <br>
            >>>>>>>>> I would like someone
            more familiar with MSVC to review the actual<br>
            >>>>>>>>> logic here (ping me if
            nobody does within a few days, though, and I'll<br>
            >>>>>>>>> try to review anyway).<br>
            >>>>>>>>> <br>
            >>>>>>>>> -Eli<br>
            >>>>>>>> Ok, thanks for hint.<br>
            >>>>>>>> <br>
            >>>>>>>> -Dmitry.<br>
            >>>>>>> I have a problem when writing a
            test. Clang doesn't implement Microsoft<br>
            >>>>>>> ABI and he crashes at code
            generation stage.<br>
            >>>>>>> Clang have dump-record-layouts
            option but he prints AST layouts and<br>
            >>>>>>> CodeGen layouts.<br>
            >>>>>>> <br>
            >>>>>>> Is there a way to save only AST
            record layout to file and then check<br>
            >>>>>>> or maybe my patch must include
            CGRecordLayoutBuilder for Microsoft?<br>
            >>>>>> It would be easy enough to add a
            new testing switch if you'd like to get this in.<br>
            >>>>> Can you give me some hint how can I do
            this?<br>
            >>>> Follow the code for -dump-record-layouts.<br>
            >>> You propose to duplicate the output to a file
            and then run FileCheck to check output, am I right?<br>
            >> It would probably be better to run FileCheck
            directly on the output, but<br>
            >> I think you get the general idea.<br>
            >> <br>
            >> Whenever you get CGRecordLayoutBuilder working
            adequately, you can rip<br>
            >> out the new option and just use
            -dump-record-layouts.<br>
            >> <br>
            >> John.<br>
            > Ok, thanks. Tomorrow I'll do it.<br>
            > <br>
            Here is a test and patch.<br>
            <br>
            - Dmitry.<br>
            <br>
            <br>
            _______________________________________________<br>
            cfe-dev mailing list<br>
            <a rel="nofollow" ymailto="mailto:cfe-dev@cs.uiuc.edu" target="_blank" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
            <a rel="nofollow" target="_blank" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
            <br>
            <br>
          </div>
        </div>
      </div>
    </blockquote>
    Hi,<br>
    what I get from MSVS output :<br>
    <br>
    class B    size(24):<br>
    1>      +---<br>
    1>   0    | {vfptr}<br>
    1>   8    | a<br>
    1>         | <alignment member> (size=4)<br>
    1>  16   | c<br>
    1>      +---<br>
    <br>
    And this I get from clang with my patch:<br>
       0 | class B<br>
       0 |   (B vtable pointer)<br>
       4 |   int a<br>
       8 |   double c<br>
      sizeof=16, dsize=16, align=8<br>
      nvsize=16, nvalign=8<br>
     <br>
    I'll try to fix this.<br>
    <br>
    What do you mean when you say "<span>Have you also tried test cases
      with and without constructors?</span>", can you give me some
    examples and I check them.<br>
    <br>
    - Dmitry.<br>
  

</div><meta http-equiv="x-dns-prefetch-control" content="on"><br><br></div></div></div></body></html>