1 //===--- AlignOf.h - Portable calculation of type alignment -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Ted Kremenek and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the AlignOf function that computes alignments for
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_SUPPORT_ALIGNOF_H
16 #define LLVM_SUPPORT_ALIGNOF_H
23 struct AlignmentCalcImpl {
27 AlignmentCalcImpl() {} // Never instantiate.
30 /// AlignOf - A templated class that contains an enum value representing
31 /// the alignment of the template argument. For example,
32 /// AlignOf<int>::Alignment represents the alignment of type "int". The
33 /// alignment calculated is the minimum alignment, and not necessarily
34 /// the "desired" alignment returned by GCC's __alignof__ (for example). Note
35 /// that because the alignment is an enum value, it can be used as a
36 /// compile-time constant (e.g., for template instantiation).
39 enum { Alignment = sizeof(AlignmentCalcImpl<T>) - sizeof(T) };
42 } // end namespace llvm