Introduce a CharUnits FieldOffsetInChars variable in AppendField() to

replace some uses of FieldOffsetInBytes. The remaining uses of
FieldOffsetInBytes will be replaced once NextFieldOffsetInBytes is converted
to CharUnits. No change in functionality intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127641 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ken Dyck 2011-03-15 01:09:02 +00:00
Родитель a8d530e3ad
Коммит 6925cc498b
1 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -77,7 +77,11 @@ private:
bool ConstStructBuilder::
AppendField(const FieldDecl *Field, uint64_t FieldOffset,
llvm::Constant *InitCst) {
uint64_t FieldOffsetInBytes = FieldOffset / 8;
const ASTContext &Context = CGM.getContext();
CharUnits FieldOffsetInChars = Context.toCharUnitsFromBits(FieldOffset);
uint64_t FieldOffsetInBytes = FieldOffsetInChars.getQuantity();
assert(NextFieldOffsetInBytes <= FieldOffsetInBytes
&& "Field offset mismatch!");
@ -100,9 +104,9 @@ AppendField(const FieldDecl *Field, uint64_t FieldOffset,
if (AlignedNextFieldOffsetInBytes < FieldOffsetInBytes) {
// We need to append padding.
AppendPadding(
CharUnits::fromQuantity(FieldOffsetInBytes - NextFieldOffsetInBytes));
FieldOffsetInChars - CharUnits::fromQuantity(NextFieldOffsetInBytes));
assert(NextFieldOffsetInBytes == FieldOffsetInBytes &&
assert(NextFieldOffsetInBytes == FieldOffsetInChars.getQuantity() &&
"Did not add enough padding!");
AlignedNextFieldOffsetInBytes = NextFieldOffsetInBytes;