<div dir="ltr">Should clang warn if this codepath is taken and -fmsc-version is VS2010?</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 10, 2014 at 5:14 PM, Warren Hunt <span dir="ltr"><<a href="mailto:whunt@google.com" target="_blank">whunt@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: whunt<br>
Date: Thu Apr 10 19:14:09 2014<br>
New Revision: 206004<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=206004&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=206004&view=rev</a><br>
Log:<br>
[MS-ABI] Update virtual base padding rules to match MSVC 10+<br>
In version 9 (VS2010) (and prior)? versions of msvc, if the last field<br>
in a record was a bitfield padding equal to the size of the storage<br>
class of that bitfield was added before each vbase and vtordisp. This<br>
patch removes that feature from clang and updates the lit tests to<br>
reflect it.<br>
<br>
<br>
Modified:<br>
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp<br>
cfe/trunk/test/Layout/ms-x86-bitfields-vbases.cpp<br>
cfe/trunk/test/Layout/ms-x86-pack-and-align.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=206004&r1=206003&r2=206004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=206004&r1=206003&r2=206004&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)<br>
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Thu Apr 10 19:14:09 2014<br>
@@ -2091,9 +2091,6 @@ static bool isMsLayout(const RecordDecl*<br>
// one.<br>
// * The last zero size virtual base may be placed at the end of the struct.<br>
// and can potentially alias a zero sized type in the next struct.<br>
-// * If the last field is a non-zero length bitfield, all virtual bases will<br>
-// have extra padding added before them for no obvious reason. The padding<br>
-// has the same number of bits as the type of the bitfield.<br>
// * When laying out empty non-virtual bases, an extra byte of padding is added<br>
// if the non-virtual base before the empty non-virtual base has a vbptr.<br>
// * The ABI attempts to avoid aliasing of zero sized bases by adding padding<br>
@@ -2595,10 +2592,6 @@ void MicrosoftRecordLayoutBuilder::layou<br>
const CXXRecordDecl *BaseDecl = I.getType()->getAsCXXRecordDecl();<br>
const ASTRecordLayout &BaseLayout = Context.getASTRecordLayout(BaseDecl);<br>
bool HasVtordisp = HasVtordispSet.count(BaseDecl);<br>
- // If the last field we laid out was a non-zero length bitfield then add<br>
- // some extra padding for no obvious reason.<br>
- if (LastFieldIsNonZeroWidthBitfield)<br>
- Size += CurrentBitfieldSize;<br>
// Insert padding between two bases if the left first one is zero sized or<br>
// contains a zero sized subobject and the right is zero sized or one leads<br>
// with a zero sized base. The padding between virtual bases is 4<br>
<br>
Modified: cfe/trunk/test/Layout/ms-x86-bitfields-vbases.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-bitfields-vbases.cpp?rev=206004&r1=206003&r2=206004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-bitfields-vbases.cpp?rev=206004&r1=206003&r2=206004&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Layout/ms-x86-bitfields-vbases.cpp (original)<br>
+++ cfe/trunk/test/Layout/ms-x86-bitfields-vbases.cpp Thu Apr 10 19:14:09 2014<br>
@@ -13,17 +13,17 @@ struct A : virtual B0 { char a : 1; };<br>
// CHECK-NEXT: 0 | struct A<br>
// CHECK-NEXT: 0 | (A vbtable pointer)<br>
// CHECK-NEXT: 4 | char a<br>
-// CHECK-NEXT: 12 | struct B0 (virtual base)<br>
-// CHECK-NEXT: 12 | int a<br>
-// CHECK-NEXT: | [sizeof=16, align=4<br>
+// CHECK-NEXT: 8 | struct B0 (virtual base)<br>
+// CHECK-NEXT: 8 | int a<br>
+// CHECK-NEXT: | [sizeof=12, align=4<br>
// CHECK-NEXT: | nvsize=8, nvalign=4]<br>
// CHECK-X64: *** Dumping AST Record Layout<br>
// CHECK-X64: *** Dumping AST Record Layout<br>
// CHECK-X64-NEXT: 0 | struct A<br>
// CHECK-X64-NEXT: 0 | (A vbtable pointer)<br>
// CHECK-X64-NEXT: 8 | char a<br>
-// CHECK-X64-NEXT: 20 | struct B0 (virtual base)<br>
-// CHECK-X64-NEXT: 20 | int a<br>
+// CHECK-X64-NEXT: 16 | struct B0 (virtual base)<br>
+// CHECK-X64-NEXT: 16 | int a<br>
// CHECK-X64-NEXT: | [sizeof=24, align=8<br>
// CHECK-X64-NEXT: | nvsize=16, nvalign=8]<br>
<br>
@@ -33,16 +33,16 @@ struct B : virtual B0 { short a : 1; };<br>
// CHECK-NEXT: 0 | struct B<br>
// CHECK-NEXT: 0 | (B vbtable pointer)<br>
// CHECK-NEXT: 4 | short a<br>
-// CHECK-NEXT: 12 | struct B0 (virtual base)<br>
-// CHECK-NEXT: 12 | int a<br>
-// CHECK-NEXT: | [sizeof=16, align=4<br>
+// CHECK-NEXT: 8 | struct B0 (virtual base)<br>
+// CHECK-NEXT: 8 | int a<br>
+// CHECK-NEXT: | [sizeof=12, align=4<br>
// CHECK-NEXT: | nvsize=8, nvalign=4]<br>
// CHECK-X64: *** Dumping AST Record Layout<br>
// CHECK-X64-NEXT: 0 | struct B<br>
// CHECK-X64-NEXT: 0 | (B vbtable pointer)<br>
// CHECK-X64-NEXT: 8 | short a<br>
-// CHECK-X64-NEXT: 20 | struct B0 (virtual base)<br>
-// CHECK-X64-NEXT: 20 | int a<br>
+// CHECK-X64-NEXT: 16 | struct B0 (virtual base)<br>
+// CHECK-X64-NEXT: 16 | int a<br>
// CHECK-X64-NEXT: | [sizeof=24, align=8<br>
// CHECK-X64-NEXT: | nvsize=16, nvalign=8]<br>
<br>
@@ -94,22 +94,22 @@ struct E : virtual B0, virtual B1 { long<br>
// CHECK-NEXT: 0 | struct E<br>
// CHECK-NEXT: 0 | (E vbtable pointer)<br>
// CHECK-NEXT: 8 | long long<br>
-// CHECK-NEXT: 24 | struct B0 (virtual base)<br>
-// CHECK-NEXT: 24 | int a<br>
-// CHECK-NEXT: 36 | struct B1 (virtual base)<br>
-// CHECK-NEXT: 36 | int a<br>
-// CHECK-NEXT: | [sizeof=40, align=8<br>
+// CHECK-NEXT: 16 | struct B0 (virtual base)<br>
+// CHECK-NEXT: 16 | int a<br>
+// CHECK-NEXT: 20 | struct B1 (virtual base)<br>
+// CHECK-NEXT: 20 | int a<br>
+// CHECK-NEXT: | [sizeof=24, align=8<br>
// CHECK-NEXT: | nvsize=16, nvalign=8]<br>
// CHECK-X64: *** Dumping AST Record Layout<br>
// CHECK-X64: *** Dumping AST Record Layout<br>
// CHECK-X64-NEXT: 0 | struct E<br>
// CHECK-X64-NEXT: 0 | (E vbtable pointer)<br>
// CHECK-X64-NEXT: 8 | long long<br>
-// CHECK-X64-NEXT: 24 | struct B0 (virtual base)<br>
-// CHECK-X64-NEXT: 24 | int a<br>
-// CHECK-X64-NEXT: 36 | struct B1 (virtual base)<br>
-// CHECK-X64-NEXT: 36 | int a<br>
-// CHECK-X64-NEXT: | [sizeof=40, align=8<br>
+// CHECK-X64-NEXT: 16 | struct B0 (virtual base)<br>
+// CHECK-X64-NEXT: 16 | int a<br>
+// CHECK-X64-NEXT: 20 | struct B1 (virtual base)<br>
+// CHECK-X64-NEXT: 20 | int a<br>
+// CHECK-X64-NEXT: | [sizeof=24, align=8<br>
// CHECK-X64-NEXT: | nvsize=16, nvalign=8]<br>
<br>
int a[<br>
<br>
Modified: cfe/trunk/test/Layout/ms-x86-pack-and-align.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-pack-and-align.cpp?rev=206004&r1=206003&r2=206004&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-pack-and-align.cpp?rev=206004&r1=206003&r2=206004&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Layout/ms-x86-pack-and-align.cpp (original)<br>
+++ cfe/trunk/test/Layout/ms-x86-pack-and-align.cpp Thu Apr 10 19:14:09 2014<br>
@@ -473,7 +473,7 @@ struct RE {<br>
// CHECK-NEXT: 0 | struct RB2<br>
// CHECK-NEXT: 0 | (RB2 vbtable pointer)<br>
// CHECK-NEXT: 1024 | int b<br>
-// CHECK-NEXT: 1032 | struct RA (virtual base) (empty)<br>
+// CHECK-NEXT: 1028 | struct RA (virtual base) (empty)<br>
// CHECK-NEXT: | [sizeof=1032, align=1024<br>
// CHECK-NEXT: | nvsize=1028, nvalign=1024]<br>
// CHECK: *** Dumping AST Record Layout<br>
@@ -481,7 +481,7 @@ struct RE {<br>
// CHECK-NEXT: 0 | (RB3 vftable pointer)<br>
// CHECK-NEXT: 1024 | (RB3 vbtable pointer)<br>
// CHECK-NEXT: 2048 | int b<br>
-// CHECK-NEXT: 2056 | struct RA (virtual base) (empty)<br>
+// CHECK-NEXT: 2052 | struct RA (virtual base) (empty)<br>
// CHECK-NEXT: | [sizeof=2056, align=1024<br>
// CHECK-NEXT: | nvsize=2052, nvalign=1024]<br>
// CHECK: *** Dumping AST Record Layout<br>
@@ -516,7 +516,7 @@ struct RE {<br>
// CHECK-X64-NEXT: 0 | struct RB2<br>
// CHECK-X64-NEXT: 0 | (RB2 vbtable pointer)<br>
// CHECK-X64-NEXT: 1024 | int b<br>
-// CHECK-X64-NEXT: 1032 | struct RA (virtual base) (empty)<br>
+// CHECK-X64-NEXT: 1028 | struct RA (virtual base) (empty)<br>
// CHECK-X64-NEXT: | [sizeof=1032, align=1024<br>
// CHECK-X64-NEXT: | nvsize=1028, nvalign=1024]<br>
// CHECK-X64: *** Dumping AST Record Layout<br>
@@ -524,7 +524,7 @@ struct RE {<br>
// CHECK-X64-NEXT: 0 | (RB3 vftable pointer)<br>
// CHECK-X64-NEXT: 1024 | (RB3 vbtable pointer)<br>
// CHECK-X64-NEXT: 2048 | int b<br>
-// CHECK-X64-NEXT: 2056 | struct RA (virtual base) (empty)<br>
+// CHECK-X64-NEXT: 2052 | struct RA (virtual base) (empty)<br>
// CHECK-X64-NEXT: | [sizeof=2056, align=1024<br>
// CHECK-X64-NEXT: | nvsize=2052, nvalign=1024]<br>
// CHECK-X64: *** Dumping AST Record Layout<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>