diff --git a/llvm/include/llvm/ADT/IntervalMap.h b/llvm/include/llvm/ADT/IntervalMap.h index f8843b2a4e50..cd721f8e7838 100644 --- a/llvm/include/llvm/ADT/IntervalMap.h +++ b/llvm/include/llvm/ADT/IntervalMap.h @@ -1041,7 +1041,7 @@ private: public: explicit IntervalMap(Allocator &a) : height(0), rootSize(0), allocator(a) { - assert((uintptr_t(data.buffer) & (alignOf() - 1)) == 0 && + assert((uintptr_t(data.buffer) & (alignof(RootLeaf) - 1)) == 0 && "Insufficient alignment"); new(&rootLeaf()) RootLeaf(); } diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h index 5c048b174dc2..8bb7ef05b969 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h @@ -157,7 +157,7 @@ public: // terminator. unsigned AllocSize = static_cast(sizeof(StringMapEntry))+ KeyLength+1; - unsigned Alignment = alignOf(); + unsigned Alignment = alignof(StringMapEntry); StringMapEntry *NewItem = static_cast(Allocator.Allocate(AllocSize,Alignment)); diff --git a/llvm/include/llvm/CodeGen/LiveInterval.h b/llvm/include/llvm/CodeGen/LiveInterval.h index 278bd7644835..b3e72dc54635 100644 --- a/llvm/include/llvm/CodeGen/LiveInterval.h +++ b/llvm/include/llvm/CodeGen/LiveInterval.h @@ -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 diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h index 4367bf10ce3e..6cc1f5095fa4 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -183,8 +183,8 @@ class SelectionDAG { /// The AllocatorType for allocating SDNodes. We use /// pool allocation with recycling. typedef RecyclingAllocator::Alignment> - NodeAllocatorType; + alignof(MostAlignedSDNode)> + NodeAllocatorType; /// Pool allocation for nodes. NodeAllocatorType NodeAllocator; diff --git a/llvm/include/llvm/CodeGen/SlotIndexes.h b/llvm/include/llvm/CodeGen/SlotIndexes.h index f6cacae9ea01..984b5f3eed49 100644 --- a/llvm/include/llvm/CodeGen/SlotIndexes.h +++ b/llvm/include/llvm/CodeGen/SlotIndexes.h @@ -346,9 +346,8 @@ namespace llvm { IndexListEntry* createEntry(MachineInstr *mi, unsigned index) { IndexListEntry *entry = - static_cast( - ileAllocator.Allocate(sizeof(IndexListEntry), - alignOf())); + static_cast(ileAllocator.Allocate( + sizeof(IndexListEntry), alignof(IndexListEntry))); new (entry) IndexListEntry(mi, index); diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h index a59049b22e84..7459d06f56dd 100644 --- a/llvm/include/llvm/IR/DerivedTypes.h +++ b/llvm/include/llvm/IR/DerivedTypes.h @@ -138,7 +138,7 @@ public: return T->getTypeID() == FunctionTyID; } }; -static_assert(AlignOf::Alignment >= AlignOf::Alignment, +static_assert(alignof(FunctionType) >= alignof(Type *), "Alignment sufficient for objects appended to FunctionType"); bool Type::isFunctionVarArg() const { diff --git a/llvm/include/llvm/IR/User.h b/llvm/include/llvm/IR/User.h index 4d6b30cd1124..c628c82cbedf 100644 --- a/llvm/include/llvm/IR/User.h +++ b/llvm/include/llvm/IR/User.h @@ -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::Alignment >= AlignOf::Alignment, +static_assert(alignof(Use) >= alignof(User), "Alignment is insufficient after objects prepended to User"); -static_assert(AlignOf::Alignment >= AlignOf::Alignment, +static_assert(alignof(Use *) >= alignof(User), "Alignment is insufficient after objects prepended to User"); template<> struct simplify_type { diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index b7ae00121770..7aee6b175745 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -337,7 +337,7 @@ ELFFile::ELFFile(StringRef Object, std::error_code &EC) return; } - if (SectionTableOffset & (AlignOf::Alignment - 1)) { + if (SectionTableOffset & (alignof(Elf_Shdr) - 1)) { // Invalid address alignment of section headers EC = object_error::parse_failed; return; diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h index 1c9508661d6f..023c94cb663a 100644 --- a/llvm/include/llvm/Support/Allocator.h +++ b/llvm/include/llvm/Support/Allocator.h @@ -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 T *Allocate(size_t Num = 1) { - return static_cast(Allocate(Num * sizeof(T), AlignOf::Alignment)); + return static_cast(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())); + assert(Begin == (char *)alignAddr(Begin, alignof(T))); for (char *Ptr = Begin; Ptr + sizeof(T) <= End; Ptr += sizeof(T)) reinterpret_cast(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()); + 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()), (char *)Ptr + Size); + DestroyElements((char *)alignAddr(Ptr, alignof(T)), (char *)Ptr + Size); } Allocator.Reset(); diff --git a/llvm/include/llvm/Support/ArrayRecycler.h b/llvm/include/llvm/Support/ArrayRecycler.h index 36f644af2880..4698f12b3bbc 100644 --- a/llvm/include/llvm/Support/ArrayRecycler.h +++ b/llvm/include/llvm/Support/ArrayRecycler.h @@ -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::Alignment> -class ArrayRecycler { +template 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::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. diff --git a/llvm/include/llvm/Support/Endian.h b/llvm/include/llvm/Support/Endian.h index cb5cd8e511b1..cbe3d67b1f9e 100644 --- a/llvm/include/llvm/Support/Endian.h +++ b/llvm/include/llvm/Support/Endian.h @@ -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 struct PickAlignment { - enum {value = alignment == 0 ? AlignOf::Alignment : alignment}; + enum { value = alignment == 0 ? alignof(T) : alignment }; }; } // end namespace detail diff --git a/llvm/include/llvm/Support/OnDiskHashTable.h b/llvm/include/llvm/Support/OnDiskHashTable.h index c28fcabe78fc..e9c28daf03b9 100644 --- a/llvm/include/llvm/Support/OnDiskHashTable.h +++ b/llvm/include/llvm/Support/OnDiskHashTable.h @@ -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()); + uint64_t N = llvm::OffsetToAlignment(TableOff, alignof(offset_type)); TableOff += N; while (N--) LE.write(0); diff --git a/llvm/include/llvm/Support/PointerLikeTypeTraits.h b/llvm/include/llvm/Support/PointerLikeTypeTraits.h index 96cdaed142c2..9ff894edbeb0 100644 --- a/llvm/include/llvm/Support/PointerLikeTypeTraits.h +++ b/llvm/include/llvm/Support/PointerLikeTypeTraits.h @@ -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 namespace llvm { @@ -42,9 +42,7 @@ public: static inline void *getAsVoidPointer(T *P) { return P; } static inline T *getFromVoidPointer(void *P) { return static_cast(P); } - enum { - NumLowBitsAvailable = detail::ConstantLog2::Alignment>::value - }; + enum { NumLowBitsAvailable = detail::ConstantLog2::value }; }; template <> class PointerLikeTypeTraits { diff --git a/llvm/include/llvm/Support/Recycler.h b/llvm/include/llvm/Support/Recycler.h index a38050d81903..1523aad38d46 100644 --- a/llvm/include/llvm/Support/Recycler.h +++ b/llvm/include/llvm/Support/Recycler.h @@ -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 @@ -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::Alignment> +template class Recycler { struct FreeNode { FreeNode *Next; @@ -80,7 +79,7 @@ public: template SubClass *Allocate(AllocatorType &Allocator) { - static_assert(AlignOf::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!"); diff --git a/llvm/include/llvm/Support/RecyclingAllocator.h b/llvm/include/llvm/Support/RecyclingAllocator.h index 001d1cf7c3df..32b033b17946 100644 --- a/llvm/include/llvm/Support/RecyclingAllocator.h +++ b/llvm/include/llvm/Support/RecyclingAllocator.h @@ -22,8 +22,8 @@ namespace llvm { /// RecyclingAllocator - This class wraps an Allocator, adding the /// functionality of recycling deleted objects. /// -template::Alignment> +template class RecyclingAllocator { private: /// Base - Implementation details. diff --git a/llvm/include/llvm/Support/TrailingObjects.h b/llvm/include/llvm/Support/TrailingObjects.h index 427ae1cb3f60..316307ac762b 100644 --- a/llvm/include/llvm/Support/TrailingObjects.h +++ b/llvm/include/llvm/Support/TrailingObjects.h @@ -62,7 +62,7 @@ namespace trailing_objects_internal { template class AlignmentCalcHelper { private: enum { - FirstAlignment = AlignOf::Alignment, + FirstAlignment = alignof(First), RestAlignment = AlignmentCalcHelper::Alignment, }; @@ -74,7 +74,7 @@ public: template class AlignmentCalcHelper { public: - enum { Alignment = AlignOf::Alignment }; + enum { Alignment = alignof(First) }; }; /// The base class for TrailingObjects* classes. @@ -143,8 +143,7 @@ class TrailingObjectsImpl::Alignment < llvm::AlignOf::Alignment; + static const bool value = alignof(PrevTy) < alignof(NextTy); }; static LLVM_CONSTEXPR bool requiresRealignment() { @@ -174,7 +173,7 @@ protected: if (requiresRealignment()) return reinterpret_cast( - llvm::alignAddr(Ptr, llvm::alignOf())); + llvm::alignAddr(Ptr, alignof(NextTy))); else return reinterpret_cast(Ptr); } @@ -188,8 +187,7 @@ protected: Obj, TrailingObjectsBase::OverloadToken()); if (requiresRealignment()) - return reinterpret_cast( - llvm::alignAddr(Ptr, llvm::alignOf())); + return reinterpret_cast(llvm::alignAddr(Ptr, alignof(NextTy))); else return reinterpret_cast(Ptr); } @@ -201,9 +199,8 @@ protected: size_t SizeSoFar, size_t Count1, typename ExtractSecondType::type... MoreCounts) { return ParentType::additionalSizeToAllocImpl( - (requiresRealignment() - ? llvm::alignTo::Alignment>(SizeSoFar) - : SizeSoFar) + + (requiresRealignment() ? llvm::alignTo(SizeSoFar) + : SizeSoFar) + sizeof(NextTy) * Count1, MoreCounts...); } @@ -216,10 +213,9 @@ 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::Alignment>:: - template from_value::value - : SizeSoFar) + + (RequiresRealignment::value ? llvm::AlignTo:: + template from_value::value + : SizeSoFar) + sizeof(NextTy) * Count1, MoreCounts...>::value; }; @@ -407,9 +403,7 @@ public: enum { Size = TotalSizeToAlloc::template with_counts::value }; - typedef llvm::AlignedCharArray< - llvm::AlignOf::Alignment, Size - > type; + typedef llvm::AlignedCharArray type; }; }; diff --git a/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h b/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h index b5f4ac82b605..b0448fed9f4d 100644 --- a/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h +++ b/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h @@ -120,9 +120,8 @@ public: if (Info->NumPreds == 0) Info->Preds = nullptr; else - Info->Preds = static_cast - (Allocator.Allocate(Info->NumPreds * sizeof(BBInfo*), - AlignOf::Alignment)); + Info->Preds = static_cast(Allocator.Allocate( + Info->NumPreds * sizeof(BBInfo *), alignof(BBInfo *))); for (unsigned p = 0; p != Info->NumPreds; ++p) { BlkT *Pred = Preds[p]; diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp index d29b9703e9c1..a0fa181518dc 100644 --- a/llvm/lib/Analysis/GlobalsModRef.cpp +++ b/llvm/lib/Analysis/GlobalsModRef.cpp @@ -78,7 +78,7 @@ class GlobalsAAResult::FunctionInfo { return (AlignedMap *)P; } enum { NumLowBitsAvailable = 3 }; - static_assert(AlignOf::Alignment >= (1 << NumLowBitsAvailable), + static_assert(alignof(AlignedMap) >= (1 << NumLowBitsAvailable), "AlignedMap insufficiently aligned to have enough low bits."); }; diff --git a/llvm/lib/CodeGen/MachineSSAUpdater.cpp b/llvm/lib/CodeGen/MachineSSAUpdater.cpp index 47ad60c5dd56..e9b47559309f 100644 --- a/llvm/lib/CodeGen/MachineSSAUpdater.cpp +++ b/llvm/lib/CodeGen/MachineSSAUpdater.cpp @@ -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" diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index 3e07b3a7c948..17aa1216b3ee 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -434,7 +434,7 @@ StringRef MDString::getString() const { // prepended to them. #define HANDLE_MDNODE_LEAF(CLASS) \ static_assert( \ - llvm::AlignOf::Alignment >= llvm::AlignOf::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()); + OpSize = alignTo(OpSize, alignof(uint64_t)); void *Ptr = reinterpret_cast(::operator new(OpSize + Size)) + OpSize; MDOperand *O = static_cast(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(Mem); size_t OpSize = N->NumOperands * sizeof(MDOperand); - OpSize = alignTo(OpSize, llvm::alignOf()); + OpSize = alignTo(OpSize, alignof(uint64_t)); MDOperand *O = static_cast(Mem); for (MDOperand *E = O - N->NumOperands; O != E; --O) diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp index 5c97a4ea0705..700f93917141 100644 --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -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::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 { diff --git a/llvm/lib/IR/User.cpp b/llvm/lib/IR/User.cpp index a75abe6938c9..497b4aa17643 100644 --- a/llvm/lib/IR/User.cpp +++ b/llvm/lib/IR/User.cpp @@ -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::Alignment >= AlignOf::Alignment, + static_assert(alignof(Use) >= alignof(Use::UserRef), "Alignment is insufficient for 'hung-off-uses' pieces"); - static_assert(AlignOf::Alignment >= - AlignOf::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 diff --git a/llvm/lib/MC/MCSymbol.cpp b/llvm/lib/MC/MCSymbol.cpp index 52f053238bca..20d985df7ea0 100644 --- a/llvm/lib/MC/MCSymbol.cpp +++ b/llvm/lib/MC/MCSymbol.cpp @@ -31,10 +31,9 @@ void *MCSymbol::operator new(size_t s, const StringMapEntry *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::Alignment <= - AlignOf::Alignment, + static_assert((unsigned)alignof(MCSymbol) <= alignof(NameEntryStorageTy), "Bad alignment of MCSymbol"); - void *Storage = Ctx.allocate(Size, alignOf()); + void *Storage = Ctx.allocate(Size, alignof(NameEntryStorageTy)); NameEntryStorageTy *Start = static_cast(Storage); NameEntryStorageTy *End = Start + (Name ? 1 : 0); return End; diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp index ed927a98604d..ad407f07957f 100644 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -289,7 +289,7 @@ Error RawInstrProfReader::readNextHeader(const char *CurrentPos) { if (CurrentPos + sizeof(RawInstrProf::Header) > End) return make_error(instrprof_error::malformed); // The writer ensures each profile is padded to start at an aligned address. - if (reinterpret_cast(CurrentPos) % alignOf()) + if (reinterpret_cast(CurrentPos) % alignof(uint64_t)) return make_error(instrprof_error::malformed); // The magic should have the same byte order as in the previous header. uint64_t Magic = *reinterpret_cast(CurrentPos); diff --git a/llvm/unittests/Support/TrailingObjectsTest.cpp b/llvm/unittests/Support/TrailingObjectsTest.cpp index 65fdcb93623c..cb5c47d1b25b 100644 --- a/llvm/unittests/Support/TrailingObjectsTest.cpp +++ b/llvm/unittests/Support/TrailingObjectsTest.cpp @@ -112,20 +112,16 @@ TEST(TrailingObjects, OneArg) { EXPECT_EQ(Class1::additionalSizeToAlloc(1), sizeof(short)); EXPECT_EQ(Class1::additionalSizeToAlloc(3), sizeof(short) * 3); - EXPECT_EQ( - llvm::alignOf(), - llvm::alignOf::with_counts<1>::type>()); + EXPECT_EQ(alignof(Class1), + alignof(Class1::FixedSizeStorage::with_counts<1>::type)); EXPECT_EQ(sizeof(Class1::FixedSizeStorage::with_counts<1>::type), - llvm::alignTo(Class1::totalSizeToAlloc(1), - llvm::alignOf())); + llvm::alignTo(Class1::totalSizeToAlloc(1), alignof(Class1))); EXPECT_EQ(Class1::totalSizeToAlloc(1), sizeof(Class1) + sizeof(short)); - EXPECT_EQ( - llvm::alignOf(), - llvm::alignOf::with_counts<3>::type>()); + EXPECT_EQ(alignof(Class1), + alignof(Class1::FixedSizeStorage::with_counts<3>::type)); EXPECT_EQ(sizeof(Class1::FixedSizeStorage::with_counts<3>::type), - llvm::alignTo(Class1::totalSizeToAlloc(3), - llvm::alignOf())); + llvm::alignTo(Class1::totalSizeToAlloc(3), alignof(Class1))); EXPECT_EQ(Class1::totalSizeToAlloc(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())); - EXPECT_EQ(llvm::alignOf(), llvm::alignOf()); + EXPECT_EQ(sizeof(Class2), llvm::alignTo(sizeof(bool) * 2, alignof(double))); + EXPECT_EQ(alignof(Class2), alignof(double)); EXPECT_EQ((Class2::additionalSizeToAlloc(1, 0)), sizeof(double)); @@ -151,13 +146,13 @@ TEST(TrailingObjects, TwoArg) { sizeof(double) * 3 + sizeof(short)); EXPECT_EQ( - llvm::alignOf(), - (llvm::alignOf< - Class2::FixedSizeStorage::with_counts<1, 1>::type>())); + alignof(Class2), + (alignof( + Class2::FixedSizeStorage::with_counts<1, 1>::type))); EXPECT_EQ( sizeof(Class2::FixedSizeStorage::with_counts<1, 1>::type), llvm::alignTo(Class2::totalSizeToAlloc(1, 1), - llvm::alignOf())); + alignof(Class2))); EXPECT_EQ((Class2::totalSizeToAlloc(1, 1)), sizeof(Class2) + sizeof(double) + sizeof(short)); @@ -191,16 +186,17 @@ class Class3 final : public TrailingObjects { TEST(TrailingObjects, ThreeArg) { EXPECT_EQ((Class3::additionalSizeToAlloc(1, 1, 3)), sizeof(double) + sizeof(short) + 3 * sizeof(bool)); - EXPECT_EQ(sizeof(Class3), llvm::alignTo(1, llvm::alignOf())); + EXPECT_EQ(sizeof(Class3), llvm::alignTo(1, alignof(double))); - EXPECT_EQ(llvm::alignOf(), - (llvm::alignOf::with_counts<1, 1, 3>::type>())); + EXPECT_EQ( + alignof(Class3), + (alignof(Class3::FixedSizeStorage::with_counts<1, 1, 3>::type))); EXPECT_EQ( sizeof(Class3::FixedSizeStorage::with_counts<1, 1, 3>::type), llvm::alignTo(Class3::totalSizeToAlloc(1, 1, 3), - llvm::alignOf())); + alignof(Class3))); std::unique_ptr P(new char[1000]); Class3 *C = reinterpret_cast(P.get()); @@ -221,23 +217,22 @@ class Class4 final : public TrailingObjects { TEST(TrailingObjects, Realignment) { EXPECT_EQ((Class4::additionalSizeToAlloc(1, 1)), - llvm::alignTo(sizeof(long) + 1, llvm::alignOf())); - EXPECT_EQ(sizeof(Class4), llvm::alignTo(1, llvm::alignOf())); + llvm::alignTo(sizeof(long) + 1, alignof(long))); + EXPECT_EQ(sizeof(Class4), llvm::alignTo(1, alignof(long))); EXPECT_EQ( - llvm::alignOf(), - (llvm::alignOf< - Class4::FixedSizeStorage::with_counts<1, 1>::type>())); + alignof(Class4), + (alignof(Class4::FixedSizeStorage::with_counts<1, 1>::type))); EXPECT_EQ( sizeof(Class4::FixedSizeStorage::with_counts<1, 1>::type), llvm::alignTo(Class4::totalSizeToAlloc(1, 1), - llvm::alignOf())); + alignof(Class4))); std::unique_ptr P(new char[1000]); Class4 *C = reinterpret_cast(P.get()); EXPECT_EQ(C->getTrailingObjects(), reinterpret_cast(C + 1)); EXPECT_EQ(C->getTrailingObjects(), reinterpret_cast(llvm::alignAddr( - reinterpret_cast(C + 1) + 1, llvm::alignOf()))); + reinterpret_cast(C + 1) + 1, alignof(long)))); } }