From: Ken Dyck Date: Tue, 22 Mar 2011 00:24:31 +0000 (+0000) Subject: Eliminate some literal '8's in FillInNullDataMemberPointers() by switching X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c4d68db1397b1c1a0a2fb33464dc65f9c51aec09;p=clang Eliminate some literal '8's in FillInNullDataMemberPointers() by switching to CharUnits. No change in functionality intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128047 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index c5d4a658c6..ce25dc7ac5 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -1035,7 +1035,8 @@ static void FillInNullDataMemberPointers(CodeGenModule &CGM, QualType T, std::vector &Elements, uint64_t StartOffset) { - assert(StartOffset % 8 == 0 && "StartOffset not byte aligned!"); + assert(StartOffset % CGM.getContext().getCharWidth() == 0 && + "StartOffset not byte aligned!"); if (CGM.getTypes().isZeroInitializable(T)) return; @@ -1094,8 +1095,8 @@ FillInNullDataMemberPointers(CodeGenModule &CGM, QualType T, assert(!T->getAs()->getPointeeType()->isFunctionType() && "Should only see pointers to data members here!"); - uint64_t StartIndex = StartOffset / 8; - uint64_t EndIndex = StartIndex + CGM.getContext().getTypeSize(T) / 8; + CharUnits StartIndex = CGM.getContext().toCharUnitsFromBits(StartOffset); + CharUnits EndIndex = StartIndex + CGM.getContext().getTypeSizeInChars(T); // FIXME: hardcodes Itanium member pointer representation! llvm::Constant *NegativeOne = @@ -1103,8 +1104,8 @@ FillInNullDataMemberPointers(CodeGenModule &CGM, QualType T, -1ULL, /*isSigned*/true); // Fill in the null data member pointer. - for (uint64_t I = StartIndex; I != EndIndex; ++I) - Elements[I] = NegativeOne; + for (CharUnits I = StartIndex; I != EndIndex; ++I) + Elements[I.getQuantity()] = NegativeOne; } }