break;
}
- Result.Offset +=
- CharUnits::fromQuantity(RL.getFieldOffset(i) / Info.Ctx.getCharWidth());
+ Result.Offset += Info.Ctx.toCharUnitsFromBits(RL.getFieldOffset(i));
return true;
}
Result.Base = BaseLV.getLValueBase();
Result.Offset = BaseLV.getLValueOffset() +
- CharUnits::fromQuantity(Offset / Info.Ctx.getCharWidth());
+ Info.Ctx.toCharUnitsFromBits(Offset);
return true;
}
if (const ReferenceType *Ref = T->getAs<ReferenceType>())
T = Ref->getPointeeType();
- // Get information about the alignment.
- unsigned CharSize = Info.Ctx.Target.getCharWidth();
-
// __alignof is defined to return the preferred alignment.
- return CharUnits::fromQuantity(
- Info.Ctx.getPreferredTypeAlign(T.getTypePtr()) / CharSize);
+ return Info.Ctx.toCharUnitsFromBits(
+ Info.Ctx.getPreferredTypeAlign(T.getTypePtr()));
}
CharUnits IntExprEvaluator::GetAlignOfExpr(const Expr *E) {
break;
}
assert(i < RL.getFieldCount() && "offsetof field in wrong type");
- Result += CharUnits::fromQuantity(
- RL.getFieldOffset(i) / Info.Ctx.getCharWidth());
+ Result += Info.Ctx.toCharUnitsFromBits(RL.getFieldOffset(i));
CurrentType = MemberDecl->getType().getNonReferenceType();
break;
}
return false;
// Add the offset to the base.
- Result += CharUnits::fromQuantity(
- RL.getBaseClassOffsetInBits(cast<CXXRecordDecl>(BaseRT->getDecl()))
- / Info.Ctx.getCharWidth());
+ Result += Info.Ctx.toCharUnitsFromBits(
+ RL.getBaseClassOffsetInBits(
+ cast<CXXRecordDecl>(BaseRT->getDecl())));
break;
}
}
assert(FieldOffset % CharWidth == 0 &&
"Field offset not at char boundary!");
- return CharUnits::fromQuantity(FieldOffset / CharWidth);
+ return toCharUnits(FieldOffset);
}
// FIXME: Remove this.
// FIXME: Remove these.
CharUnits toCharUnits(uint64_t Offset) const {
- return CharUnits::fromQuantity(Offset / Context.getCharWidth());
+ return Context.toCharUnitsFromBits(Offset);
}
uint64_t toOffset(CharUnits Offset) const {
return Offset.getQuantity() * Context.getCharWidth();
E = RD->field_end(); I != E; ++I, ++FieldNo) {
const FieldDecl *Field = *I;
CharUnits FieldOffset = Offset +
- CharUnits::fromQuantity(Layout.getFieldOffset(FieldNo) /
- C.getCharWidth());
+ C.toCharUnitsFromBits(Layout.getFieldOffset(FieldNo));
if (const RecordType *RT = Field->getType()->getAs<RecordType>()) {
if (const CXXRecordDecl *D = dyn_cast<CXXRecordDecl>(RT->getDecl())) {