Hello Warren, Could you check your CRLF settings? Your commit added mixed line endings to test/Layout/ms-x86-bitfields-vbases.cpp.
Also maybe it's worth adding a TODO to investigate this further, weird padding might indicate something is misaligned or missing in the base layout. Alp. On 06/11/2013 00:55, Warren Hunt wrote: > Author: whunt > Date: Tue Nov 5 18:54:59 2013 > New Revision: 194115 > > URL: http://llvm.org/viewvc/llvm-project?rev=194115&view=rev > Log: > Microsoft adds weird padding before virtual bases if the last field was a > bitfield > > This patch adds the same behavior to clang. > > Differential Revision: http://llvm-reviews.chandlerc.com/D2103 > > > Added: > cfe/trunk/test/Layout/ms-x86-bitfields-vbases.cpp > Modified: > cfe/trunk/lib/AST/RecordLayoutBuilder.cpp > > Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=194115&r1=194114&r2=194115&view=diff > ============================================================================== > --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original) > +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Tue Nov 5 18:54:59 2013 > @@ -2014,6 +2014,10 @@ static bool isMsLayout(const RecordDecl* > // one. > // * The last zero size virtual base may be placed at the end of the struct. > // and can potentially alias a zero sized type in the next struct. > +// * If the last field is a non-zero length bitfield and we have any virtual > +// bases then some extra padding is added before the virtual bases for no > +// obvious reason. > + > > namespace { > struct MicrosoftRecordLayoutBuilder { > @@ -2499,6 +2503,11 @@ void MicrosoftRecordLayoutBuilder::layou > llvm::SmallPtrSet<const CXXRecordDecl *, 2> HasVtordisp = > computeVtorDispSet(RD); > > + // If the last field we laid out was a non-zero length bitfield then add > some > + // extra padding for no obvious reason. > + if (LastFieldIsNonZeroWidthBitfield) > + Size += CurrentBitfieldSize; > + > // Iterate through the virtual bases and lay them out. > for (CXXRecordDecl::base_class_const_iterator i = RD->vbases_begin(), > e = RD->vbases_end(); > > Added: cfe/trunk/test/Layout/ms-x86-bitfields-vbases.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-bitfields-vbases.cpp?rev=194115&view=auto > ============================================================================== > --- cfe/trunk/test/Layout/ms-x86-bitfields-vbases.cpp (added) > +++ cfe/trunk/test/Layout/ms-x86-bitfields-vbases.cpp Tue Nov 5 18:54:59 2013 > @@ -0,0 +1,84 @@ > +// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 > -fdump-record-layouts -fsyntax-only -cxx-abi microsoft %s 2>&1 \ > +// RUN: | FileCheck %s > +// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 > -fdump-record-layouts -fsyntax-only -cxx-abi microsoft %s 2>/dev/null \ > +// RUN: | FileCheck %s -check-prefix CHECK-X64 > + > +struct B0 { }; > + > +struct A : virtual B0 { char a : 1; }; > + > +// CHECK: *** Dumping AST Record Layout > +// CHECK: 0 | struct A > +// CHECK: 0 | (A vbtable pointer) > +// CHECK: 4 | char a > +// CHECK: 9 | struct B0 (virtual base) (empty) > +// CHECK: | [sizeof=9, align=4 > +// CHECK: | nvsize=8, nvalign=4] > +// CHECK-X64: *** Dumping AST Record Layout > +// CHECK-X64: 0 | struct A > +// CHECK-X64: 0 | (A vbtable pointer) > +// CHECK-X64: 8 | char a > +// CHECK-X64: 17 | struct B0 (virtual base) (empty) > +// CHECK-X64: | [sizeof=24, align=8 > +// CHECK-X64: | nvsize=16, nvalign=8] > + > +struct B : virtual B0 { short a : 1; }; > + > +// CHECK: *** Dumping AST Record Layout > +// CHECK: 0 | struct B > +// CHECK: 0 | (B vbtable pointer) > +// CHECK: 4 | short a > +// CHECK: 10 | struct B0 (virtual base) (empty) > +// CHECK: | [sizeof=10, align=4 > +// CHECK: | nvsize=8, nvalign=4] > +// CHECK-X64: *** Dumping AST Record Layout > +// CHECK-X64: 0 | struct B > +// CHECK-X64: 0 | (B vbtable pointer) > +// CHECK-X64: 8 | short a > +// CHECK-X64: 18 | struct B0 (virtual base) (empty) > +// CHECK-X64: | [sizeof=24, align=8 > +// CHECK-X64: | nvsize=16, nvalign=8] > + > +struct C : virtual B0 { char a : 1; char : 0; }; > + > +// CHECK: *** Dumping AST Record Layout > +// CHECK: 0 | struct C > +// CHECK: 0 | (C vbtable pointer) > +// CHECK: 4 | char a > +// CHECK: 5 | char > +// CHECK: 8 | struct B0 (virtual base) (empty) > +// CHECK: | [sizeof=8, align=4 > +// CHECK: | nvsize=8, nvalign=4] > +// CHECK-X64: *** Dumping AST Record Layout > +// CHECK-X64: 0 | struct C > +// CHECK-X64: 0 | (C vbtable pointer) > +// CHECK-X64: 8 | char a > +// CHECK-X64: 9 | char > +// CHECK-X64: 16 | struct B0 (virtual base) (empty) > +// CHECK-X64: | [sizeof=16, align=8 > +// CHECK-X64: | nvsize=16, nvalign=8] > + > +struct D : virtual B0 { char a : 1; char b; }; > + > +// CHECK: *** Dumping AST Record Layout > +// CHECK: 0 | struct D > +// CHECK: 0 | (D vbtable pointer) > +// CHECK: 4 | char a > +// CHECK: 5 | char b > +// CHECK: 8 | struct B0 (virtual base) (empty) > +// CHECK: | [sizeof=8, align=4 > +// CHECK: | nvsize=8, nvalign=4] > +// CHECK-X64: *** Dumping AST Record Layout > +// CHECK-X64: 0 | struct D > +// CHECK-X64: 0 | (D vbtable pointer) > +// CHECK-X64: 8 | char a > +// CHECK-X64: 9 | char b > +// CHECK-X64: 16 | struct B0 (virtual base) (empty) > +// CHECK-X64: | [sizeof=16, align=8 > +// CHECK-X64: | nvsize=16, nvalign=8] > + > +int a[ > +sizeof(A)+ > +sizeof(B)+ > +sizeof(C)+ > +sizeof(D)]; > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits -- http://www.nuanti.com the browser experts _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
