Change the return type of ASTContext::getTypeSizeInChars() from uint64_t to the

new opaque value type, CharUnits. This will help us avoid accidentally mixing 
quantities that are in bit and character units.

llvm-svn: 91689
This commit is contained in:
Ken Dyck 2009-12-18 15:55:54 +00:00
parent acfe6aa83a
commit 01e620efaa
2 changed files with 7 additions and 5 deletions

View File

@ -18,6 +18,7 @@
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/OperatorKinds.h"
#include "clang/AST/Attr.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/Decl.h"
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/PrettyPrinter.h"
@ -819,11 +820,11 @@ public:
/// getTypeSizeInChars - Return the size of the specified type, in characters.
/// This method does not work on incomplete types.
uint64_t getTypeSizeInChars(QualType T) {
return getTypeSize(T) / getCharWidth();
CharUnits getTypeSizeInChars(QualType T) {
return CharUnits::fromRaw(getTypeSize(T) / getCharWidth());
}
uint64_t getTypeSizeInChars(const Type *T) {
return getTypeSize(T) / getCharWidth();
CharUnits getTypeSizeInChars(const Type *T) {
return CharUnits::fromRaw(getTypeSize(T) / getCharWidth());
}
/// getTypeAlign - Return the ABI-specified alignment of a type, in bits.

View File

@ -471,7 +471,8 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
const llvm::Type *IntPtr =
llvm::IntegerType::get(VMContext, LLVMPointerWidth);
llvm::Value *SizeVal =
llvm::ConstantInt::get(IntPtr, getContext().getTypeSizeInChars(Ty));
llvm::ConstantInt::get(IntPtr,
getContext().getTypeSizeInChars(Ty).getRaw());
const llvm::Type *BP = llvm::Type::getInt8PtrTy(VMContext);
if (Loc->getType() != BP)