[cfe-commits] r120922 - in /cfe/trunk: clang.xcodeproj/project.pbxproj lib/CodeGen/CGRecordLayoutBuilder.cpp

Anders Carlsson andersca at mac.com
Sat Dec 4 15:53:18 PST 2010


Author: andersca
Date: Sat Dec  4 17:53:18 2010
New Revision: 120922

URL: http://llvm.org/viewvc/llvm-project?rev=120922&view=rev
Log:
Replace calls to AppendBytes with calls to AppendPadding when the bytes appended are padding.

Modified:
    cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=120922&r1=120921&r2=120922&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Sat Dec  4 17:53:18 2010
@@ -2063,6 +2063,7 @@
 			isa = PBXProject;
 			buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
 			compatibilityVersion = "Xcode 2.4";
+			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				English,

Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=120922&r1=120921&r2=120922&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Sat Dec  4 17:53:18 2010
@@ -136,7 +136,8 @@
 
   /// 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 @@
     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 @@
     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::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,





More information about the cfe-commits mailing list