diff options
author | Ken Dyck <kd@kendyck.com> | 2011-02-11 01:54:29 +0000 |
---|---|---|
committer | Ken Dyck <kd@kendyck.com> | 2011-02-11 01:54:29 +0000 |
commit | dd76a9ab9ea675671200f94b18ce95766841952b (patch) | |
tree | 12945459f4e5250a0888bb4956ebb68cc66c70be /lib/CodeGen/CGRecordLayoutBuilder.cpp | |
parent | 0e376a0ca8372c9e809d08a9db2fae98394878b8 (diff) |
Add a helper function, ASTContext::toBits(), that converts sizes in
CharUnits to sizes in bits, and use it to tidy up the places where the
conversion was done explicitly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125332 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGRecordLayoutBuilder.cpp')
-rw-r--r-- | lib/CodeGen/CGRecordLayoutBuilder.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index af0c9ed499..4d928409a2 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -300,8 +300,7 @@ CGBitFieldInfo CGBitFieldInfo::MakeInfo(CodeGenTypes &Types, uint64_t FieldSize) { const RecordDecl *RD = FD->getParent(); const ASTRecordLayout &RL = Types.getContext().getASTRecordLayout(RD); - uint64_t ContainingTypeSizeInBits = - RL.getSize().getQuantity() * Types.getContext().getCharWidth(); + uint64_t ContainingTypeSizeInBits = Types.getContext().toBits(RL.getSize()); unsigned ContainingTypeAlign = RL.getAlignment(); return MakeInfo(Types, FD, FieldOffset, FieldSize, ContainingTypeSizeInBits, @@ -689,8 +688,7 @@ bool CGRecordLayoutBuilder::LayoutFields(const RecordDecl *D) { } // Append tail padding if necessary. - AppendTailPadding( - Layout.getSize().getQuantity() * Types.getContext().getCharWidth()); + AppendTailPadding(Types.getContext().toBits(Layout.getSize())); return true; } @@ -855,8 +853,7 @@ CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D) { // Verify that the computed LLVM struct size matches the AST layout size. const ASTRecordLayout &Layout = getContext().getASTRecordLayout(D); - uint64_t TypeSizeInBits = - Layout.getSize().getQuantity() * getContext().getCharWidth(); + uint64_t TypeSizeInBits = getContext().toBits(Layout.getSize()); assert(TypeSizeInBits == getTargetData().getTypeAllocSizeInBits(Ty) && "Type size mismatch!"); @@ -867,7 +864,7 @@ CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D) { NonVirtualSize.RoundUpToAlignment(NonVirtualAlign); uint64_t AlignedNonVirtualTypeSizeInBits = - AlignedNonVirtualTypeSize.getQuantity() * getContext().getCharWidth(); + getContext().toBits(AlignedNonVirtualTypeSize); assert(AlignedNonVirtualTypeSizeInBits == getTargetData().getTypeAllocSizeInBits(BaseTy) && |