diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-08-10 07:00:24 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-08-10 07:00:24 +0000 |
commit | 9ca8bb0996bbb8b9dbf69c51cb3d1523559e47e3 (patch) | |
tree | 8563914eb69ab5ffc6ae2cb200b530a2a2c2d22f /lib/CodeGen/CGExprConstant.cpp | |
parent | a5d1cb7ef3f0780540e7fd7180399fd220ef0210 (diff) |
Fix crash during initialization of a bitfield which followed a zero
length element.
Fix some 80-col violations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54610 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index d58d004607..095153229e 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -132,7 +132,8 @@ public: // Calculate information about the relevant field const llvm::Type* Ty = CI->getType(); - unsigned size = CGM.getTypes().getTargetData().getTypeStoreSizeInBits(Ty); + const llvm::TargetData &TD = CGM.getTypes().getTargetData(); + unsigned size = TD.getTypeStoreSizeInBits(Ty); unsigned fieldOffset = CGM.getTypes().getLLVMFieldNo(Field) * size; CodeGenTypes::BitFieldInfo bitFieldInfo = CGM.getTypes().getBitFieldInfo(Field); @@ -143,7 +144,12 @@ public: // FIXME: This won't work if the struct isn't completely packed! unsigned offset = 0, i = 0; while (offset < (fieldOffset & -8)) - offset += CGM.getTypes().getTargetData().getTypeStoreSizeInBits(Elts[i++]->getType()); + offset += TD.getTypeStoreSizeInBits(Elts[i++]->getType()); + + // Advance over 0 sized elements (must terminate in bounds since + // the bitfield must have a size). + while (TD.getTypeStoreSizeInBits(Elts[i]->getType()) == 0) + ++i; // Promote the size of V if necessary // FIXME: This should never occur, but currently it can because |