summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Dyck <kd@kendyck.com>2011-04-22 17:34:18 +0000
committerKen Dyck <kd@kendyck.com>2011-04-22 17:34:18 +0000
commit8159c1f2dff119aab4702ec65ef3a46259e73dd2 (patch)
tree12ff7d89aad0c30a831a9240c0f7b632d97a9aab
parentabae3beec585e887244411eb2313c1a5c92a7af1 (diff)
downloadbcm5719-llvm-8159c1f2dff119aab4702ec65ef3a46259e73dd2.tar.gz
bcm5719-llvm-8159c1f2dff119aab4702ec65ef3a46259e73dd2.zip
Use CharUnits to eliminate some literal 8s in
EmitTypeForVarWithBlocksAttr(). No change in functionality intended. llvm-svn: 129998
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 65b1ffb591f..8a3cf6c515d 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1797,15 +1797,17 @@ llvm::DIType CGDebugInfo::EmitTypeForVarWithBlocksAttr(const ValueDecl *VD,
}
CharUnits Align = CGM.getContext().getDeclAlign(VD);
- if (Align > CharUnits::fromQuantity(
- CGM.getContext().Target.getPointerAlign(0) / 8)) {
- unsigned AlignedOffsetInBytes
- = llvm::RoundUpToAlignment(FieldOffset/8, Align.getQuantity());
- unsigned NumPaddingBytes
- = AlignedOffsetInBytes - FieldOffset/8;
+ if (Align > CGM.getContext().toCharUnitsFromBits(
+ CGM.getContext().Target.getPointerAlign(0))) {
+ CharUnits FieldOffsetInBytes
+ = CGM.getContext().toCharUnitsFromBits(FieldOffset);
+ CharUnits AlignedOffsetInBytes
+ = FieldOffsetInBytes.RoundUpToAlignment(Align);
+ CharUnits NumPaddingBytes
+ = AlignedOffsetInBytes - FieldOffsetInBytes;
- if (NumPaddingBytes > 0) {
- llvm::APInt pad(32, NumPaddingBytes);
+ if (NumPaddingBytes.isPositive()) {
+ llvm::APInt pad(32, NumPaddingBytes.getQuantity());
FType = CGM.getContext().getConstantArrayType(CGM.getContext().CharTy,
pad, ArrayType::Normal, 0);
EltTys.push_back(CreateMemberType(Unit, FType, "", &FieldOffset));
@@ -1815,7 +1817,7 @@ llvm::DIType CGDebugInfo::EmitTypeForVarWithBlocksAttr(const ValueDecl *VD,
FType = Type;
llvm::DIType FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
FieldSize = CGM.getContext().getTypeSize(FType);
- FieldAlign = Align.getQuantity()*8;
+ FieldAlign = CGM.getContext().toBits(Align);
*XOffset = FieldOffset;
FieldTy = DBuilder.createMemberType(VD->getName(), Unit,
OpenPOWER on IntegriCloud