//===----------------------------------------------------------------------===// // // 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 // //===----------------------------------------------------------------------===// // Pin down the ABI of associative containers with respect to their size and alignment // when passed a comparator that is a reference. // // While it's not even clear that reference comparators are legal in containers, an // unintended ABI break was discovered after implementing the new compressed pair // mechanism based on [[no_unique_address]], and this is a regression test for that. // If we decide to make reference comparators ill-formed, this test would become // unnecessary. // // See https://llvm.org/PR118559 for more details. #include #include #include "test_macros.h" struct TEST_ALIGNAS(16) Cmp { bool operator()(int, int) const; }; template struct Set { char b; std::set s; }; template struct Multiset { char b; std::multiset s; }; template struct Map { char b; std::map s; }; template struct Multimap { char b; std::multimap s; }; static_assert(sizeof(Set) == sizeof(Set), ""); static_assert(sizeof(Multiset) == sizeof(Multiset), ""); static_assert(sizeof(Map) == sizeof(Map), ""); static_assert(sizeof(Multimap) == sizeof(Multimap), "");