[cfe-commits] r44974 - /cfe/trunk/CodeGen/CodeGenTypes.cpp
Devang Patel
dpatel at apple.com
Wed Dec 12 17:24:16 PST 2007
Author: dpatel
Date: Wed Dec 12 19:24:16 2007
New Revision: 44974
URL: http://llvm.org/viewvc/llvm-project?rev=44974&view=rev
Log:
Add assert to detect incomplete implementation work.
Modified:
cfe/trunk/CodeGen/CodeGenTypes.cpp
Modified: cfe/trunk/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenTypes.cpp?rev=44974&r1=44973&r2=44974&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenTypes.cpp Wed Dec 12 19:24:16 2007
@@ -594,6 +594,11 @@
}
}
} 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 @@
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);
}
}
More information about the cfe-commits
mailing list