diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 0b1632f234b3..8e3c3ce2d309 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -946,12 +946,8 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { const QualType ElementType = Type->getAsPointerType()->getPointeeType(); uint64_t D = LHSValue.getLValueOffset() - RHSValue.getLValueOffset(); - uint64_t ElemSize; - if (ElementType->isVoidType() || ElementType->isFunctionType()) - ElemSize = 8; - else - ElemSize = Info.Ctx.getTypeSize(ElementType); - D /= ElemSize / 8; + if (!ElementType->isVoidType() && !ElementType->isFunctionType()) + D /= Info.Ctx.getTypeSize(ElementType) / 8; return Success(D, E); }