From f5f514477d8a4e04e511d345b9fb896153f70e9d Mon Sep 17 00:00:00 2001 From: Ken Dyck Date: Tue, 24 Nov 2009 12:04:54 +0000 Subject: [PATCH] Add getByteSize() and getTypeSizeInBytes(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89760 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/ASTContext.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 6017ef8d6d..2e2e298ec4 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -795,6 +795,20 @@ public: return getTypeInfo(T).first; } + /// getByteWidth - Return the size of a byte, in bits + uint64_t getByteSize() { + return getTypeSize(CharTy); + } + + /// getTypeSizeInBytes - Return the size of the specified type, in bytes. + /// This method does not work on incomplete types. + uint64_t getTypeSizeInBytes(QualType T) { + return getTypeSize(T) / getByteSize(); + } + uint64_t getTypeSizeInBytes(const Type *T) { + return getTypeSize(T) / getByteSize(); + } + /// getTypeAlign - Return the ABI-specified alignment of a type, in bits. /// This method does not work on incomplete types. unsigned getTypeAlign(QualType T) { -- 2.50.1