diff options
| author | Devang Patel <dpatel@apple.com> | 2007-12-13 01:24:16 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2007-12-13 01:24:16 +0000 |
| commit | 527048247b965277c527decafcdc8b8c53e67fdc (patch) | |
| tree | b0f19525d7671a040278333bf85cf3ab2b2ba7a8 /clang/CodeGen/CodeGenTypes.cpp | |
| parent | 272ee458cffad6f03f918b276bd0af9b09d33800 (diff) | |
| download | bcm5719-llvm-527048247b965277c527decafcdc8b8c53e67fdc.tar.gz bcm5719-llvm-527048247b965277c527decafcdc8b8c53e67fdc.zip | |
Add assert to detect incomplete implementation work.
llvm-svn: 44974
Diffstat (limited to 'clang/CodeGen/CodeGenTypes.cpp')
| -rw-r--r-- | clang/CodeGen/CodeGenTypes.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/clang/CodeGen/CodeGenTypes.cpp b/clang/CodeGen/CodeGenTypes.cpp index a66c760340d..54cc8b12364 100644 --- a/clang/CodeGen/CodeGenTypes.cpp +++ b/clang/CodeGen/CodeGenTypes.cpp @@ -594,6 +594,11 @@ void RecordOrganizer::placeBitField(const FieldDecl *FD) { } } } else if (ExtraBits >= BitFieldSize) { + const llvm::Type *Ty = CGT.ConvertType(FD->getType()); + uint64_t TySize = CGT.getTargetData().getABITypeSizeInBits(Ty); + assert ( Cursor - CurrentFieldStart + BitFieldSize <= TySize + && "Incomplete layout. struct {char a; int b:10; int c:18;};"); + // Reuse existing llvm field ExtraBits = ExtraBits - BitFieldSize; CGT.addFieldInfo(FD, FieldNo, Cursor - CurrentFieldStart, ExtraBits); @@ -604,13 +609,13 @@ void RecordOrganizer::placeBitField(const FieldDecl *FD) { const llvm::Type *Ty = CGT.ConvertType(FD->getType()); const llvm::Type *PrevTy = LLVMFields.back(); uint64_t TySize = CGT.getTargetData().getABITypeSizeInBits(Ty); - if (CGT.getTargetData().getABITypeSizeInBits(PrevTy) >= TySize) { - // Previous field does not allow sharing of ExtraBits. Use new field. - // struct { char a; char b:5; char c:4; } where c is current FD. - Cursor += ExtraBits; - ExtraBits = 0; - addLLVMField(Ty, TySize, FD, 0, BitFieldSize); - } else - assert (!FD->isBitField() && "Bit fields are not yet supported"); + assert (CGT.getTargetData().getABITypeSizeInBits(PrevTy) >= TySize + && "Unable to handle bit field"); + + // Previous field does not allow sharing of ExtraBits. Use new field. + // struct { char a; char b:5; char c:4; } where c is current FD. + Cursor += ExtraBits; + ExtraBits = 0; + addLLVMField(Ty, TySize, FD, 0, BitFieldSize); } } |

