[cfe-commits] r94552 - in /cfe/trunk:	include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp
    Ken Dyck 
    ken.dyck at onsemi.com
       
    Tue Jan 26 09:22:55 PST 2010
    
    
  
Author: kjdyck
Date: Tue Jan 26 11:22:55 2010
New Revision: 94552
URL: http://llvm.org/viewvc/llvm-project?rev=94552&view=rev
Log:
Add getTypeAlignInChars() for use in code that works in alignments in character
units.
Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=94552&r1=94551&r2=94552&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Jan 26 11:22:55 2010
@@ -835,6 +835,11 @@
     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
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=94552&r1=94551&r2=94552&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jan 26 11:22:55 2010
@@ -820,6 +820,15 @@
   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
    
    
More information about the cfe-commits
mailing list