mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-14 15:19:33 +00:00
[Support] Remove llvm::alignOf now that all uses are gone.
Also clean up the legacy hacks for AlignedCharArray. I'm keeping LLVM_ALIGNAS alive for a bit longer because GCC 4.8.0 (which we still support apparently) shipped a buggy alignas(). All other supported compilers have a working alignas. llvm-svn: 284736
This commit is contained in:
parent
7999e6045a
commit
b471938ca6
@ -7,8 +7,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the AlignOf function that computes alignments for
|
||||
// arbitrary types.
|
||||
// This file defines the AlignedCharArray and AlignedCharArrayUnion classes.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@ -17,204 +16,19 @@
|
||||
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
namespace detail {
|
||||
|
||||
// For everything other than an abstract class we can calulate alignment by
|
||||
// building a class with a single character and a member of the given type.
|
||||
template <typename T, bool = std::is_abstract<T>::value>
|
||||
struct AlignmentCalcImpl {
|
||||
char x;
|
||||
#if defined(_MSC_VER)
|
||||
// Disables "structure was padded due to __declspec(align())" warnings that are
|
||||
// generated by any class using AlignOf<T> with a manually specified alignment.
|
||||
// Although the warning is disabled in the LLVM project we need this pragma
|
||||
// as AlignOf.h is a published support header that's available for use
|
||||
// out-of-tree, and we would like that to compile cleanly at /W4.
|
||||
#pragma warning(suppress : 4324)
|
||||
#endif
|
||||
T t;
|
||||
private:
|
||||
AlignmentCalcImpl() = delete;
|
||||
};
|
||||
|
||||
// Abstract base class helper, this will have the minimal alignment and size
|
||||
// for any abstract class. We don't even define its destructor because this
|
||||
// type should never be used in a way that requires it.
|
||||
struct AlignmentCalcImplBase {
|
||||
virtual ~AlignmentCalcImplBase() = 0;
|
||||
};
|
||||
|
||||
// When we have an abstract class type, specialize the alignment computation
|
||||
// engine to create another abstract class that derives from both an empty
|
||||
// abstract base class and the provided type. This has the same effect as the
|
||||
// above except that it handles the fact that we can't actually create a member
|
||||
// of type T.
|
||||
template <typename T>
|
||||
struct AlignmentCalcImpl<T, true> : AlignmentCalcImplBase, T {
|
||||
~AlignmentCalcImpl() override = 0;
|
||||
};
|
||||
|
||||
} // End detail namespace.
|
||||
|
||||
/// AlignOf - A templated class that contains an enum value representing
|
||||
/// the alignment of the template argument. For example,
|
||||
/// AlignOf<int>::Alignment represents the alignment of type "int". The
|
||||
/// alignment calculated is the minimum alignment, and not necessarily
|
||||
/// the "desired" alignment returned by GCC's __alignof__ (for example). Note
|
||||
/// that because the alignment is an enum value, it can be used as a
|
||||
/// compile-time constant (e.g., for template instantiation).
|
||||
template <typename T>
|
||||
struct AlignOf {
|
||||
#ifndef _MSC_VER
|
||||
// Avoid warnings from GCC like:
|
||||
// comparison between 'enum llvm::AlignOf<X>::<anonymous>' and 'enum
|
||||
// llvm::AlignOf<Y>::<anonymous>' [-Wenum-compare]
|
||||
// by using constexpr instead of enum.
|
||||
// (except on MSVC, since it doesn't support constexpr yet).
|
||||
static constexpr unsigned Alignment = static_cast<unsigned int>(
|
||||
sizeof(detail::AlignmentCalcImpl<T>) - sizeof(T));
|
||||
#else
|
||||
enum {
|
||||
Alignment = static_cast<unsigned int>(
|
||||
sizeof(::llvm::detail::AlignmentCalcImpl<T>) - sizeof(T))
|
||||
};
|
||||
#endif
|
||||
enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 };
|
||||
enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 };
|
||||
enum { Alignment_GreaterEqual_8Bytes = Alignment >= 8 ? 1 : 0 };
|
||||
enum { Alignment_GreaterEqual_16Bytes = Alignment >= 16 ? 1 : 0 };
|
||||
|
||||
enum { Alignment_LessEqual_2Bytes = Alignment <= 2 ? 1 : 0 };
|
||||
enum { Alignment_LessEqual_4Bytes = Alignment <= 4 ? 1 : 0 };
|
||||
enum { Alignment_LessEqual_8Bytes = Alignment <= 8 ? 1 : 0 };
|
||||
enum { Alignment_LessEqual_16Bytes = Alignment <= 16 ? 1 : 0 };
|
||||
};
|
||||
|
||||
#ifndef _MSC_VER
|
||||
template <typename T> constexpr unsigned AlignOf<T>::Alignment;
|
||||
#endif
|
||||
|
||||
/// alignOf - A templated function that returns the minimum 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>
|
||||
LLVM_CONSTEXPR inline unsigned alignOf() { return AlignOf<T>::Alignment; }
|
||||
|
||||
/// \struct AlignedCharArray
|
||||
/// \brief Helper for building an aligned character array type.
|
||||
///
|
||||
/// This template is used to explicitly build up a collection of aligned
|
||||
/// character array types. We have to build these up using a macro and explicit
|
||||
/// specialization to cope with old versions of MSVC and GCC where only an
|
||||
/// integer literal can be used to specify an alignment constraint. Once built
|
||||
/// up here, we can then begin to indirect between these using normal C++
|
||||
/// template parameters.
|
||||
|
||||
// MSVC requires special handling here.
|
||||
#ifndef _MSC_VER
|
||||
|
||||
#if __has_feature(cxx_alignas)
|
||||
/// character array types.
|
||||
template<std::size_t Alignment, std::size_t Size>
|
||||
struct AlignedCharArray {
|
||||
alignas(Alignment) char buffer[Size];
|
||||
LLVM_ALIGNAS(Alignment) char buffer[Size];
|
||||
};
|
||||
|
||||
#elif defined(__GNUC__) || defined(__IBM_ATTRIBUTES)
|
||||
/// \brief Create a type with an aligned char buffer.
|
||||
template<std::size_t Alignment, std::size_t Size>
|
||||
struct AlignedCharArray;
|
||||
|
||||
#define LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \
|
||||
template<std::size_t Size> \
|
||||
struct AlignedCharArray<x, Size> { \
|
||||
__attribute__((aligned(x))) char buffer[Size]; \
|
||||
};
|
||||
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1)
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2)
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4)
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8)
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(16)
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(32)
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(64)
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(128)
|
||||
|
||||
#undef LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT
|
||||
|
||||
#else
|
||||
# error No supported align as directive.
|
||||
#endif
|
||||
|
||||
#else // _MSC_VER
|
||||
|
||||
/// \brief Create a type with an aligned char buffer.
|
||||
template<std::size_t Alignment, std::size_t Size>
|
||||
struct AlignedCharArray;
|
||||
|
||||
// We provide special variations of this template for the most common
|
||||
// alignments because __declspec(align(...)) doesn't actually work when it is
|
||||
// a member of a by-value function argument in MSVC, even if the alignment
|
||||
// request is something reasonably like 8-byte or 16-byte. Note that we can't
|
||||
// even include the declspec with the union that forces the alignment because
|
||||
// MSVC warns on the existence of the declspec despite the union member forcing
|
||||
// proper alignment.
|
||||
|
||||
template<std::size_t Size>
|
||||
struct AlignedCharArray<1, Size> {
|
||||
union {
|
||||
char aligned;
|
||||
char buffer[Size];
|
||||
};
|
||||
};
|
||||
|
||||
template<std::size_t Size>
|
||||
struct AlignedCharArray<2, Size> {
|
||||
union {
|
||||
short aligned;
|
||||
char buffer[Size];
|
||||
};
|
||||
};
|
||||
|
||||
template<std::size_t Size>
|
||||
struct AlignedCharArray<4, Size> {
|
||||
union {
|
||||
int aligned;
|
||||
char buffer[Size];
|
||||
};
|
||||
};
|
||||
|
||||
template<std::size_t Size>
|
||||
struct AlignedCharArray<8, Size> {
|
||||
union {
|
||||
double aligned;
|
||||
char buffer[Size];
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// The rest of these are provided with a __declspec(align(...)) and we simply
|
||||
// can't pass them by-value as function arguments on MSVC.
|
||||
|
||||
#define LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \
|
||||
template<std::size_t Size> \
|
||||
struct AlignedCharArray<x, Size> { \
|
||||
__declspec(align(x)) char buffer[Size]; \
|
||||
};
|
||||
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(16)
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(32)
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(64)
|
||||
LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(128)
|
||||
|
||||
#undef LLVM_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
||||
namespace detail {
|
||||
template <typename T1,
|
||||
typename T2 = char, typename T3 = char, typename T4 = char,
|
||||
@ -249,8 +63,8 @@ template <typename T1,
|
||||
typename T5 = char, typename T6 = char, typename T7 = char,
|
||||
typename T8 = char, typename T9 = char, typename T10 = char>
|
||||
struct AlignedCharArrayUnion : llvm::AlignedCharArray<
|
||||
AlignOf<llvm::detail::AlignerImpl<T1, T2, T3, T4, T5,
|
||||
T6, T7, T8, T9, T10> >::Alignment,
|
||||
alignof(llvm::detail::AlignerImpl<T1, T2, T3, T4, T5,
|
||||
T6, T7, T8, T9, T10>),
|
||||
sizeof(::llvm::detail::SizerImpl<T1, T2, T3, T4, T5,
|
||||
T6, T7, T8, T9, T10>)> {
|
||||
};
|
||||
|
@ -325,15 +325,8 @@
|
||||
#endif
|
||||
|
||||
/// \macro LLVM_ALIGNAS
|
||||
/// \brief Used to specify a minimum alignment for a structure or variable. The
|
||||
/// alignment must be a constant integer. Use LLVM_PTR_SIZE to compute
|
||||
/// alignments in terms of the size of a pointer.
|
||||
///
|
||||
/// Note that __declspec(align) has special quirks, it's not legal to pass a
|
||||
/// structure with __declspec(align) as a formal parameter.
|
||||
#ifdef _MSC_VER
|
||||
# define LLVM_ALIGNAS(x) __declspec(align(x))
|
||||
#elif __GNUC__ && !__has_feature(cxx_alignas) && !LLVM_GNUC_PREREQ(4, 8, 0)
|
||||
/// \brief Used to specify a minimum alignment for a structure or variable.
|
||||
#if __GNUC__ && !__has_feature(cxx_alignas) && !LLVM_GNUC_PREREQ(4, 8, 1)
|
||||
# define LLVM_ALIGNAS(x) __attribute__((aligned(x)))
|
||||
#else
|
||||
# define LLVM_ALIGNAS(x) alignas(x)
|
||||
|
@ -89,140 +89,31 @@ V6::~V6() {}
|
||||
V7::~V7() {}
|
||||
V8::~V8() {}
|
||||
|
||||
struct Abstract1 {
|
||||
virtual ~Abstract1() {}
|
||||
virtual void method() = 0;
|
||||
|
||||
char c;
|
||||
};
|
||||
|
||||
struct Abstract2 : Abstract1 {
|
||||
~Abstract2() override = default;
|
||||
double d;
|
||||
};
|
||||
|
||||
struct Final final : Abstract2 {
|
||||
void method() override {}
|
||||
};
|
||||
|
||||
// Ensure alignment is a compile-time constant.
|
||||
char LLVM_ATTRIBUTE_UNUSED test_arr1
|
||||
[AlignOf<char>::Alignment > 0]
|
||||
[AlignOf<short>::Alignment > 0]
|
||||
[AlignOf<int>::Alignment > 0]
|
||||
[AlignOf<long>::Alignment > 0]
|
||||
[AlignOf<long long>::Alignment > 0]
|
||||
[AlignOf<float>::Alignment > 0]
|
||||
[AlignOf<double>::Alignment > 0]
|
||||
[AlignOf<long double>::Alignment > 0]
|
||||
[AlignOf<void *>::Alignment > 0]
|
||||
[AlignOf<int *>::Alignment > 0]
|
||||
[AlignOf<double (*)(double)>::Alignment > 0]
|
||||
[AlignOf<double (S6::*)()>::Alignment > 0];
|
||||
char LLVM_ATTRIBUTE_UNUSED test_arr2
|
||||
[AlignOf<A1>::Alignment > 0]
|
||||
[AlignOf<A2>::Alignment > 0]
|
||||
[AlignOf<A4>::Alignment > 0]
|
||||
[AlignOf<A8>::Alignment > 0];
|
||||
char LLVM_ATTRIBUTE_UNUSED test_arr3
|
||||
[AlignOf<S1>::Alignment > 0]
|
||||
[AlignOf<S2>::Alignment > 0]
|
||||
[AlignOf<S3>::Alignment > 0]
|
||||
[AlignOf<S4>::Alignment > 0]
|
||||
[AlignOf<S5>::Alignment > 0]
|
||||
[AlignOf<S6>::Alignment > 0];
|
||||
char LLVM_ATTRIBUTE_UNUSED test_arr4
|
||||
[AlignOf<D1>::Alignment > 0]
|
||||
[AlignOf<D2>::Alignment > 0]
|
||||
[AlignOf<D3>::Alignment > 0]
|
||||
[AlignOf<D4>::Alignment > 0]
|
||||
[AlignOf<D5>::Alignment > 0]
|
||||
[AlignOf<D6>::Alignment > 0]
|
||||
[AlignOf<D7>::Alignment > 0]
|
||||
[AlignOf<D8>::Alignment > 0]
|
||||
[AlignOf<D9>::Alignment > 0];
|
||||
char LLVM_ATTRIBUTE_UNUSED test_arr5
|
||||
[AlignOf<V1>::Alignment > 0]
|
||||
[AlignOf<V2>::Alignment > 0]
|
||||
[AlignOf<V3>::Alignment > 0]
|
||||
[AlignOf<V4>::Alignment > 0]
|
||||
[AlignOf<V5>::Alignment > 0]
|
||||
[AlignOf<V6>::Alignment > 0]
|
||||
[AlignOf<V7>::Alignment > 0]
|
||||
[AlignOf<V8>::Alignment > 0];
|
||||
|
||||
TEST(AlignOfTest, BasicAlignmentInvariants) {
|
||||
EXPECT_LE(1u, alignOf<A1>());
|
||||
EXPECT_LE(2u, alignOf<A2>());
|
||||
EXPECT_LE(4u, alignOf<A4>());
|
||||
EXPECT_LE(8u, alignOf<A8>());
|
||||
|
||||
EXPECT_EQ(1u, alignOf<char>());
|
||||
EXPECT_LE(alignOf<char>(), alignOf<short>());
|
||||
EXPECT_LE(alignOf<short>(), alignOf<int>());
|
||||
EXPECT_LE(alignOf<int>(), alignOf<long>());
|
||||
EXPECT_LE(alignOf<long>(), alignOf<long long>());
|
||||
EXPECT_LE(alignOf<char>(), alignOf<float>());
|
||||
EXPECT_LE(alignOf<float>(), alignOf<double>());
|
||||
EXPECT_LE(alignOf<char>(), alignOf<long double>());
|
||||
EXPECT_LE(alignOf<char>(), alignOf<void *>());
|
||||
EXPECT_EQ(alignOf<void *>(), alignOf<int *>());
|
||||
EXPECT_LE(alignOf<char>(), alignOf<S1>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<S2>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<S3>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<S4>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<S5>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<S6>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<D1>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<D2>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<D3>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<D4>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<D5>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<D6>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<D7>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<D8>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<D9>());
|
||||
EXPECT_LE(alignOf<S1>(), alignOf<V1>());
|
||||
EXPECT_LE(alignOf<V1>(), alignOf<V2>());
|
||||
EXPECT_LE(alignOf<V1>(), alignOf<V3>());
|
||||
EXPECT_LE(alignOf<V1>(), alignOf<V4>());
|
||||
EXPECT_LE(alignOf<V1>(), alignOf<V5>());
|
||||
EXPECT_LE(alignOf<V1>(), alignOf<V6>());
|
||||
EXPECT_LE(alignOf<V1>(), alignOf<V7>());
|
||||
EXPECT_LE(alignOf<V1>(), alignOf<V8>());
|
||||
|
||||
EXPECT_LE(alignOf<char>(), alignOf<Abstract1>());
|
||||
EXPECT_LE(alignOf<double>(), alignOf<Abstract2>());
|
||||
EXPECT_LE(alignOf<Abstract2>(), alignOf<Final>());
|
||||
}
|
||||
|
||||
TEST(AlignOfTest, BasicAlignedArray) {
|
||||
EXPECT_LE(1u, alignOf<AlignedCharArrayUnion<A1> >());
|
||||
EXPECT_LE(2u, alignOf<AlignedCharArrayUnion<A2> >());
|
||||
EXPECT_LE(4u, alignOf<AlignedCharArrayUnion<A4> >());
|
||||
EXPECT_LE(8u, alignOf<AlignedCharArrayUnion<A8> >());
|
||||
EXPECT_LE(1u, alignof(AlignedCharArrayUnion<A1>));
|
||||
EXPECT_LE(2u, alignof(AlignedCharArrayUnion<A2>));
|
||||
EXPECT_LE(4u, alignof(AlignedCharArrayUnion<A4>));
|
||||
EXPECT_LE(8u, alignof(AlignedCharArrayUnion<A8>));
|
||||
|
||||
EXPECT_LE(1u, sizeof(AlignedCharArrayUnion<A1>));
|
||||
EXPECT_LE(2u, sizeof(AlignedCharArrayUnion<A2>));
|
||||
EXPECT_LE(4u, sizeof(AlignedCharArrayUnion<A4>));
|
||||
EXPECT_LE(8u, sizeof(AlignedCharArrayUnion<A8>));
|
||||
|
||||
EXPECT_EQ(1u, (alignOf<AlignedCharArrayUnion<A1> >()));
|
||||
EXPECT_EQ(2u, (alignOf<AlignedCharArrayUnion<A1, A2> >()));
|
||||
EXPECT_EQ(4u, (alignOf<AlignedCharArrayUnion<A1, A2, A4> >()));
|
||||
EXPECT_EQ(8u, (alignOf<AlignedCharArrayUnion<A1, A2, A4, A8> >()));
|
||||
EXPECT_EQ(1u, (alignof(AlignedCharArrayUnion<A1>)));
|
||||
EXPECT_EQ(2u, (alignof(AlignedCharArrayUnion<A1, A2>)));
|
||||
EXPECT_EQ(4u, (alignof(AlignedCharArrayUnion<A1, A2, A4>)));
|
||||
EXPECT_EQ(8u, (alignof(AlignedCharArrayUnion<A1, A2, A4, A8>)));
|
||||
|
||||
EXPECT_EQ(1u, sizeof(AlignedCharArrayUnion<A1>));
|
||||
EXPECT_EQ(2u, sizeof(AlignedCharArrayUnion<A1, A2>));
|
||||
EXPECT_EQ(4u, sizeof(AlignedCharArrayUnion<A1, A2, A4>));
|
||||
EXPECT_EQ(8u, sizeof(AlignedCharArrayUnion<A1, A2, A4, A8>));
|
||||
|
||||
EXPECT_EQ(1u, (alignOf<AlignedCharArrayUnion<A1[1]> >()));
|
||||
EXPECT_EQ(2u, (alignOf<AlignedCharArrayUnion<A1[2], A2[1]> >()));
|
||||
EXPECT_EQ(4u, (alignOf<AlignedCharArrayUnion<A1[42], A2[55],
|
||||
A4[13]> >()));
|
||||
EXPECT_EQ(8u, (alignOf<AlignedCharArrayUnion<A1[2], A2[1],
|
||||
A4, A8> >()));
|
||||
EXPECT_EQ(1u, (alignof(AlignedCharArrayUnion<A1[1]>)));
|
||||
EXPECT_EQ(2u, (alignof(AlignedCharArrayUnion<A1[2], A2[1]>)));
|
||||
EXPECT_EQ(4u, (alignof(AlignedCharArrayUnion<A1[42], A2[55], A4[13]>)));
|
||||
EXPECT_EQ(8u, (alignof(AlignedCharArrayUnion<A1[2], A2[1], A4, A8>)));
|
||||
|
||||
EXPECT_EQ(1u, sizeof(AlignedCharArrayUnion<A1[1]>));
|
||||
EXPECT_EQ(2u, sizeof(AlignedCharArrayUnion<A1[2], A2[1]>));
|
||||
@ -233,49 +124,47 @@ TEST(AlignOfTest, BasicAlignedArray) {
|
||||
// For other tests we simply assert that the alignment of the union mathes
|
||||
// that of the fundamental type and hope that we have any weird type
|
||||
// productions that would trigger bugs.
|
||||
EXPECT_EQ(alignOf<char>(), alignOf<AlignedCharArrayUnion<char> >());
|
||||
EXPECT_EQ(alignOf<short>(), alignOf<AlignedCharArrayUnion<short> >());
|
||||
EXPECT_EQ(alignOf<int>(), alignOf<AlignedCharArrayUnion<int> >());
|
||||
EXPECT_EQ(alignOf<long>(), alignOf<AlignedCharArrayUnion<long> >());
|
||||
EXPECT_EQ(alignOf<long long>(),
|
||||
alignOf<AlignedCharArrayUnion<long long> >());
|
||||
EXPECT_EQ(alignOf<float>(), alignOf<AlignedCharArrayUnion<float> >());
|
||||
EXPECT_EQ(alignOf<double>(), alignOf<AlignedCharArrayUnion<double> >());
|
||||
EXPECT_EQ(alignOf<long double>(),
|
||||
alignOf<AlignedCharArrayUnion<long double> >());
|
||||
EXPECT_EQ(alignOf<void *>(), alignOf<AlignedCharArrayUnion<void *> >());
|
||||
EXPECT_EQ(alignOf<int *>(), alignOf<AlignedCharArrayUnion<int *> >());
|
||||
EXPECT_EQ(alignOf<double (*)(double)>(),
|
||||
alignOf<AlignedCharArrayUnion<double (*)(double)> >());
|
||||
EXPECT_EQ(alignOf<double (S6::*)()>(),
|
||||
alignOf<AlignedCharArrayUnion<double (S6::*)()> >());
|
||||
EXPECT_EQ(alignOf<S1>(), alignOf<AlignedCharArrayUnion<S1> >());
|
||||
EXPECT_EQ(alignOf<S2>(), alignOf<AlignedCharArrayUnion<S2> >());
|
||||
EXPECT_EQ(alignOf<S3>(), alignOf<AlignedCharArrayUnion<S3> >());
|
||||
EXPECT_EQ(alignOf<S4>(), alignOf<AlignedCharArrayUnion<S4> >());
|
||||
EXPECT_EQ(alignOf<S5>(), alignOf<AlignedCharArrayUnion<S5> >());
|
||||
EXPECT_EQ(alignOf<S6>(), alignOf<AlignedCharArrayUnion<S6> >());
|
||||
EXPECT_EQ(alignOf<D1>(), alignOf<AlignedCharArrayUnion<D1> >());
|
||||
EXPECT_EQ(alignOf<D2>(), alignOf<AlignedCharArrayUnion<D2> >());
|
||||
EXPECT_EQ(alignOf<D3>(), alignOf<AlignedCharArrayUnion<D3> >());
|
||||
EXPECT_EQ(alignOf<D4>(), alignOf<AlignedCharArrayUnion<D4> >());
|
||||
EXPECT_EQ(alignOf<D5>(), alignOf<AlignedCharArrayUnion<D5> >());
|
||||
EXPECT_EQ(alignOf<D6>(), alignOf<AlignedCharArrayUnion<D6> >());
|
||||
EXPECT_EQ(alignOf<D7>(), alignOf<AlignedCharArrayUnion<D7> >());
|
||||
EXPECT_EQ(alignOf<D8>(), alignOf<AlignedCharArrayUnion<D8> >());
|
||||
EXPECT_EQ(alignOf<D9>(), alignOf<AlignedCharArrayUnion<D9> >());
|
||||
EXPECT_EQ(alignOf<V1>(), alignOf<AlignedCharArrayUnion<V1> >());
|
||||
EXPECT_EQ(alignOf<V2>(), alignOf<AlignedCharArrayUnion<V2> >());
|
||||
EXPECT_EQ(alignOf<V3>(), alignOf<AlignedCharArrayUnion<V3> >());
|
||||
EXPECT_EQ(alignOf<V4>(), alignOf<AlignedCharArrayUnion<V4> >());
|
||||
EXPECT_EQ(alignOf<V5>(), alignOf<AlignedCharArrayUnion<V5> >());
|
||||
EXPECT_EQ(alignOf<V6>(), alignOf<AlignedCharArrayUnion<V6> >());
|
||||
EXPECT_EQ(alignOf<V7>(), alignOf<AlignedCharArrayUnion<V7> >());
|
||||
EXPECT_EQ(alignof(char), alignof(AlignedCharArrayUnion<char>));
|
||||
EXPECT_EQ(alignof(short), alignof(AlignedCharArrayUnion<short>));
|
||||
EXPECT_EQ(alignof(int), alignof(AlignedCharArrayUnion<int>));
|
||||
EXPECT_EQ(alignof(long), alignof(AlignedCharArrayUnion<long>));
|
||||
EXPECT_EQ(alignof(long long), alignof(AlignedCharArrayUnion<long long>));
|
||||
EXPECT_EQ(alignof(float), alignof(AlignedCharArrayUnion<float>));
|
||||
EXPECT_EQ(alignof(double), alignof(AlignedCharArrayUnion<double>));
|
||||
EXPECT_EQ(alignof(long double), alignof(AlignedCharArrayUnion<long double>));
|
||||
EXPECT_EQ(alignof(void *), alignof(AlignedCharArrayUnion<void *>));
|
||||
EXPECT_EQ(alignof(int *), alignof(AlignedCharArrayUnion<int *>));
|
||||
EXPECT_EQ(alignof(double (*)(double)),
|
||||
alignof(AlignedCharArrayUnion<double (*)(double)>));
|
||||
EXPECT_EQ(alignof(double (S6::*)()),
|
||||
alignof(AlignedCharArrayUnion<double (S6::*)()>));
|
||||
EXPECT_EQ(alignof(S1), alignof(AlignedCharArrayUnion<S1>));
|
||||
EXPECT_EQ(alignof(S2), alignof(AlignedCharArrayUnion<S2>));
|
||||
EXPECT_EQ(alignof(S3), alignof(AlignedCharArrayUnion<S3>));
|
||||
EXPECT_EQ(alignof(S4), alignof(AlignedCharArrayUnion<S4>));
|
||||
EXPECT_EQ(alignof(S5), alignof(AlignedCharArrayUnion<S5>));
|
||||
EXPECT_EQ(alignof(S6), alignof(AlignedCharArrayUnion<S6>));
|
||||
EXPECT_EQ(alignof(D1), alignof(AlignedCharArrayUnion<D1>));
|
||||
EXPECT_EQ(alignof(D2), alignof(AlignedCharArrayUnion<D2>));
|
||||
EXPECT_EQ(alignof(D3), alignof(AlignedCharArrayUnion<D3>));
|
||||
EXPECT_EQ(alignof(D4), alignof(AlignedCharArrayUnion<D4>));
|
||||
EXPECT_EQ(alignof(D5), alignof(AlignedCharArrayUnion<D5>));
|
||||
EXPECT_EQ(alignof(D6), alignof(AlignedCharArrayUnion<D6>));
|
||||
EXPECT_EQ(alignof(D7), alignof(AlignedCharArrayUnion<D7>));
|
||||
EXPECT_EQ(alignof(D8), alignof(AlignedCharArrayUnion<D8>));
|
||||
EXPECT_EQ(alignof(D9), alignof(AlignedCharArrayUnion<D9>));
|
||||
EXPECT_EQ(alignof(V1), alignof(AlignedCharArrayUnion<V1>));
|
||||
EXPECT_EQ(alignof(V2), alignof(AlignedCharArrayUnion<V2>));
|
||||
EXPECT_EQ(alignof(V3), alignof(AlignedCharArrayUnion<V3>));
|
||||
EXPECT_EQ(alignof(V4), alignof(AlignedCharArrayUnion<V4>));
|
||||
EXPECT_EQ(alignof(V5), alignof(AlignedCharArrayUnion<V5>));
|
||||
EXPECT_EQ(alignof(V6), alignof(AlignedCharArrayUnion<V6>));
|
||||
EXPECT_EQ(alignof(V7), alignof(AlignedCharArrayUnion<V7>));
|
||||
|
||||
// Some versions of MSVC get this wrong somewhat disturbingly. The failure
|
||||
// appears to be benign: alignOf<V8>() produces a preposterous value: 12
|
||||
// appears to be benign: alignof(V8) produces a preposterous value: 12
|
||||
#ifndef _MSC_VER
|
||||
EXPECT_EQ(alignOf<V8>(), alignOf<AlignedCharArrayUnion<V8> >());
|
||||
EXPECT_EQ(alignof(V8), alignof(AlignedCharArrayUnion<V8>));
|
||||
#endif
|
||||
|
||||
EXPECT_EQ(sizeof(char), sizeof(AlignedCharArrayUnion<char>));
|
||||
@ -343,11 +232,11 @@ TEST(AlignOfTest, BasicAlignedArray) {
|
||||
EXPECT_EQ(sizeof(V8), sizeof(AlignedCharArrayUnion<V8>));
|
||||
#endif
|
||||
|
||||
EXPECT_EQ(1u, (alignOf<AlignedCharArray<1, 1> >()));
|
||||
EXPECT_EQ(2u, (alignOf<AlignedCharArray<2, 1> >()));
|
||||
EXPECT_EQ(4u, (alignOf<AlignedCharArray<4, 1> >()));
|
||||
EXPECT_EQ(8u, (alignOf<AlignedCharArray<8, 1> >()));
|
||||
EXPECT_EQ(16u, (alignOf<AlignedCharArray<16, 1> >()));
|
||||
EXPECT_EQ(1u, (alignof(AlignedCharArray<1, 1>)));
|
||||
EXPECT_EQ(2u, (alignof(AlignedCharArray<2, 1>)));
|
||||
EXPECT_EQ(4u, (alignof(AlignedCharArray<4, 1>)));
|
||||
EXPECT_EQ(8u, (alignof(AlignedCharArray<8, 1>)));
|
||||
EXPECT_EQ(16u, (alignof(AlignedCharArray<16, 1>)));
|
||||
|
||||
EXPECT_EQ(1u, sizeof(AlignedCharArray<1, 1>));
|
||||
EXPECT_EQ(7u, sizeof(AlignedCharArray<1, 7>));
|
||||
|
Loading…
Reference in New Issue
Block a user