summaryrefslogtreecommitdiff
path: root/include/llvm/Support/AlignOf.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-10-17 22:08:55 +0000
committerTed Kremenek <kremenek@apple.com>2007-10-17 22:08:55 +0000
commit87f3870db9d92eca87e2f42c3537efe4bfb6e9c2 (patch)
treeaab66a2ffb5ffb152b779f43836f7da4fbb88233 /include/llvm/Support/AlignOf.h
parent774577c1f97ec2d659ac5c35c238dd0952f7f45f (diff)
downloadllvm-87f3870db9d92eca87e2f42c3537efe4bfb6e9c2.tar.gz
llvm-87f3870db9d92eca87e2f42c3537efe4bfb6e9c2.tar.bz2
llvm-87f3870db9d92eca87e2f42c3537efe4bfb6e9c2.tar.xz
Added template function alignof() which provides a clean
function-based interface to getting the alignment of a type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43096 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/AlignOf.h')
-rw-r--r--include/llvm/Support/AlignOf.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/Support/AlignOf.h b/include/llvm/Support/AlignOf.h
index f27ecdd713..0911bb84b3 100644
--- a/include/llvm/Support/AlignOf.h
+++ b/include/llvm/Support/AlignOf.h
@@ -38,6 +38,13 @@ template <typename T>
struct AlignOf {
enum { Alignment = sizeof(AlignmentCalcImpl<T>) - sizeof(T) };
};
+
+/// alignof - A templated function that returns the mininum alignment of
+/// of a type. This provides no extra functionality beyond the AlignOf
+/// class besides some cosmetic cleanliness. Example usage:
+/// alignof<int>() returns the alignment of an int.
+template <typename T>
+static inline unsigned alignof() { return AlignOf<T>::Alignment; }
} // end namespace llvm
#endif