//===- llvm/ADT/SmallVector.cpp - 'Normally small' vectors ----------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements the SmallVector class. // //===----------------------------------------------------------------------===// #include "llvm/ADT/SmallVector.h" using namespace llvm; // Check that no bytes are wasted and everything is well-aligned. namespace { struct Struct16B { alignas(16) void *X; }; struct Struct32B { alignas(32) void *X; }; } static_assert(sizeof(SmallVector) == sizeof(unsigned) * 2 + sizeof(void *), "wasted space in SmallVector size 0"); static_assert(alignof(SmallVector) >= alignof(Struct16B), "wrong alignment for 16-byte aligned T"); static_assert(alignof(SmallVector) >= alignof(Struct32B), "wrong alignment for 32-byte aligned T"); static_assert(sizeof(SmallVector) >= alignof(Struct16B), "missing padding for 16-byte aligned T"); static_assert(sizeof(SmallVector) >= alignof(Struct32B), "missing padding for 32-byte aligned T"); static_assert(sizeof(SmallVector) == sizeof(unsigned) * 2 + sizeof(void *) * 2, "wasted space in SmallVector size 1"); static_assert(sizeof(SmallVector) == sizeof(void *) * 2 + sizeof(void *), "1 byte elements have word-sized type for size and capacity");