]> granicus.if.org Git - clang/commitdiff
Add getTypeAlignInChars() for use in code that works in alignments in character
authorKen Dyck <ken.dyck@onsemi.com>
Tue, 26 Jan 2010 17:22:55 +0000 (17:22 +0000)
committerKen Dyck <ken.dyck@onsemi.com>
Tue, 26 Jan 2010 17:22:55 +0000 (17:22 +0000)
units.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94552 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h
lib/AST/ASTContext.cpp

index e5429bec143c40405f251bc9554ff784260fc76e..0462de3897aa1a8a6f011998660becc022d107f6 100644 (file)
@@ -835,6 +835,11 @@ public:
     return getTypeInfo(T).second;
   }
 
+  /// getTypeAlign - Return the ABI-specified alignment of a type, in 
+  /// characters. This method does not work on incomplete types.
+  CharUnits getTypeAlignInChars(QualType T);
+  CharUnits getTypeAlignInChars(const Type *T);
+
   /// getPreferredTypeAlign - Return the "preferred" alignment of the specified
   /// type for the current target in bits.  This can be different than the ABI
   /// alignment in cases where it is beneficial for performance to overalign
index c1bc70989d4ee88a286aadc1d8e9479c0c965cb8..e5c4381530f586d0ffdd1b7dc2f37b74959bddae 100644 (file)
@@ -820,6 +820,15 @@ CharUnits ASTContext::getTypeSizeInChars(const Type *T) {
   return CharUnits::fromQuantity(getTypeSize(T) / getCharWidth());
 }
 
+/// getTypeAlign - Return the ABI-specified alignment of a type, in 
+/// characters. This method does not work on incomplete types.
+CharUnits ASTContext::getTypeAlignInChars(QualType T) {
+  return CharUnits::fromQuantity(getTypeAlign(T) / getCharWidth());
+}
+CharUnits ASTContext::getTypeAlignInChars(const Type *T) {
+  return CharUnits::fromQuantity(getTypeAlign(T) / getCharWidth());
+}
+
 /// getPreferredTypeAlign - Return the "preferred" alignment of the specified
 /// type for the current target in bits.  This can be different than the ABI
 /// alignment in cases where it is beneficial for performance to overalign