[llvm-commits] [125748] Handle padding before zero-length fields.

johannes at apple.com johannes at apple.com
Thu Apr 5 12:09:17 PDT 2007


Revision: 125748
Author:   johannes
Date:     2007-04-05 12:09:17 -0700 (Thu, 05 Apr 2007)

Log Message:
-----------
Handle padding before zero-length fields.  Handle consecutive
zero-length fields as the comment indicates they should be.

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/llvm-types.cpp

Modified: apple-local/branches/llvm/gcc/llvm-types.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-types.cpp	2007-04-05 18:56:15 UTC (rev 125747)
+++ apple-local/branches/llvm/gcc/llvm-types.cpp	2007-04-05 19:09:17 UTC (rev 125748)
@@ -1063,12 +1063,23 @@
       return ~0U;
     }
 
-    // Handle zero sized fields now.  If the next field is zero sized, return
-    // it.  This is a nicety that causes us to assign C fields different LLVM
-    // fields in cases like struct X {}; struct Y { struct X a, b, c };
+    // Handle zero sized fields now.
+
+    // Skip over LLVM fields that start and end before the GCC field starts.
+    // Such fields are always nonzero sized, and we don't want to skip past 
+    // zero sized ones as well, which happens if you use only the Offset
+    // comparison.
+    while (CurFieldNo < ElementOffsetInBytes.size() &&
+           getFieldEndOffsetInBytes(CurFieldNo)*8 <= FieldOffsetInBits &&
+           ElementSizeInBytes[CurFieldNo] != 0)
+      ++CurFieldNo;
+
+    // If the next field is zero sized, advance past this one.  This is a nicety 
+    // that causes us to assign C fields different LLVM fields in cases like 
+    // struct X {}; struct Y { struct X a, b, c };
     if (CurFieldNo+1 < ElementOffsetInBytes.size() &&
         ElementSizeInBytes[CurFieldNo+1] == 0) {
-      return ++CurFieldNo;
+      return CurFieldNo++;
     }
     
     // Otherwise, if this is a zero sized field, return it.





More information about the llvm-commits mailing list