summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-08-10 07:00:24 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-08-10 07:00:24 +0000
commit07bb087ac1aa5075081d93be440d74d5ddda0d6a (patch)
tree05fc4bb8941377ae3b99ae32979a55c05f7bced7 /clang/lib
parent63fed4f35e410b1b3ec4bb957a1542e3b56214c0 (diff)
downloadbcm5719-llvm-07bb087ac1aa5075081d93be440d74d5ddda0d6a.tar.gz
bcm5719-llvm-07bb087ac1aa5075081d93be440d74d5ddda0d6a.zip
Fix crash during initialization of a bitfield which followed a zero
length element. Fix some 80-col violations. llvm-svn: 54610
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index d58d0046072..095153229e6 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud