summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorKen Dyck <kd@kendyck.com>2011-02-11 01:54:29 +0000
committerKen Dyck <kd@kendyck.com>2011-02-11 01:54:29 +0000
commitb0fcc59e19508dca2dc809fb5c83e19c4d3e9ffc (patch)
tree50f55aa851f434ae67dabbb02ed0ac6c21b5f2fe /clang/lib/AST/ASTContext.cpp
parenta759d72d7b00328077328306dae142c9c97a57e2 (diff)
downloadbcm5719-llvm-b0fcc59e19508dca2dc809fb5c83e19c4d3e9ffc.tar.gz
bcm5719-llvm-b0fcc59e19508dca2dc809fb5c83e19c4d3e9ffc.zip
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. llvm-svn: 125332
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r--clang/lib/AST/ASTContext.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 6b267432586..03c0abd3c62 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -847,7 +847,7 @@ ASTContext::getTypeInfo(const Type *T) const {
case Type::ObjCInterface: {
const ObjCInterfaceType *ObjCI = cast<ObjCInterfaceType>(T);
const ASTRecordLayout &Layout = getASTObjCInterfaceLayout(ObjCI->getDecl());
- Width = Layout.getSize().getQuantity() * getCharWidth();
+ Width = toBits(Layout.getSize());
Align = Layout.getAlignment();
break;
}
@@ -866,7 +866,7 @@ ASTContext::getTypeInfo(const Type *T) const {
const RecordType *RT = cast<RecordType>(TT);
const ASTRecordLayout &Layout = getASTRecordLayout(RT->getDecl());
- Width = Layout.getSize().getQuantity() * getCharWidth();
+ Width = toBits(Layout.getSize());
Align = Layout.getAlignment();
break;
}
@@ -923,6 +923,11 @@ CharUnits ASTContext::toCharUnitsFromBits(int64_t BitSize) const {
return CharUnits::fromQuantity(BitSize / getCharWidth());
}
+/// toBits - Convert a size in characters to a size in characters.
+int64_t ASTContext::toBits(CharUnits CharSize) const {
+ return CharSize.getQuantity() * getCharWidth();
+}
+
/// getTypeSizeInChars - Return the size of the specified type, in characters.
/// This method does not work on incomplete types.
CharUnits ASTContext::getTypeSizeInChars(QualType T) const {
OpenPOWER on IntegriCloud