aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Dyck <ken.dyck@onsemi.com>2010-01-26 17:22:55 +0000
committerKen Dyck <ken.dyck@onsemi.com>2010-01-26 17:22:55 +0000
commit86fa4311c8a330957ff5b765fbb0a7750ecd38c9 (patch)
tree40556394b70295cd631fa8464a06269655cf0f4c
parentfc8ea23eb6cbaaa5046f2abb4c033e24c8659efd (diff)
Add getTypeAlignInChars() for use in code that works in alignments in character
units. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94552 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ASTContext.h5
-rw-r--r--lib/AST/ASTContext.cpp9
2 files changed, 14 insertions, 0 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index e5429bec14..0462de3897 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -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
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index c1bc70989d..e5c4381530 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -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