diff options
author | Ken Dyck <ken.dyck@onsemi.com> | 2009-12-18 15:55:54 +0000 |
---|---|---|
committer | Ken Dyck <ken.dyck@onsemi.com> | 2009-12-18 15:55:54 +0000 |
commit | 4273f7068f16863f2469b45a3f00c3b4217bdbb4 (patch) | |
tree | b43028fc841ebed93c8af9116acb66ffa5670910 | |
parent | cc906ef220c9be2644ad942457766d46a0b3651e (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91689 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/ASTContext.h | 9 | ||||
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 96861b5a2a..617a019baf 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -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. diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 3db3eefc1e..72dc8373ca 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -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) |