/// Header for data within LifetimeExtendedCleanupStack.
struct LifetimeExtendedCleanupHeader {
/// The size of the following cleanup object.
- unsigned Size : 29;
+ unsigned Size;
/// The kind of cleanup to push: a value from the CleanupKind enumeration.
- unsigned Kind : 3;
+ CleanupKind Kind;
- size_t getSize() const { return size_t(Size); }
- CleanupKind getKind() const { return static_cast<CleanupKind>(Kind); }
+ size_t getSize() const { return Size; }
+ CleanupKind getKind() const { return Kind; }
};
/// i32s containing the indexes of the cleanup destinations.
LifetimeExtendedCleanupStack.resize(
LifetimeExtendedCleanupStack.size() + sizeof(Header) + Header.Size);
+ static_assert(sizeof(Header) % llvm::AlignOf<T>::Alignment == 0,
+ "Cleanup will be allocated on misaligned address");
char *Buffer = &LifetimeExtendedCleanupStack[OldSize];
new (Buffer) LifetimeExtendedCleanupHeader(Header);
new (Buffer + sizeof(Header)) T(A...);