diff options
author | Anders Carlsson <andersca@mac.com> | 2010-04-17 22:54:57 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-04-17 22:54:57 +0000 |
commit | 6ba38151f7e31d7f9194c8bbb91229cb5ffbb6f4 (patch) | |
tree | 6e701ceef98e1d7789206433b652c2a36dd38f73 /lib/CodeGen/CGRecordLayoutBuilder.cpp | |
parent | 3fbaf3e5d524bfff219d1e3e9ac4801a8411590f (diff) |
Simplify wide bit-field layout in CGRecordLayoutBuilder, and also fix a bug where assigning to a bit-field member would overwrite other parts of the struct.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101681 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGRecordLayoutBuilder.cpp')
-rw-r--r-- | lib/CodeGen/CGRecordLayoutBuilder.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index 215b39e743..71dca504c5 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -161,21 +161,16 @@ static CGBitFieldInfo ComputeBitFieldInfo(CodeGenTypes &Types, bool IsSigned = FD->getType()->isSignedIntegerType(); if (FieldSize > TypeSizeInBits) { - // We have a wide bit-field. - - CGBitFieldInfo::AccessInfo Component; - - Component.FieldIndex = 0; - Component.FieldByteOffset = - TypeSizeInBytes * ((FieldOffset / 8) / TypeSizeInBytes); - Component.FieldBitStart = 0; - Component.AccessWidth = TypeSizeInBits; - // FIXME: This might be wrong! - Component.AccessAlignment = 0; - Component.TargetBitOffset = 0; - Component.TargetBitWidth = TypeSizeInBits; - - return CGBitFieldInfo(TypeSizeInBits, 1, &Component, IsSigned); + // We have a wide bit-field. The extra bits are only used for padding, so + // if we have a bitfield of type T, with size N: + // + // T t : N; + // + // We can just assume that it's: + // + // T t : sizeof(T); + // + FieldSize = TypeSizeInBits; } unsigned StartBit = FieldOffset % TypeSizeInBits; |