Retire llvm::alignOf in favor of C++11 alignof.

No functionality change intended.

llvm-svn: 284733
This commit is contained in:
Benjamin Kramer 2016-10-20 15:02:18 +00:00
parent 5d8cdb83db
commit b2505005c7
25 changed files with 73 additions and 98 deletions

View File

@ -1041,7 +1041,7 @@ private:
public:
explicit IntervalMap(Allocator &a) : height(0), rootSize(0), allocator(a) {
assert((uintptr_t(data.buffer) & (alignOf<RootLeaf>() - 1)) == 0 &&
assert((uintptr_t(data.buffer) & (alignof(RootLeaf) - 1)) == 0 &&
"Insufficient alignment");
new(&rootLeaf()) RootLeaf();
}

View File

@ -157,7 +157,7 @@ public:
// terminator.
unsigned AllocSize = static_cast<unsigned>(sizeof(StringMapEntry))+
KeyLength+1;
unsigned Alignment = alignOf<StringMapEntry>();
unsigned Alignment = alignof(StringMapEntry);
StringMapEntry *NewItem =
static_cast<StringMapEntry*>(Allocator.Allocate(AllocSize,Alignment));

View File

@ -23,7 +23,6 @@
#include "llvm/ADT/IntEqClasses.h"
#include "llvm/CodeGen/SlotIndexes.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include <cassert>

View File

@ -183,7 +183,7 @@ class SelectionDAG {
/// The AllocatorType for allocating SDNodes. We use
/// pool allocation with recycling.
typedef RecyclingAllocator<BumpPtrAllocator, SDNode, sizeof(LargestSDNode),
AlignOf<MostAlignedSDNode>::Alignment>
alignof(MostAlignedSDNode)>
NodeAllocatorType;
/// Pool allocation for nodes.

View File

@ -346,9 +346,8 @@ namespace llvm {
IndexListEntry* createEntry(MachineInstr *mi, unsigned index) {
IndexListEntry *entry =
static_cast<IndexListEntry*>(
ileAllocator.Allocate(sizeof(IndexListEntry),
alignOf<IndexListEntry>()));
static_cast<IndexListEntry *>(ileAllocator.Allocate(
sizeof(IndexListEntry), alignof(IndexListEntry)));
new (entry) IndexListEntry(mi, index);

View File

@ -138,7 +138,7 @@ public:
return T->getTypeID() == FunctionTyID;
}
};
static_assert(AlignOf<FunctionType>::Alignment >= AlignOf<Type *>::Alignment,
static_assert(alignof(FunctionType) >= alignof(Type *),
"Alignment sufficient for objects appended to FunctionType");
bool Type::isFunctionVarArg() const {

View File

@ -22,7 +22,6 @@
#include "llvm/ADT/iterator.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/ErrorHandling.h"
namespace llvm {
@ -250,9 +249,9 @@ public:
}
};
// Either Use objects, or a Use pointer can be prepended to User.
static_assert(AlignOf<Use>::Alignment >= AlignOf<User>::Alignment,
static_assert(alignof(Use) >= alignof(User),
"Alignment is insufficient after objects prepended to User");
static_assert(AlignOf<Use *>::Alignment >= AlignOf<User>::Alignment,
static_assert(alignof(Use *) >= alignof(User),
"Alignment is insufficient after objects prepended to User");
template<> struct simplify_type<User::op_iterator> {

View File

@ -337,7 +337,7 @@ ELFFile<ELFT>::ELFFile(StringRef Object, std::error_code &EC)
return;
}
if (SectionTableOffset & (AlignOf<Elf_Shdr>::Alignment - 1)) {
if (SectionTableOffset & (alignof(Elf_Shdr) - 1)) {
// Invalid address alignment of section headers
EC = object_error::parse_failed;
return;

View File

@ -22,7 +22,6 @@
#define LLVM_SUPPORT_ALLOCATOR_H
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Memory.h"
@ -74,7 +73,7 @@ public:
/// \brief Allocate space for a sequence of objects without constructing them.
template <typename T> T *Allocate(size_t Num = 1) {
return static_cast<T *>(Allocate(Num * sizeof(T), AlignOf<T>::Alignment));
return static_cast<T *>(Allocate(Num * sizeof(T), alignof(T)));
}
/// \brief Deallocate space for a sequence of objects without constructing them.
@ -381,7 +380,7 @@ public:
/// all memory allocated so far.
void DestroyAll() {
auto DestroyElements = [](char *Begin, char *End) {
assert(Begin == (char*)alignAddr(Begin, alignOf<T>()));
assert(Begin == (char *)alignAddr(Begin, alignof(T)));
for (char *Ptr = Begin; Ptr + sizeof(T) <= End; Ptr += sizeof(T))
reinterpret_cast<T *>(Ptr)->~T();
};
@ -390,7 +389,7 @@ public:
++I) {
size_t AllocatedSlabSize = BumpPtrAllocator::computeSlabSize(
std::distance(Allocator.Slabs.begin(), I));
char *Begin = (char*)alignAddr(*I, alignOf<T>());
char *Begin = (char *)alignAddr(*I, alignof(T));
char *End = *I == Allocator.Slabs.back() ? Allocator.CurPtr
: (char *)*I + AllocatedSlabSize;
@ -400,7 +399,7 @@ public:
for (auto &PtrAndSize : Allocator.CustomSizedSlabs) {
void *Ptr = PtrAndSize.first;
size_t Size = PtrAndSize.second;
DestroyElements((char*)alignAddr(Ptr, alignOf<T>()), (char *)Ptr + Size);
DestroyElements((char *)alignAddr(Ptr, alignof(T)), (char *)Ptr + Size);
}
Allocator.Reset();

View File

@ -26,15 +26,14 @@ namespace llvm {
/// Arrays are allocated in a small number of fixed sizes. For each supported
/// array size, the ArrayRecycler keeps a free list of available arrays.
///
template<class T, size_t Align = AlignOf<T>::Alignment>
class ArrayRecycler {
template <class T, size_t Align = alignof(T)> class ArrayRecycler {
// The free list for a given array size is a simple singly linked list.
// We can't use iplist or Recycler here since those classes can't be copied.
struct FreeList {
FreeList *Next;
};
static_assert(Align >= AlignOf<FreeList>::Alignment, "Object underaligned");
static_assert(Align >= alignof(FreeList), "Object underaligned");
static_assert(sizeof(T) >= sizeof(FreeList), "Objects are too small");
// Keep a free list for each array size.

View File

@ -14,7 +14,6 @@
#ifndef LLVM_SUPPORT_ENDIAN_H
#define LLVM_SUPPORT_ENDIAN_H
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/SwapByteOrder.h"
@ -29,7 +28,7 @@ namespace detail {
/// \brief ::value is either alignment, or alignof(T) if alignment is 0.
template<class T, int alignment>
struct PickAlignment {
enum {value = alignment == 0 ? AlignOf<T>::Alignment : alignment};
enum { value = alignment == 0 ? alignof(T) : alignment };
};
} // end namespace detail

View File

@ -14,7 +14,6 @@
#ifndef LLVM_SUPPORT_ONDISKHASHTABLE_H
#define LLVM_SUPPORT_ONDISKHASHTABLE_H
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/EndianStream.h"
@ -208,7 +207,7 @@ public:
// Pad with zeros so that we can start the hashtable at an aligned address.
offset_type TableOff = Out.tell();
uint64_t N = llvm::OffsetToAlignment(TableOff, alignOf<offset_type>());
uint64_t N = llvm::OffsetToAlignment(TableOff, alignof(offset_type));
TableOff += N;
while (N--)
LE.write<uint8_t>(0);

View File

@ -15,8 +15,8 @@
#ifndef LLVM_SUPPORT_POINTERLIKETYPETRAITS_H
#define LLVM_SUPPORT_POINTERLIKETYPETRAITS_H
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/DataTypes.h"
#include <type_traits>
namespace llvm {
@ -42,9 +42,7 @@ public:
static inline void *getAsVoidPointer(T *P) { return P; }
static inline T *getFromVoidPointer(void *P) { return static_cast<T *>(P); }
enum {
NumLowBitsAvailable = detail::ConstantLog2<AlignOf<T>::Alignment>::value
};
enum { NumLowBitsAvailable = detail::ConstantLog2<alignof(T)>::value };
};
template <> class PointerLikeTypeTraits<void *> {

View File

@ -16,7 +16,6 @@
#define LLVM_SUPPORT_RECYCLER_H
#include "llvm/ADT/ilist.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
@ -32,7 +31,7 @@ void PrintRecyclerStats(size_t Size, size_t Align, size_t FreeListSize);
/// and facilitates reusing deallocated memory in place of allocating
/// new memory.
///
template<class T, size_t Size = sizeof(T), size_t Align = AlignOf<T>::Alignment>
template <class T, size_t Size = sizeof(T), size_t Align = alignof(T)>
class Recycler {
struct FreeNode {
FreeNode *Next;
@ -80,7 +79,7 @@ public:
template<class SubClass, class AllocatorType>
SubClass *Allocate(AllocatorType &Allocator) {
static_assert(AlignOf<SubClass>::Alignment <= Align,
static_assert(alignof(SubClass) <= Align,
"Recycler allocation alignment is less than object align!");
static_assert(sizeof(SubClass) <= Size,
"Recycler allocation size is less than object size!");

View File

@ -22,8 +22,8 @@ namespace llvm {
/// RecyclingAllocator - This class wraps an Allocator, adding the
/// functionality of recycling deleted objects.
///
template<class AllocatorType, class T,
size_t Size = sizeof(T), size_t Align = AlignOf<T>::Alignment>
template <class AllocatorType, class T, size_t Size = sizeof(T),
size_t Align = alignof(T)>
class RecyclingAllocator {
private:
/// Base - Implementation details.

View File

@ -62,7 +62,7 @@ namespace trailing_objects_internal {
template <typename First, typename... Rest> class AlignmentCalcHelper {
private:
enum {
FirstAlignment = AlignOf<First>::Alignment,
FirstAlignment = alignof(First),
RestAlignment = AlignmentCalcHelper<Rest...>::Alignment,
};
@ -74,7 +74,7 @@ public:
template <typename First> class AlignmentCalcHelper<First> {
public:
enum { Alignment = AlignOf<First>::Alignment };
enum { Alignment = alignof(First) };
};
/// The base class for TrailingObjects* classes.
@ -143,8 +143,7 @@ class TrailingObjectsImpl<Align, BaseTy, TopTrailingObj, PrevTy, NextTy,
ParentType;
struct RequiresRealignment {
static const bool value =
llvm::AlignOf<PrevTy>::Alignment < llvm::AlignOf<NextTy>::Alignment;
static const bool value = alignof(PrevTy) < alignof(NextTy);
};
static LLVM_CONSTEXPR bool requiresRealignment() {
@ -174,7 +173,7 @@ protected:
if (requiresRealignment())
return reinterpret_cast<const NextTy *>(
llvm::alignAddr(Ptr, llvm::alignOf<NextTy>()));
llvm::alignAddr(Ptr, alignof(NextTy)));
else
return reinterpret_cast<const NextTy *>(Ptr);
}
@ -188,8 +187,7 @@ protected:
Obj, TrailingObjectsBase::OverloadToken<PrevTy>());
if (requiresRealignment())
return reinterpret_cast<NextTy *>(
llvm::alignAddr(Ptr, llvm::alignOf<NextTy>()));
return reinterpret_cast<NextTy *>(llvm::alignAddr(Ptr, alignof(NextTy)));
else
return reinterpret_cast<NextTy *>(Ptr);
}
@ -201,8 +199,7 @@ protected:
size_t SizeSoFar, size_t Count1,
typename ExtractSecondType<MoreTys, size_t>::type... MoreCounts) {
return ParentType::additionalSizeToAllocImpl(
(requiresRealignment()
? llvm::alignTo<llvm::AlignOf<NextTy>::Alignment>(SizeSoFar)
(requiresRealignment() ? llvm::alignTo<alignof(NextTy)>(SizeSoFar)
: SizeSoFar) +
sizeof(NextTy) * Count1,
MoreCounts...);
@ -216,8 +213,7 @@ protected:
static_assert(sizeof...(MoreTys) == sizeof...(MoreCounts),
"Number of counts do not match number of types");
static const size_t value = ParentType::template AdditionalSizeToAllocImpl<
(RequiresRealignment::value
? llvm::AlignTo<llvm::AlignOf<NextTy>::Alignment>::
(RequiresRealignment::value ? llvm::AlignTo<alignof(NextTy)>::
template from_value<SizeSoFar>::value
: SizeSoFar) +
sizeof(NextTy) * Count1,
@ -407,9 +403,7 @@ public:
enum {
Size = TotalSizeToAlloc<Tys...>::template with_counts<Counts...>::value
};
typedef llvm::AlignedCharArray<
llvm::AlignOf<BaseTy>::Alignment, Size
> type;
typedef llvm::AlignedCharArray<alignof(BaseTy), Size> type;
};
};

View File

@ -120,9 +120,8 @@ public:
if (Info->NumPreds == 0)
Info->Preds = nullptr;
else
Info->Preds = static_cast<BBInfo**>
(Allocator.Allocate(Info->NumPreds * sizeof(BBInfo*),
AlignOf<BBInfo*>::Alignment));
Info->Preds = static_cast<BBInfo **>(Allocator.Allocate(
Info->NumPreds * sizeof(BBInfo *), alignof(BBInfo *)));
for (unsigned p = 0; p != Info->NumPreds; ++p) {
BlkT *Pred = Preds[p];

View File

@ -78,7 +78,7 @@ class GlobalsAAResult::FunctionInfo {
return (AlignedMap *)P;
}
enum { NumLowBitsAvailable = 3 };
static_assert(AlignOf<AlignedMap>::Alignment >= (1 << NumLowBitsAvailable),
static_assert(alignof(AlignedMap) >= (1 << NumLowBitsAvailable),
"AlignedMap insufficiently aligned to have enough low bits.");
};

View File

@ -18,7 +18,6 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"

View File

@ -434,7 +434,7 @@ StringRef MDString::getString() const {
// prepended to them.
#define HANDLE_MDNODE_LEAF(CLASS) \
static_assert( \
llvm::AlignOf<uint64_t>::Alignment >= llvm::AlignOf<CLASS>::Alignment, \
alignof(uint64_t) >= alignof(CLASS), \
"Alignment is insufficient after objects prepended to " #CLASS);
#include "llvm/IR/Metadata.def"
@ -442,7 +442,7 @@ void *MDNode::operator new(size_t Size, unsigned NumOps) {
size_t OpSize = NumOps * sizeof(MDOperand);
// uint64_t is the most aligned type we need support (ensured by static_assert
// above)
OpSize = alignTo(OpSize, llvm::alignOf<uint64_t>());
OpSize = alignTo(OpSize, alignof(uint64_t));
void *Ptr = reinterpret_cast<char *>(::operator new(OpSize + Size)) + OpSize;
MDOperand *O = static_cast<MDOperand *>(Ptr);
for (MDOperand *E = O - NumOps; O != E; --O)
@ -453,7 +453,7 @@ void *MDNode::operator new(size_t Size, unsigned NumOps) {
void MDNode::operator delete(void *Mem) {
MDNode *N = static_cast<MDNode *>(Mem);
size_t OpSize = N->NumOperands * sizeof(MDOperand);
OpSize = alignTo(OpSize, llvm::alignOf<uint64_t>());
OpSize = alignTo(OpSize, alignof(uint64_t));
MDOperand *O = static_cast<MDOperand *>(Mem);
for (MDOperand *E = O - N->NumOperands; O != E; --O)

View File

@ -296,9 +296,9 @@ FunctionType *FunctionType::get(Type *ReturnType,
FunctionType *FT;
if (I == pImpl->FunctionTypes.end()) {
FT = (FunctionType*) pImpl->TypeAllocator.
Allocate(sizeof(FunctionType) + sizeof(Type*) * (Params.size() + 1),
AlignOf<FunctionType>::Alignment);
FT = (FunctionType *)pImpl->TypeAllocator.Allocate(
sizeof(FunctionType) + sizeof(Type *) * (Params.size() + 1),
alignof(FunctionType));
new (FT) FunctionType(ReturnType, Params, isVarArg);
pImpl->FunctionTypes.insert(FT);
} else {

View File

@ -43,10 +43,9 @@ void User::replaceUsesOfWith(Value *From, Value *To) {
void User::allocHungoffUses(unsigned N, bool IsPhi) {
assert(HasHungOffUses && "alloc must have hung off uses");
static_assert(AlignOf<Use>::Alignment >= AlignOf<Use::UserRef>::Alignment,
static_assert(alignof(Use) >= alignof(Use::UserRef),
"Alignment is insufficient for 'hung-off-uses' pieces");
static_assert(AlignOf<Use::UserRef>::Alignment >=
AlignOf<BasicBlock *>::Alignment,
static_assert(alignof(Use::UserRef) >= alignof(BasicBlock *),
"Alignment is insufficient for 'hung-off-uses' pieces");
// Allocate the array of Uses, followed by a pointer (with bottom bit set) to

View File

@ -31,10 +31,9 @@ void *MCSymbol::operator new(size_t s, const StringMapEntry<bool> *Name,
// For safety, ensure that the alignment of a pointer is enough for an
// MCSymbol. This also ensures we don't need padding between the name and
// symbol.
static_assert((unsigned)AlignOf<MCSymbol>::Alignment <=
AlignOf<NameEntryStorageTy>::Alignment,
static_assert((unsigned)alignof(MCSymbol) <= alignof(NameEntryStorageTy),
"Bad alignment of MCSymbol");
void *Storage = Ctx.allocate(Size, alignOf<NameEntryStorageTy>());
void *Storage = Ctx.allocate(Size, alignof(NameEntryStorageTy));
NameEntryStorageTy *Start = static_cast<NameEntryStorageTy*>(Storage);
NameEntryStorageTy *End = Start + (Name ? 1 : 0);
return End;

View File

@ -289,7 +289,7 @@ Error RawInstrProfReader<IntPtrT>::readNextHeader(const char *CurrentPos) {
if (CurrentPos + sizeof(RawInstrProf::Header) > End)
return make_error<InstrProfError>(instrprof_error::malformed);
// The writer ensures each profile is padded to start at an aligned address.
if (reinterpret_cast<size_t>(CurrentPos) % alignOf<uint64_t>())
if (reinterpret_cast<size_t>(CurrentPos) % alignof(uint64_t))
return make_error<InstrProfError>(instrprof_error::malformed);
// The magic should have the same byte order as in the previous header.
uint64_t Magic = *reinterpret_cast<const uint64_t *>(CurrentPos);

View File

@ -112,20 +112,16 @@ TEST(TrailingObjects, OneArg) {
EXPECT_EQ(Class1::additionalSizeToAlloc<short>(1), sizeof(short));
EXPECT_EQ(Class1::additionalSizeToAlloc<short>(3), sizeof(short) * 3);
EXPECT_EQ(
llvm::alignOf<Class1>(),
llvm::alignOf<Class1::FixedSizeStorage<short>::with_counts<1>::type>());
EXPECT_EQ(alignof(Class1),
alignof(Class1::FixedSizeStorage<short>::with_counts<1>::type));
EXPECT_EQ(sizeof(Class1::FixedSizeStorage<short>::with_counts<1>::type),
llvm::alignTo(Class1::totalSizeToAlloc<short>(1),
llvm::alignOf<Class1>()));
llvm::alignTo(Class1::totalSizeToAlloc<short>(1), alignof(Class1)));
EXPECT_EQ(Class1::totalSizeToAlloc<short>(1), sizeof(Class1) + sizeof(short));
EXPECT_EQ(
llvm::alignOf<Class1>(),
llvm::alignOf<Class1::FixedSizeStorage<short>::with_counts<3>::type>());
EXPECT_EQ(alignof(Class1),
alignof(Class1::FixedSizeStorage<short>::with_counts<3>::type));
EXPECT_EQ(sizeof(Class1::FixedSizeStorage<short>::with_counts<3>::type),
llvm::alignTo(Class1::totalSizeToAlloc<short>(3),
llvm::alignOf<Class1>()));
llvm::alignTo(Class1::totalSizeToAlloc<short>(3), alignof(Class1)));
EXPECT_EQ(Class1::totalSizeToAlloc<short>(3),
sizeof(Class1) + sizeof(short) * 3);
@ -139,9 +135,8 @@ TEST(TrailingObjects, TwoArg) {
Class2 *C1 = Class2::create(4);
Class2 *C2 = Class2::create(0, 4.2);
EXPECT_EQ(sizeof(Class2),
llvm::alignTo(sizeof(bool) * 2, llvm::alignOf<double>()));
EXPECT_EQ(llvm::alignOf<Class2>(), llvm::alignOf<double>());
EXPECT_EQ(sizeof(Class2), llvm::alignTo(sizeof(bool) * 2, alignof(double)));
EXPECT_EQ(alignof(Class2), alignof(double));
EXPECT_EQ((Class2::additionalSizeToAlloc<double, short>(1, 0)),
sizeof(double));
@ -151,13 +146,13 @@ TEST(TrailingObjects, TwoArg) {
sizeof(double) * 3 + sizeof(short));
EXPECT_EQ(
llvm::alignOf<Class2>(),
(llvm::alignOf<
Class2::FixedSizeStorage<double, short>::with_counts<1, 1>::type>()));
alignof(Class2),
(alignof(
Class2::FixedSizeStorage<double, short>::with_counts<1, 1>::type)));
EXPECT_EQ(
sizeof(Class2::FixedSizeStorage<double, short>::with_counts<1, 1>::type),
llvm::alignTo(Class2::totalSizeToAlloc<double, short>(1, 1),
llvm::alignOf<Class2>()));
alignof(Class2)));
EXPECT_EQ((Class2::totalSizeToAlloc<double, short>(1, 1)),
sizeof(Class2) + sizeof(double) + sizeof(short));
@ -191,16 +186,17 @@ class Class3 final : public TrailingObjects<Class3, double, short, bool> {
TEST(TrailingObjects, ThreeArg) {
EXPECT_EQ((Class3::additionalSizeToAlloc<double, short, bool>(1, 1, 3)),
sizeof(double) + sizeof(short) + 3 * sizeof(bool));
EXPECT_EQ(sizeof(Class3), llvm::alignTo(1, llvm::alignOf<double>()));
EXPECT_EQ(sizeof(Class3), llvm::alignTo(1, alignof(double)));
EXPECT_EQ(llvm::alignOf<Class3>(),
(llvm::alignOf<Class3::FixedSizeStorage<
double, short, bool>::with_counts<1, 1, 3>::type>()));
EXPECT_EQ(
alignof(Class3),
(alignof(Class3::FixedSizeStorage<double, short,
bool>::with_counts<1, 1, 3>::type)));
EXPECT_EQ(
sizeof(Class3::FixedSizeStorage<double, short,
bool>::with_counts<1, 1, 3>::type),
llvm::alignTo(Class3::totalSizeToAlloc<double, short, bool>(1, 1, 3),
llvm::alignOf<Class3>()));
alignof(Class3)));
std::unique_ptr<char[]> P(new char[1000]);
Class3 *C = reinterpret_cast<Class3 *>(P.get());
@ -221,23 +217,22 @@ class Class4 final : public TrailingObjects<Class4, char, long> {
TEST(TrailingObjects, Realignment) {
EXPECT_EQ((Class4::additionalSizeToAlloc<char, long>(1, 1)),
llvm::alignTo(sizeof(long) + 1, llvm::alignOf<long>()));
EXPECT_EQ(sizeof(Class4), llvm::alignTo(1, llvm::alignOf<long>()));
llvm::alignTo(sizeof(long) + 1, alignof(long)));
EXPECT_EQ(sizeof(Class4), llvm::alignTo(1, alignof(long)));
EXPECT_EQ(
llvm::alignOf<Class4>(),
(llvm::alignOf<
Class4::FixedSizeStorage<char, long>::with_counts<1, 1>::type>()));
alignof(Class4),
(alignof(Class4::FixedSizeStorage<char, long>::with_counts<1, 1>::type)));
EXPECT_EQ(
sizeof(Class4::FixedSizeStorage<char, long>::with_counts<1, 1>::type),
llvm::alignTo(Class4::totalSizeToAlloc<char, long>(1, 1),
llvm::alignOf<Class4>()));
alignof(Class4)));
std::unique_ptr<char[]> P(new char[1000]);
Class4 *C = reinterpret_cast<Class4 *>(P.get());
EXPECT_EQ(C->getTrailingObjects<char>(), reinterpret_cast<char *>(C + 1));
EXPECT_EQ(C->getTrailingObjects<long>(),
reinterpret_cast<long *>(llvm::alignAddr(
reinterpret_cast<char *>(C + 1) + 1, llvm::alignOf<long>())));
reinterpret_cast<char *>(C + 1) + 1, alignof(long))));
}
}