From: David Majnemer Date: Thu, 17 Jul 2014 00:55:19 +0000 (+0000) Subject: MS ABI: Padding injected between empty vbases doesn't up required align X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a246468f5816242734ec7f8dcab846c5805d8e86;p=platform%2Fupstream%2Fllvm.git MS ABI: Padding injected between empty vbases doesn't up required align Only alignment is changed, not required alignment. llvm-svn: 213217 --- diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index b5ebbee..b3deeba 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -2615,7 +2615,7 @@ void MicrosoftRecordLayoutBuilder::layoutVirtualBases(const CXXRecordDecl *RD) { if ((PreviousBaseLayout && PreviousBaseLayout->hasZeroSizedSubObject() && BaseLayout.leadsWithZeroSizedBase()) || HasVtordisp) { Size = Size.RoundUpToAlignment(VtorDispAlignment) + VtorDispSize; - RequiredAlignment = VtorDispAlignment; + Alignment = std::max(VtorDispAlignment, Alignment); } // Insert the virtual base. ElementInfo Info = getAdjustedElementInfo(BaseLayout); diff --git a/clang/test/Layout/ms-x86-pack-and-align.cpp b/clang/test/Layout/ms-x86-pack-and-align.cpp index 7398465..5e1aae1 100644 --- a/clang/test/Layout/ms-x86-pack-and-align.cpp +++ b/clang/test/Layout/ms-x86-pack-and-align.cpp @@ -598,6 +598,62 @@ struct ND : NC {}; // CHECK-X64-NEXT: | [sizeof=12, align=4 // CHECK-X64-NEXT: | nvsize=8, nvalign=4] +struct OA {}; +struct OB {}; +struct OC : virtual OA, virtual OB {}; +#pragma pack(push, 1) +struct OD : OC {}; +#pragma pack(pop) + +// CHECK: *** Dumping AST Record Layout +// CHECK-NEXT: 0 | struct OA (empty) +// CHECK-NEXT: | [sizeof=1, align=1 +// CHECK-NEXT: | nvsize=0, nvalign=1] +// CHECK: *** Dumping AST Record Layout +// CHECK-NEXT: 0 | struct OB (empty) +// CHECK-NEXT: | [sizeof=1, align=1 +// CHECK-NEXT: | nvsize=0, nvalign=1] +// CHECK: *** Dumping AST Record Layout +// CHECK-NEXT: 0 | struct OC +// CHECK-NEXT: 0 | (OC vbtable pointer) +// CHECK-NEXT: 4 | struct OA (virtual base) (empty) +// CHECK-NEXT: 8 | struct OB (virtual base) (empty) +// CHECK-NEXT: | [sizeof=8, align=4 +// CHECK-NEXT: | nvsize=4, nvalign=4] +// CHECK: *** Dumping AST Record Layout +// CHECK-NEXT: 0 | struct OD +// CHECK-NEXT: 0 | struct OC (base) +// CHECK-NEXT: 0 | (OC vbtable pointer) +// CHECK-NEXT: 4 | struct OA (virtual base) (empty) +// CHECK-NEXT: 8 | struct OB (virtual base) (empty) +// CHECK-NEXT: | [sizeof=8, align=1 +// CHECK-NEXT: | nvsize=4, nvalign=1] +// CHECK-X64: *** Dumping AST Record Layout +// CHECK-X64-NEXT: 0 | struct OA (empty) +// CHECK-X64-NEXT: | [sizeof=1, align=1 +// CHECK-X64-NEXT: | nvsize=0, nvalign=1] +// CHECK-X64: *** Dumping AST Record Layout +// CHECK-X64-NEXT: 0 | struct OB (empty) +// CHECK-X64-NEXT: | [sizeof=1, align=1 +// CHECK-X64-NEXT: | nvsize=0, nvalign=1] +// CHECK-X64: *** Dumping AST Record Layout +// CHECK-X64-NEXT: 0 | struct OC +// CHECK-X64-NEXT: 0 | (OC vbtable pointer) +// CHECK-X64-NEXT: 8 | struct OA (virtual base) (empty) +// CHECK-X64-NEXT: 12 | struct OB (virtual base) (empty) +// CHECK-X64-NEXT: | [sizeof=16, align=8 +// CHECK-X64-NEXT: | nvsize=8, nvalign=8] +// CHECK-X64: *** Dumping AST Record Layout +// CHECK-X64-NEXT: 0 | struct OD +// CHECK-X64-NEXT: 0 | struct OC (base) +// CHECK-X64-NEXT: 0 | (OC vbtable pointer) +// CHECK-X64-NEXT: 8 | struct OA (virtual base) (empty) +// CHECK-X64-NEXT: 12 | struct OB (virtual base) (empty) +// CHECK-X64-NEXT: | [sizeof=12, align=1 +// CHECK-X64-NEXT: | nvsize=8, nvalign=1] + + + int a[ sizeof(X)+ sizeof(Y)+ @@ -623,4 +679,5 @@ sizeof(RB3)+ sizeof(RC)+ sizeof(RE)+ sizeof(ND)+ +sizeof(OD)+ 0];