r199129 - [ms-abi] Quick fix layout of an array of records

Reid Kleckner reid at kleckner.net
Mon Jan 13 11:25:01 PST 2014


Author: rnk
Date: Mon Jan 13 13:25:00 2014
New Revision: 199129

URL: http://llvm.org/viewvc/llvm-project?rev=199129&view=rev
Log:
[ms-abi] Quick fix layout of an array of records

This fixes llvm::SmallVector, which fixes lots of TUs in the MS ABI self
host.

Modified:
    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
    cfe/trunk/test/Layout/ms-x86-basic-layout.cpp

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=199129&r1=199128&r2=199129&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Mon Jan 13 13:25:00 2014
@@ -2176,16 +2176,14 @@ MicrosoftRecordLayoutBuilder::getAdjuste
     Info = getAdjustedElementInfo(Layout);
     // Nomally getAdjustedElementInfo returns the non-virtual size, which is
     // correct for bases but not for fields.
-    Info.Size = Layout.getSize();
+    Info.Size = Context.getTypeInfoInChars(FD->getType()).first;
     // Capture required alignment as a side-effect.
     RequiredAlignment = std::max(RequiredAlignment,
                                  Layout.getRequiredAlignment());
   }
   else {
-    std::pair<CharUnits, CharUnits> FieldInfo =
+    llvm::tie(Info.Size, Info.Alignment) =
         Context.getTypeInfoInChars(FD->getType());
-    Info.Size = FieldInfo.first;
-    Info.Alignment = FieldInfo.second;
     if (FD->isBitField() && FD->getMaxAlignment() != 0)
       Info.Alignment = std::max(Info.Alignment, FieldRequiredAlignment);
     // Respect pragma pack.

Modified: cfe/trunk/test/Layout/ms-x86-basic-layout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Layout/ms-x86-basic-layout.cpp?rev=199129&r1=199128&r2=199129&view=diff
==============================================================================
--- cfe/trunk/test/Layout/ms-x86-basic-layout.cpp (original)
+++ cfe/trunk/test/Layout/ms-x86-basic-layout.cpp Mon Jan 13 13:25:00 2014
@@ -770,6 +770,21 @@ struct F6 : virtual A16f, A4, virtual B
 // CHECK-X64-NEXT:      | [sizeof=96, align=16
 // CHECK-X64-NEXT:      |  nvsize=32, nvalign=16]
 
+struct ArrayFieldOfRecords {
+  A4 InlineElts[2];
+};
+
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:    0 | struct ArrayFieldOfRecords
+// CHECK-NEXT:    0 |   struct A4 [2] InlineElts
+// CHECK-NEXT:      | [sizeof=8, align=4
+// CHECK-NEXT:      |  nvsize=8, nvalign=4]
+// CHECK-X64: *** Dumping AST Record Layout
+// CHECK-X64-NEXT:    0 | struct ArrayFieldOfRecords
+// CHECK-X64-NEXT:    0 |   struct A4 [2] InlineElts
+// CHECK-X64-NEXT:      | [sizeof=8, align=4
+// CHECK-X64-NEXT:      |  nvsize=8, nvalign=4]
+
 int a[
 sizeof(TestF0)+
 sizeof(TestF1)+
@@ -790,4 +805,5 @@ sizeof(F2)+
 sizeof(F3)+
 sizeof(F4)+
 sizeof(F5)+
-sizeof(F6)];
+sizeof(F6)+
+sizeof(ArrayFieldOfRecords)];





More information about the cfe-commits mailing list