diff options
author | Sean Callanan <scallanan@apple.com> | 2017-01-09 23:23:25 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2017-01-09 23:23:25 +0000 |
commit | 4d9c5c2280627f3c90882e681459a1df27dfca92 (patch) | |
tree | f2aad56676ea5074b94e8516cdc0bd1dceb0317d /llvm/unittests/Support/AlignOfTest.cpp | |
parent | 47132e5cab08bd1455f308d8f8d459010c7d21bd (diff) | |
download | bcm5719-llvm-4d9c5c2280627f3c90882e681459a1df27dfca92.tar.gz bcm5719-llvm-4d9c5c2280627f3c90882e681459a1df27dfca92.zip |
Lift the 10-type limit for AlignedCharArrayUnion
This patch uses C++11 parameter packs and constexpr functions
to allow AlignedCharArrayUnion to hold an arbitrary number of
types.
Differential Revision: https://reviews.llvm.org/D28429
llvm-svn: 291503
Diffstat (limited to 'llvm/unittests/Support/AlignOfTest.cpp')
-rw-r--r-- | llvm/unittests/Support/AlignOfTest.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/unittests/Support/AlignOfTest.cpp b/llvm/unittests/Support/AlignOfTest.cpp index 388ca11b776..dfcdc1484b3 100644 --- a/llvm/unittests/Support/AlignOfTest.cpp +++ b/llvm/unittests/Support/AlignOfTest.cpp @@ -91,6 +91,24 @@ V8::~V8() {} template <typename M> struct T { M m; }; +typedef uint8_t t1; +typedef uint16_t t2; +typedef uint32_t t3; +typedef uint64_t t4; +typedef int8_t t5; +typedef int16_t t6; +typedef int32_t t7; +typedef int64_t t8; +typedef struct { uint8_t bytes[16]; } t9; +typedef struct { uint16_t words[16]; } t10; +typedef struct { uint32_t words[16]; } t11; +typedef struct { uint64_t words[16]; } t12; + +typedef AlignedCharArrayUnion<t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12> U; + +static_assert(sizeof(U) == sizeof(uint64_t[16]), "Statically-computed size must be right"); +static_assert(alignof(U) == alignof(uint64_t), "Statically-computed alignment must be right"); + TEST(AlignOfTest, BasicAlignedArray) { EXPECT_LE(1u, alignof(AlignedCharArrayUnion<A1>)); EXPECT_LE(2u, alignof(AlignedCharArrayUnion<A2>)); |