//=== - llvm/unittest/Support/TrailingObjectsTest.cpp ---------------------===// // // 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 // //===----------------------------------------------------------------------===// #include "llvm/Support/TrailingObjects.h" #include "gtest/gtest.h" usingnamespacellvm; namespace { // This class, beyond being used by the test case, a nice // demonstration of the intended usage of TrailingObjects, with a // single trailing array. class Class1 final : protected TrailingObjects<Class1, short> { … }; // Here, there are two singular optional object types appended. Note // that the alignment of Class2 is automatically increased to account // for the alignment requirements of the trailing objects. class Class2 final : protected TrailingObjects<Class2, double, short> { … }; TEST(TrailingObjects, OneArg) { … } TEST(TrailingObjects, TwoArg) { … } // This test class is not trying to be a usage demo, just asserting // that three args does actually work too (it's the same code as // handles the second arg, so it's basically covered by the above, but // just in case..) class Class3 final : public TrailingObjects<Class3, double, short, bool> { … }; TEST(TrailingObjects, ThreeArg) { … } class Class4 final : public TrailingObjects<Class4, char, long> { … }; TEST(TrailingObjects, Realignment) { … } } // Test the use of TrailingObjects with a template class. This // previously failed to compile due to a bug in MSVC's member access // control/lookup handling for OverloadToken. template <typename Derived> class Class5Tmpl : private llvm::TrailingObjects<Derived, float, int> { … }; class Class5 : public Class5Tmpl<Class5> { … };