diff --git a/libcxx/include/chrono b/libcxx/include/chrono --- a/libcxx/include/chrono +++ b/libcxx/include/chrono @@ -13,6 +13,8 @@ /* chrono synopsis +#include + namespace std { namespace chrono @@ -825,6 +827,7 @@ #include <__config> #include <__availability> +#include #include #include #include diff --git a/libcxx/include/deque b/libcxx/include/deque --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -13,6 +13,9 @@ /* deque synopsis +#include +#include + namespace std { @@ -162,6 +165,7 @@ #include <__config> #include <__split_buffer> +#include #include #include #include diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem --- a/libcxx/include/filesystem +++ b/libcxx/include/filesystem @@ -11,6 +11,8 @@ /* filesystem synopsis + #include + namespace std { namespace filesystem { class path; @@ -234,6 +236,7 @@ #include #include #include +#include #include #include #include diff --git a/libcxx/include/iterator b/libcxx/include/iterator --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -13,6 +13,8 @@ /* iterator synopsis +#include + namespace std { @@ -418,6 +420,7 @@ #include // for forward declarations of vector and string. #include <__functional_base> #include +#include #include #include #include <__memory/base.h> diff --git a/libcxx/include/map b/libcxx/include/map --- a/libcxx/include/map +++ b/libcxx/include/map @@ -14,6 +14,9 @@ map synopsis +#include +#include + namespace std { @@ -480,6 +483,8 @@ #include <__config> #include <__tree> #include <__node_handle> +#include +#include #include // __libcpp_erase_if_container #include #include diff --git a/libcxx/include/memory b/libcxx/include/memory --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -13,6 +13,8 @@ /* memory synopsis +#include + namespace std { @@ -668,6 +670,7 @@ #include <__availability> #include #include +#include #include #include #include diff --git a/libcxx/include/optional b/libcxx/include/optional --- a/libcxx/include/optional +++ b/libcxx/include/optional @@ -13,7 +13,7 @@ /* optional synopsis -// C++1z +#include namespace std { // 23.6.3, optional for object types @@ -150,6 +150,7 @@ #include <__availability> #include <__debug> #include <__functional_base> +#include #include #include #include diff --git a/libcxx/include/queue b/libcxx/include/queue --- a/libcxx/include/queue +++ b/libcxx/include/queue @@ -13,6 +13,9 @@ /* queue synopsis +#include +#include + namespace std { @@ -179,6 +182,7 @@ */ #include <__config> +#include #include #include #include diff --git a/libcxx/include/regex b/libcxx/include/regex --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -13,6 +13,7 @@ /* regex synopsis +#include #include namespace std @@ -765,6 +766,7 @@ #include <__config> #include #include <__locale> +#include #include #include #include diff --git a/libcxx/include/set b/libcxx/include/set --- a/libcxx/include/set +++ b/libcxx/include/set @@ -14,6 +14,9 @@ set synopsis +#include +#include + namespace std { @@ -428,7 +431,9 @@ #include <__config> #include <__tree> #include <__node_handle> +#include #include +#include #include // __libcpp_erase_if_container #include diff --git a/libcxx/include/stack b/libcxx/include/stack --- a/libcxx/include/stack +++ b/libcxx/include/stack @@ -13,6 +13,9 @@ /* stack synopsis +#include +#include + namespace std { diff --git a/libcxx/include/streambuf b/libcxx/include/streambuf --- a/libcxx/include/streambuf +++ b/libcxx/include/streambuf @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP_STEAMBUF -#define _LIBCPP_STEAMBUF +#ifndef _LIBCPP_STREAMBUF +#define _LIBCPP_STREAMBUF /* streambuf synopsis @@ -495,4 +495,4 @@ _LIBCPP_POP_MACROS -#endif // _LIBCPP_STEAMBUF +#endif // _LIBCPP_STREAMBUF diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -13,6 +13,9 @@ /* string synopsis +#include +#include + namespace std { @@ -514,6 +517,7 @@ */ #include <__config> +#include #include #include #include diff --git a/libcxx/include/string_view b/libcxx/include/string_view --- a/libcxx/include/string_view +++ b/libcxx/include/string_view @@ -13,6 +13,8 @@ /* string_view synopsis +#include + namespace std { // 7.2, Class template basic_string_view @@ -182,6 +184,7 @@ #include <__string> #include #include +#include #include #include #include diff --git a/libcxx/include/system_error b/libcxx/include/system_error --- a/libcxx/include/system_error +++ b/libcxx/include/system_error @@ -13,6 +13,8 @@ /* system_error synopsis +#include + namespace std { @@ -145,6 +147,7 @@ #include <__config> #include <__errc> #include <__functional_base> // unary_function +#include #include #include #include diff --git a/libcxx/include/tuple b/libcxx/include/tuple --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -13,6 +13,8 @@ /* tuple synopsis +#include + namespace std { @@ -151,6 +153,7 @@ #include <__config> #include <__tuple> +#include #include #include #include <__functional_base> diff --git a/libcxx/include/typeindex b/libcxx/include/typeindex --- a/libcxx/include/typeindex +++ b/libcxx/include/typeindex @@ -14,6 +14,8 @@ typeindex synopsis +#include + namespace std { @@ -47,6 +49,7 @@ #include <__config> #include #include <__functional_base> +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map --- a/libcxx/include/unordered_map +++ b/libcxx/include/unordered_map @@ -14,6 +14,7 @@ unordered_map synopsis +#include #include namespace std @@ -434,6 +435,7 @@ #include <__config> #include <__hash_table> #include <__node_handle> +#include #include #include // __libcpp_erase_if_container #include diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set --- a/libcxx/include/unordered_set +++ b/libcxx/include/unordered_set @@ -14,6 +14,7 @@ unordered_set synopsis +#include #include namespace std @@ -389,6 +390,7 @@ #include <__config> #include <__hash_table> #include <__node_handle> +#include #include #include // __libcpp_erase_if_container #include diff --git a/libcxx/include/utility b/libcxx/include/utility --- a/libcxx/include/utility +++ b/libcxx/include/utility @@ -13,6 +13,7 @@ /* utility synopsis +#include #include namespace std @@ -201,6 +202,7 @@ #include <__config> #include <__tuple> +#include #include #include #include diff --git a/libcxx/include/variant b/libcxx/include/variant --- a/libcxx/include/variant +++ b/libcxx/include/variant @@ -13,6 +13,8 @@ /* variant synopsis +#include + namespace std { // 20.7.2, class template variant @@ -203,6 +205,7 @@ #include <__availability> #include <__tuple> #include +#include #include #include #include diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -13,6 +13,9 @@ /* vector synopsis +#include +#include + namespace std { @@ -276,6 +279,7 @@ #include <__bit_reference> #include #include +#include #include #include #include diff --git a/libcxx/test/libcxx/inclusions/algorithm.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/algorithm.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/algorithm.inclusions.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_ALGORITHM) + # error " was expected to define _LIBCPP_ALGORITHM" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/array.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/array.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/array.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_ARRAY) + # error " was expected to define _LIBCPP_ARRAY" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/bitset.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/bitset.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/bitset.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_BITSET) + # error " was expected to define _LIBCPP_BITSET" +#endif +#if !defined(_LIBCPP_IOSFWD) + # error " should include in C++03 and later" +#endif +#if !defined(_LIBCPP_STRING) + # error " should include in C++03 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/chrono.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/chrono.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/chrono.inclusions.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// UNSUPPORTED: c++03 + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_CHRONO) + # error " was expected to define _LIBCPP_CHRONO" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/cinttypes.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/cinttypes.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/cinttypes.inclusions.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_CINTTYPES) + # error " was expected to define _LIBCPP_CINTTYPES" +#endif +#if !defined(_LIBCPP_CSTDINT) + # error " should include in C++03 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/complex.h.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/complex.h.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/complex.h.inclusions.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_COMPLEX_H) + # error " was expected to define _LIBCPP_COMPLEX_H" +#endif +#if !defined(_LIBCPP_COMPLEX) + # error " should include in C++03 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/deque.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/deque.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/deque.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_DEQUE) + # error " was expected to define _LIBCPP_DEQUE" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/filesystem.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/filesystem.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/filesystem.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// UNSUPPORTED: c++03, c++11, c++14 +// UNSUPPORTED: libcpp-has-no-filesystem-library + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_FILESYSTEM) + # error " was expected to define _LIBCPP_FILESYSTEM" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/forward_list.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/forward_list.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/forward_list.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_FORWARD_LIST) + # error " was expected to define _LIBCPP_FORWARD_LIST" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/ios.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/ios.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/ios.inclusions.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_IOS) + # error " was expected to define _LIBCPP_IOS" +#endif +#if !defined(_LIBCPP_IOSFWD) + # error " should include in C++03 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/iostream.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/iostream.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/iostream.inclusions.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_IOSTREAM) + # error " was expected to define _LIBCPP_IOSTREAM" +#endif +#if !defined(_LIBCPP_IOS) + # error " should include in C++03 and later" +#endif +#if !defined(_LIBCPP_ISTREAM) + # error " should include in C++03 and later" +#endif +#if !defined(_LIBCPP_OSTREAM) + # error " should include in C++03 and later" +#endif +#if !defined(_LIBCPP_STREAMBUF) + # error " should include in C++03 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/list.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/list.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/list.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_LIST) + # error " was expected to define _LIBCPP_LIST" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/map.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/map.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/map.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_MAP) + # error " was expected to define _LIBCPP_MAP" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/memory.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/memory.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/memory.inclusions.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_MEMORY) + # error " was expected to define _LIBCPP_MEMORY" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/optional.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/optional.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/optional.inclusions.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// UNSUPPORTED: c++03, c++11, c++14 + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_OPTIONAL) + # error " was expected to define _LIBCPP_OPTIONAL" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/queue.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/queue.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/queue.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_QUEUE) + # error " was expected to define _LIBCPP_QUEUE" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/random.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/random.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/random.inclusions.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_RANDOM) + # error " was expected to define _LIBCPP_RANDOM" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/regex.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/regex.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/regex.inclusions.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// UNSUPPORTED: libcpp-has-no-localization + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_REGEX) + # error " was expected to define _LIBCPP_REGEX" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/set.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/set.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/set.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_SET) + # error " was expected to define _LIBCPP_SET" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/stack.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/stack.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/stack.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_STACK) + # error " was expected to define _LIBCPP_STACK" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/string.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/string.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/string.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_STRING) + # error " was expected to define _LIBCPP_STRING" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/string_view.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/string_view.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/string_view.inclusions.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// UNSUPPORTED: c++03, c++11, c++14 + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_STRING_VIEW) + # error " was expected to define _LIBCPP_STRING_VIEW" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/system_error.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/system_error.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/system_error.inclusions.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// UNSUPPORTED: c++03 + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_SYSTEM_ERROR) + # error " was expected to define _LIBCPP_SYSTEM_ERROR" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/tgmath.h.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/tgmath.h.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/tgmath.h.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_TGMATH_H) + # error " was expected to define _LIBCPP_TGMATH_H" +#endif +#if !defined(_LIBCPP_CMATH) + # error " should include in C++03 and later" +#endif +#if !defined(_LIBCPP_COMPLEX) + # error " should include in C++03 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/thread.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/thread.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/thread.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// UNSUPPORTED: c++03 +// UNSUPPORTED: libcpp-has-no-threads + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_THREAD) + # error " was expected to define _LIBCPP_THREAD" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/tuple.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/tuple.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/tuple.inclusions.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// UNSUPPORTED: c++03 + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_TUPLE) + # error " was expected to define _LIBCPP_TUPLE" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/typeindex.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/typeindex.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/typeindex.inclusions.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_TYPEINDEX) + # error " was expected to define _LIBCPP_TYPEINDEX" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/unordered_map.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/unordered_map.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/unordered_map.inclusions.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// UNSUPPORTED: c++03 + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_UNORDERED_MAP) + # error " was expected to define _LIBCPP_UNORDERED_MAP" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/unordered_set.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/unordered_set.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/unordered_set.inclusions.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// UNSUPPORTED: c++03 + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_UNORDERED_SET) + # error " was expected to define _LIBCPP_UNORDERED_SET" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/utility.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/utility.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/utility.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_UTILITY) + # error " was expected to define _LIBCPP_UTILITY" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/valarray.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/valarray.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/valarray.inclusions.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_VALARRAY) + # error " was expected to define _LIBCPP_VALARRAY" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/variant.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/variant.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/variant.inclusions.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// UNSUPPORTED: c++03, c++11, c++14 + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_VARIANT) + # error " was expected to define _LIBCPP_VARIANT" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/test/libcxx/inclusions/vector.inclusions.pass.cpp b/libcxx/test/libcxx/inclusions/vector.inclusions.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/inclusions/vector.inclusions.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by generate_header_inclusion_tests.py +// and should not be edited manually. +// +// clang-format off + +// + +// Test that includes all the other headers it's supposed to. + +#include +#include "test_macros.h" + +#if !defined(_LIBCPP_VECTOR) + # error " was expected to define _LIBCPP_VECTOR" +#endif +#if TEST_STD_VER > 17 && !defined(_LIBCPP_COMPARE) + # error " should include in C++20 and later" +#endif +#if TEST_STD_VER >= 11 && !defined(_LIBCPP_INITIALIZER_LIST) + # error " should include in C++11 and later" +#endif + +int main(int, char**) { return 0; } diff --git a/libcxx/utils/generate_header_inclusion_tests.py b/libcxx/utils/generate_header_inclusion_tests.py new file mode 100755 --- /dev/null +++ b/libcxx/utils/generate_header_inclusion_tests.py @@ -0,0 +1,205 @@ +#!/usr/bin/env python + +import os + + +def get_libcxx_paths(): + utils_path = os.path.dirname(os.path.abspath(__file__)) + script_name = os.path.basename(__file__) + assert os.path.exists(utils_path) + src_root = os.path.dirname(utils_path) + test_path = os.path.join(src_root, 'test', 'libcxx', 'inclusions') + assert os.path.exists(test_path) + assert os.path.exists(os.path.join(test_path, 'algorithm.inclusions.pass.cpp')) + return script_name, src_root, test_path + + +script_name, source_root, test_path = get_libcxx_paths() + + +# This table was produced manually, by grepping the TeX source of the Standard's +# library clauses for the string "#include". Each header's synopsis contains +# explicit "#include" directives for its mandatory inclusions. +# For example, [algorithm.syn] contains "#include ". +# +mandatory_inclusions = { + "algorithm": ["initializer_list"], + "array": ["compare", "initializer_list"], + "bitset": ["iosfwd", "string"], + "chrono": ["compare"], + "cinttypes": ["cstdint"], + "complex.h": ["complex"], + # TODO "coroutine": ["compare"], + "deque": ["compare", "initializer_list"], + "filesystem": ["compare"], + "forward_list": ["compare", "initializer_list"], + "ios": ["iosfwd"], + "iostream": ["ios", "istream", "ostream", "streambuf"], + # TODO "iterator": ["compare", "concepts"], + "list": ["compare", "initializer_list"], + "map": ["compare", "initializer_list"], + "memory": ["compare"], + "optional": ["compare"], + "queue": ["compare", "initializer_list"], + "random": ["initializer_list"], + # TODO "ranges": ["compare", "initializer_list", "iterator"], + "regex": ["compare", "initializer_list"], + "set": ["compare", "initializer_list"], + "stack": ["compare", "initializer_list"], + "string": ["compare", "initializer_list"], + "string_view": ["compare"], + # TODO "syncstream": ["ostream"], + "system_error": ["compare"], + "tgmath.h": ["cmath", "complex"], + "thread": ["compare"], + "tuple": ["compare"], + "typeindex": ["compare"], + "unordered_map": ["compare", "initializer_list"], + "unordered_set": ["compare", "initializer_list"], + "utility": ["compare", "initializer_list"], + "valarray": ["initializer_list"], + "variant": ["compare"], + "vector": ["compare", "initializer_list"], +} + +new_in_version = { + "chrono": "11", + "compare": "20", + "concepts": "20", + "coroutine": "20", + "filesystem": "17", + "initializer_list": "11", + "optional": "17", + "system_error": "11", + "thread": "11", + "tuple": "11", + "unordered_map": "11", + "unordered_set": "11", + "string_view": "17", + "ranges": "20", + "syncstream": "20", + "variant": "17", +} + +assert all(v == sorted(v) for k, v in mandatory_inclusions.items()) + +# Map from each header to the Lit annotations that should be used for +# tests that include that header. +# +# For example, when threads are not supported, any test +# that includes should be marked as UNSUPPORTED, because including +# is a hard error in that case. +lit_markup = { + "atomic": ["UNSUPPORTED: libcpp-has-no-threads"], + "barrier": ["UNSUPPORTED: libcpp-has-no-threads"], + "filesystem": ["UNSUPPORTED: libcpp-has-no-filesystem-library"], + "iomanip": ["UNSUPPORTED: libcpp-has-no-localization"], + "istream": ["UNSUPPORTED: libcpp-has-no-localization"], + "latch": ["UNSUPPORTED: libcpp-has-no-threads"], + "locale": ["UNSUPPORTED: libcpp-has-no-localization"], + "ostream": ["UNSUPPORTED: libcpp-has-no-localization"], + "regex": ["UNSUPPORTED: libcpp-has-no-localization"], + "semaphore": ["UNSUPPORTED: libcpp-has-no-threads"], + "shared_mutex": ["UNSUPPORTED: libcpp-has-no-threads"], + "thread": ["UNSUPPORTED: libcpp-has-no-threads"], +} + + +def get_std_ver_test(includee): + v = new_in_version.get(includee, "03") + if v == "03": + return '' + if v == "11": + return 'TEST_STD_VER >= 11 && ' + modern_versions = ["11", "14", "17", "20"] + return 'TEST_STD_VER > {} && '.format(max(i for i in modern_versions if i < v)) + + +def get_unsupported_line(includee): + v = new_in_version.get(includee, "03") + return { + "03": [], + "11": ['UNSUPPORTED: c++03'], + "14": ['UNSUPPORTED: c++03, c++11'], + "17": ['UNSUPPORTED: c++03, c++11, c++14'], + "20": ['UNSUPPORTED: c++03, c++11, c++14, c++17'], + "2b": ['UNSUPPORTED: c++03, c++11, c++14, c++17, c++20'], + }[v] + + +def get_libcpp_header_symbol(header_name): + return '_LIBCPP_' + header_name.upper().replace('.', '_') + + +def get_includer_symbol_test(includer): + symbol = get_libcpp_header_symbol(includer) + return """ +#if !defined({symbol}) + # error "{message}" +#endif + """.strip().format( + symbol=symbol, + message="<{}> was expected to define {}".format(includer, symbol), + ) + +def get_ifdef(includer, includee): + version = max(new_in_version.get(h, "03") for h in [includer, includee]) + symbol = get_libcpp_header_symbol(includee) + return """ +#if {includee_test}!defined({symbol}) + # error "{message}" +#endif + """.strip().format( + includee_test=get_std_ver_test(includee), + symbol=symbol, + message="<{}> should include <{}> in C++{} and later".format(includer, includee, version) + ) + + +test_body_template = """ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// WARNING: This test was generated by {script_name} +// and should not be edited manually. +// +// clang-format off +{markup} +// <{header}> + +// Test that <{header}> includes all the other headers it's supposed to. + +#include <{header}> +#include "test_macros.h" + +{test_includers_symbol} +{test_per_includee} + +int main(int, char**) {{ return 0; }} +""".strip() + + +def produce_tests(): + for includer, includees in mandatory_inclusions.items(): + markup_tags = get_unsupported_line(includer) + lit_markup.get(includer, []) + test_body = test_body_template.format( + script_name=script_name, + header=includer, + markup=('\n' + '\n'.join('// ' + m for m in markup_tags) + '\n') if markup_tags else '', + test_includers_symbol=get_includer_symbol_test(includer), + test_per_includee='\n'.join(get_ifdef(includer, includee) for includee in includees), + ) + test_name = "{header}.inclusions.pass.cpp".format(header=includer) + out_path = os.path.join(test_path, test_name) + with open(out_path, 'w', newline='\n') as f: + f.write(test_body + '\n') + + +if __name__ == '__main__': + produce_tests() +