]> granicus.if.org Git - clang/commitdiff
Replace calls to AppendBytes with calls to AppendPadding when the bytes appended...
authorAnders Carlsson <andersca@mac.com>
Sat, 4 Dec 2010 23:53:18 +0000 (23:53 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 4 Dec 2010 23:53:18 +0000 (23:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120922 91177308-0d34-0410-b5e6-96231b3b80d8

clang.xcodeproj/project.pbxproj
lib/CodeGen/CGRecordLayoutBuilder.cpp

index 36660f04aa4beae4d633193d3c3f8d21b12ec26c..877d81e61e19d4ae059b8183e3fbd784cdecf2fd 100644 (file)
                        isa = PBXProject;
                        buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
                        compatibilityVersion = "Xcode 2.4";
+                       developmentRegion = English;
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index 9b154d03bf61ac205bc25ec56192fcbd1d0dfabe..855552f960cd369a49ce3826087272d43cfe6908 100644 (file)
@@ -136,7 +136,8 @@ private:
 
   /// AppendPadding - Appends enough padding bytes so that the total
   /// struct size is a multiple of the field alignment.
-  void AppendPadding(uint64_t FieldOffsetInBytes, unsigned FieldAlignment);
+  void AppendPadding(uint64_t FieldOffsetInBytes,
+                     unsigned FieldAlignmentInBytes);
 
   /// getByteArrayType - Returns a byte array type with the given number of
   /// elements.
@@ -325,7 +326,7 @@ void CGRecordLayoutBuilder::LayoutBitField(const FieldDecl *D,
     assert(FieldOffset % 8 == 0 && "Field offset not aligned correctly");
 
     // Append padding if necessary.
-    AppendBytes((FieldOffset - NextFieldOffset) / 8);
+    AppendPadding(FieldOffset / 8, 1);
 
     NumBytesToAppend =
       llvm::RoundUpToAlignment(FieldSize, 8) / 8;
@@ -393,13 +394,7 @@ bool CGRecordLayoutBuilder::LayoutField(const FieldDecl *D,
     return false;
   }
 
-  if (AlignedNextFieldOffsetInBytes < FieldOffsetInBytes) {
-    // Even with alignment, the field offset is not at the right place,
-    // insert padding.
-    uint64_t PaddingInBytes = FieldOffsetInBytes - NextFieldOffsetInBytes;
-
-    AppendBytes(PaddingInBytes);
-  }
+  AppendPadding(FieldOffsetInBytes, TypeAlignment);
 
   // Now append the field.
   LLVMFields.push_back(LLVMFieldInfo(D, FieldTypes.size()));
@@ -713,13 +708,13 @@ void CGRecordLayoutBuilder::AppendField(uint64_t FieldOffsetInBytes,
 }
 
 void CGRecordLayoutBuilder::AppendPadding(uint64_t FieldOffsetInBytes,
-                                          unsigned FieldAlignment) {
+                                          unsigned FieldAlignmentInBytes) {
   assert(NextFieldOffsetInBytes <= FieldOffsetInBytes &&
          "Incorrect field layout!");
 
   // Round up the field offset to the alignment of the field type.
   uint64_t AlignedNextFieldOffsetInBytes =
-    llvm::RoundUpToAlignment(NextFieldOffsetInBytes, FieldAlignment);
+    llvm::RoundUpToAlignment(NextFieldOffsetInBytes, FieldAlignmentInBytes);
 
   if (AlignedNextFieldOffsetInBytes < FieldOffsetInBytes) {
     // Even with alignment, the field offset is not at the right place,