[cfe-commits] r91689 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/CodeGen/CGDecl.cpp

Ken Dyck ken.dyck at onsemi.com
Fri Dec 18 07:55:55 PST 2009


Author: kjdyck
Date: Fri Dec 18 09:55:54 2009
New Revision: 91689

URL: http://llvm.org/viewvc/llvm-project?rev=91689&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/CodeGen/CGDecl.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=91689&r1=91688&r2=91689&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Fri Dec 18 09:55:54 2009
@@ -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 @@
   
   /// 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.

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=91689&r1=91688&r2=91689&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Dec 18 09:55:54 2009
@@ -471,7 +471,8 @@
       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)





More information about the cfe-commits mailing list