summaryrefslogtreecommitdiffstats
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
commit86a7fcc19c91af32f1947e802130dfe68a6b05ce (patch)
tree664e464f89beb6c2447d954ada8dea1e605941fa
parent542f8a52214374684dc8b1f6f3239a34942ac360 (diff)
downloadbcm5719-llvm-86a7fcc19c91af32f1947e802130dfe68a6b05ce.tar.gz
bcm5719-llvm-86a7fcc19c91af32f1947e802130dfe68a6b05ce.zip
Replace calls to CharUnits::fromQuantity() with ones
ASTContext::toCharUnitsFromBits() when converting from bit sizes to char units. llvm-svn: 123715
-rw-r--r--clang/lib/AST/ExprConstant.cpp21
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.cpp7
2 files changed, 11 insertions, 17 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index cb738101636..f262a4acff0 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/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;
}
}
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index 7b5ed4ad161..c433ca488cf 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -98,7 +98,7 @@ class EmptySubobjectMap {
assert(FieldOffset % CharWidth == 0 &&
"Field offset not at char boundary!");
- return CharUnits::fromQuantity(FieldOffset / CharWidth);
+ return toCharUnits(FieldOffset);
}
// FIXME: Remove this.
@@ -623,7 +623,7 @@ protected:
// 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();
@@ -1806,8 +1806,7 @@ static void DumpCXXRecordLayout(llvm::raw_ostream &OS,
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())) {
OpenPOWER on IntegriCloud