]> granicus.if.org Git - clang/commitdiff
Add getByteSize() and getTypeSizeInBytes().
authorKen Dyck <ken.dyck@onsemi.com>
Tue, 24 Nov 2009 12:04:54 +0000 (12:04 +0000)
committerKen Dyck <ken.dyck@onsemi.com>
Tue, 24 Nov 2009 12:04:54 +0000 (12:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89760 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h

index 6017ef8d6d7668ef3f017aab6935d10cf14e7781..2e2e298ec421f6ff9f9e3d70f014907e46fa0e1b 100644 (file)
@@ -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) {