From e2fc01ea8d682187df2026c5ffd6fdd2425b2ad2 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 17 Oct 2007 22:08:55 +0000 Subject: 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 --- include/llvm/Support/AlignOf.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/AlignOf.h b/include/llvm/Support/AlignOf.h index f27ecdd..0911bb8 100644 --- a/include/llvm/Support/AlignOf.h +++ b/include/llvm/Support/AlignOf.h @@ -38,6 +38,13 @@ template struct AlignOf { enum { Alignment = sizeof(AlignmentCalcImpl) - 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() returns the alignment of an int. +template +static inline unsigned alignof() { return AlignOf::Alignment; } } // end namespace llvm #endif -- cgit v1.1