aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorKen Dyck <ken.dyck@onsemi.com>2011-01-18 01:56:16 +0000
committerKen Dyck <ken.dyck@onsemi.com>2011-01-18 01:56:16 +0000
commitfb1e3bc29b667f4275e1d5a43d64ec173f4f9a7d (patch)
tree66efc799bbe7d4a111884b7578d6855f95da5144 /lib/AST/ExprConstant.cpp
parenta75732201b19059a0e56a88b0eb5a0e5dd3c6ca3 (diff)
Replace calls to CharUnits::fromQuantity() with ones
ASTContext::toCharUnitsFromBits() when converting from bit sizes to char units. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123715 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r--lib/AST/ExprConstant.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index cb73810163..f262a4acff 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -404,8 +404,7 @@ bool LValueExprEvaluator::VisitMemberExpr(MemberExpr *E) {
break;
}
- Result.Offset +=
- CharUnits::fromQuantity(RL.getFieldOffset(i) / Info.Ctx.getCharWidth());
+ Result.Offset += Info.Ctx.toCharUnitsFromBits(RL.getFieldOffset(i));
return true;
}
@@ -574,7 +573,7 @@ bool PointerExprEvaluator::VisitCastExpr(CastExpr* E) {
Result.Base = BaseLV.getLValueBase();
Result.Offset = BaseLV.getLValueOffset() +
- CharUnits::fromQuantity(Offset / Info.Ctx.getCharWidth());
+ Info.Ctx.toCharUnitsFromBits(Offset);
return true;
}
@@ -1481,12 +1480,9 @@ CharUnits IntExprEvaluator::GetAlignOfType(QualType T) {
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) {
@@ -1578,8 +1574,7 @@ bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *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;
}
@@ -1607,9 +1602,9 @@ bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *E) {
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;
}
}