[cfe-commits] r123715 - in /cfe/trunk/lib/AST: ExprConstant.cpp RecordLayoutBuilder.cpp
Ken Dyck
ken.dyck at onsemi.com
Mon Jan 17 17:56:16 PST 2011
Author: kjdyck
Date: Mon Jan 17 19:56:16 2011
New Revision: 123715
URL: http://llvm.org/viewvc/llvm-project?rev=123715&view=rev
Log:
Replace calls to CharUnits::fromQuantity() with ones
ASTContext::toCharUnitsFromBits() when converting from bit sizes to char units.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=123715&r1=123714&r2=123715&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Jan 17 19:56:16 2011
@@ -404,8 +404,7 @@
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 @@
Result.Base = BaseLV.getLValueBase();
Result.Offset = BaseLV.getLValueOffset() +
- CharUnits::fromQuantity(Offset / Info.Ctx.getCharWidth());
+ Info.Ctx.toCharUnitsFromBits(Offset);
return true;
}
@@ -1481,12 +1480,9 @@
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 @@
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 @@
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;
}
}
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=123715&r1=123714&r2=123715&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Mon Jan 17 19:56:16 2011
@@ -98,7 +98,7 @@
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 @@
// 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 @@
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())) {
More information about the cfe-commits
mailing list