Change the return type of ASTContext::getDeclAlignInBytes() to CharUnits and,
now that the "InBytes" part of the name is implied by the return type, rename
it to getDeclAlign().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94681 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 086249c..d64e6f1 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -849,8 +849,8 @@
bool VisitUnaryImag(const UnaryOperator *E);
private:
- unsigned GetAlignOfExpr(const Expr *E);
- unsigned GetAlignOfType(QualType T);
+ CharUnits GetAlignOfExpr(const Expr *E);
+ CharUnits GetAlignOfType(QualType T);
// FIXME: Missing: array subscript of vector, member of vector
};
} // end anonymous namespace
@@ -1288,7 +1288,7 @@
return Visit(Cond ? E->getTrueExpr() : E->getFalseExpr());
}
-unsigned IntExprEvaluator::GetAlignOfType(QualType T) {
+CharUnits IntExprEvaluator::GetAlignOfType(QualType T) {
// C++ [expr.sizeof]p2: "When applied to a reference or a reference type,
// the result is the size of the referenced type."
// C++ [expr.alignof]p3: "When alignof is applied to a reference type, the
@@ -1300,20 +1300,22 @@
unsigned CharSize = Info.Ctx.Target.getCharWidth();
// __alignof is defined to return the preferred alignment.
- return Info.Ctx.getPreferredTypeAlign(T.getTypePtr()) / CharSize;
+ return CharUnits::fromQuantity(
+ Info.Ctx.getPreferredTypeAlign(T.getTypePtr()) / CharSize);
}
-unsigned IntExprEvaluator::GetAlignOfExpr(const Expr *E) {
+CharUnits IntExprEvaluator::GetAlignOfExpr(const Expr *E) {
E = E->IgnoreParens();
// alignof decl is always accepted, even if it doesn't make sense: we default
// to 1 in those cases.
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
- return Info.Ctx.getDeclAlignInBytes(DRE->getDecl(), /*RefAsPointee*/true);
+ return Info.Ctx.getDeclAlign(DRE->getDecl(),
+ /*RefAsPointee*/true);
if (const MemberExpr *ME = dyn_cast<MemberExpr>(E))
- return Info.Ctx.getDeclAlignInBytes(ME->getMemberDecl(),
- /*RefAsPointee*/true);
+ return Info.Ctx.getDeclAlign(ME->getMemberDecl(),
+ /*RefAsPointee*/true);
return GetAlignOfType(E->getType());
}
@@ -1325,9 +1327,9 @@
// Handle alignof separately.
if (!E->isSizeOf()) {
if (E->isArgumentType())
- return Success(GetAlignOfType(E->getArgumentType()), E);
+ return Success(GetAlignOfType(E->getArgumentType()).getQuantity(), E);
else
- return Success(GetAlignOfExpr(E->getArgumentExpr()), E);
+ return Success(GetAlignOfExpr(E->getArgumentExpr()).getQuantity(), E);
}
QualType SrcTy = E->getTypeOfArgument();