[libc++] Implement all public header tests using the new generator
authorLouis Dionne <ldionne.2@gmail.com>
Fri, 25 Mar 2022 21:06:46 +0000 (17:06 -0400)
committerLouis Dionne <ldionne.2@gmail.com>
Mon, 4 Apr 2022 13:09:37 +0000 (09:09 -0400)
Note that `generate_assertion_tests.py` will be renamed to
`generate_header_tests.py` separately to facilitate change tracking.

Differential Revision: https://reviews.llvm.org/D123000

libcxx/test/libcxx/clang_tidy.sh.cpp
libcxx/test/libcxx/double_include.sh.cpp
libcxx/test/libcxx/min_max_macros.compile.pass.cpp
libcxx/test/libcxx/nasty_macros.compile.pass.cpp
libcxx/test/libcxx/no_assert_include.compile.pass.cpp
libcxx/utils/CMakeLists.txt
libcxx/utils/generate_assertion_tests.py
libcxx/utils/generate_header_tests.py [deleted file]

index 98cdbcd..b06cac9 100644 (file)
@@ -8,6 +8,7 @@
 
 // REQUIRES: has-clang-tidy
 // XFAIL: modules-build
+
 // RUN: clang-tidy %s --warnings-as-errors=* -header-filter=.* -- -Wno-unknown-warning-option %{compile_flags}
 // -Wno-unknown-warning-option tells clang-tidy to ignore '-W' command-line arguments that it doesn't know.
 // There are some GCC-specific ones where clang-tidy would warn otherwise.
 #    undef __DEPRECATED
 #endif
 
-////////////////////////////////////////////////////////////////////////////////
-// BEGIN-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
+/*
+BEGIN-SCRIPT
 
-// clang-format off
+for header in public_headers:
+  print("{}#{}include <{}>{}".format(
+    '#if ' + header_restrictions[header] + '\n' if header in header_restrictions else '',
+    3 * ' ' if header in header_restrictions else '',
+    header,
+    '\n#endif' if header in header_restrictions else ''
+  ))
 
-// WARNING: This test was generated by generate_header_tests.py
-// and should not be edited manually.
+END-SCRIPT
+*/
 
-// Top level headers
+// DO NOT MANUALLY EDIT ANYTHING BETWEEN THE MARKERS BELOW
+// GENERATED-MARKER
 #include <algorithm>
 #include <any>
 #include <array>
 #include <atomic>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <barrier>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <barrier>
 #endif
 #include <bit>
 #include <bitset>
 #include <cinttypes>
 #include <ciso646>
 #include <climits>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <clocale>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <clocale>
 #endif
 #include <cmath>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <codecvt>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <codecvt>
 #endif
 #include <compare>
 #include <complex>
 #include <complex.h>
 #include <concepts>
 #include <condition_variable>
-#ifndef _LIBCPP_HAS_NO_CXX20_COROUTINES
-#    include <coroutine>
-#endif
+#include <coroutine>
 #include <csetjmp>
 #include <csignal>
 #include <cstdarg>
 #include <ctime>
 #include <ctype.h>
 #include <cuchar>
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <cwchar>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <cwchar>
 #endif
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <cwctype>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <cwctype>
 #endif
 #include <deque>
 #include <errno.h>
 #include <exception>
 #include <execution>
 #include <fenv.h>
-#ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
-#    include <filesystem>
+#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#   include <filesystem>
 #endif
 #include <float.h>
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
-#    include <format>
-#endif
+#include <format>
 #include <forward_list>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <fstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <fstream>
 #endif
 #include <functional>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <future>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <future>
 #endif
 #include <initializer_list>
 #include <inttypes.h>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <iomanip>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <iomanip>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <ios>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <ios>
 #endif
 #include <iosfwd>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <iostream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <iostream>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <istream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <istream>
 #endif
 #include <iterator>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <latch>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <latch>
 #endif
 #include <limits>
 #include <limits.h>
 #include <list>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <locale>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <locale>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <locale.h>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <locale.h>
 #endif
 #include <map>
 #include <math.h>
 #include <memory>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <mutex>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <mutex>
 #endif
 #include <new>
 #include <numbers>
 #include <numeric>
 #include <optional>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <ostream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <ostream>
 #endif
 #include <queue>
 #include <random>
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_RANGES
-#    include <ranges>
-#endif
+#include <ranges>
 #include <ratio>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <regex>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <regex>
 #endif
 #include <scoped_allocator>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <semaphore>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <semaphore>
 #endif
 #include <set>
 #include <setjmp.h>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <shared_mutex>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <shared_mutex>
 #endif
 #include <span>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <sstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <sstream>
 #endif
 #include <stack>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <streambuf>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <streambuf>
 #endif
 #include <string>
 #include <string.h>
 #include <string_view>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <strstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <strstream>
 #endif
 #include <system_error>
 #include <tgmath.h>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <thread>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <thread>
 #endif
 #include <tuple>
 #include <type_traits>
 #include <variant>
 #include <vector>
 #include <version>
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <wchar.h>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <wchar.h>
 #endif
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <wctype.h>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <wctype.h>
+#endif
+#include <experimental/algorithm>
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES)
+#   include <experimental/coroutine>
 #endif
-
-// experimental headers
 #if __cplusplus >= 201103L
-#    include <experimental/algorithm>
-#    ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
-#        include <experimental/coroutine>
-#    endif
-#    include <experimental/deque>
-#    include <experimental/forward_list>
-#    include <experimental/functional>
-#    include <experimental/iterator>
-#    include <experimental/list>
-#    include <experimental/map>
-#    include <experimental/memory_resource>
-#    include <experimental/propagate_const>
-#    ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#        include <experimental/regex>
-#    endif
-#    include <experimental/set>
-#    include <experimental/simd>
-#    include <experimental/string>
-#    include <experimental/type_traits>
-#    include <experimental/unordered_map>
-#    include <experimental/unordered_set>
-#    include <experimental/utility>
-#    include <experimental/vector>
-#endif // __cplusplus >= 201103L
-
-// clang-format on
-
-////////////////////////////////////////////////////////////////////////////////
-// END-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
+#   include <experimental/deque>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/forward_list>
+#endif
+#include <experimental/functional>
+#include <experimental/iterator>
+#if __cplusplus >= 201103L
+#   include <experimental/list>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/map>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/memory_resource>
+#endif
+#include <experimental/propagate_const>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L
+#   include <experimental/regex>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/set>
+#endif
+#include <experimental/simd>
+#if __cplusplus >= 201103L
+#   include <experimental/string>
+#endif
+#include <experimental/type_traits>
+#if __cplusplus >= 201103L
+#   include <experimental/unordered_map>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/unordered_set>
+#endif
+#include <experimental/utility>
+#if __cplusplus >= 201103L
+#   include <experimental/vector>
+#endif
+#include <ext/hash_map>
+#include <ext/hash_set>
+// GENERATED-MARKER
index 54547c8..6701908 100644 (file)
 #    undef __DEPRECATED
 #endif
 
-////////////////////////////////////////////////////////////////////////////////
-// BEGIN-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
+/*
+BEGIN-SCRIPT
 
-// clang-format off
+for header in public_headers:
+  print("{}#{}include <{}>{}".format(
+    '#if ' + header_restrictions[header] + '\n' if header in header_restrictions else '',
+    3 * ' ' if header in header_restrictions else '',
+    header,
+    '\n#endif' if header in header_restrictions else ''
+  ))
 
-// WARNING: This test was generated by generate_header_tests.py
-// and should not be edited manually.
+END-SCRIPT
+*/
 
-// Top level headers
+// DO NOT MANUALLY EDIT ANYTHING BETWEEN THE MARKERS BELOW
+// GENERATED-MARKER
 #include <algorithm>
 #include <any>
 #include <array>
 #include <atomic>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <barrier>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <barrier>
 #endif
 #include <bit>
 #include <bitset>
 #include <cinttypes>
 #include <ciso646>
 #include <climits>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <clocale>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <clocale>
 #endif
 #include <cmath>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <codecvt>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <codecvt>
 #endif
 #include <compare>
 #include <complex>
 #include <complex.h>
 #include <concepts>
 #include <condition_variable>
-#ifndef _LIBCPP_HAS_NO_CXX20_COROUTINES
-#    include <coroutine>
-#endif
+#include <coroutine>
 #include <csetjmp>
 #include <csignal>
 #include <cstdarg>
 #include <ctime>
 #include <ctype.h>
 #include <cuchar>
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <cwchar>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <cwchar>
 #endif
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <cwctype>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <cwctype>
 #endif
 #include <deque>
 #include <errno.h>
 #include <exception>
 #include <execution>
 #include <fenv.h>
-#ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
-#    include <filesystem>
+#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#   include <filesystem>
 #endif
 #include <float.h>
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
-#    include <format>
-#endif
+#include <format>
 #include <forward_list>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <fstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <fstream>
 #endif
 #include <functional>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <future>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <future>
 #endif
 #include <initializer_list>
 #include <inttypes.h>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <iomanip>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <iomanip>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <ios>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <ios>
 #endif
 #include <iosfwd>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <iostream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <iostream>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <istream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <istream>
 #endif
 #include <iterator>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <latch>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <latch>
 #endif
 #include <limits>
 #include <limits.h>
 #include <list>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <locale>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <locale>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <locale.h>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <locale.h>
 #endif
 #include <map>
 #include <math.h>
 #include <memory>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <mutex>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <mutex>
 #endif
 #include <new>
 #include <numbers>
 #include <numeric>
 #include <optional>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <ostream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <ostream>
 #endif
 #include <queue>
 #include <random>
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_RANGES
-#    include <ranges>
-#endif
+#include <ranges>
 #include <ratio>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <regex>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <regex>
 #endif
 #include <scoped_allocator>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <semaphore>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <semaphore>
 #endif
 #include <set>
 #include <setjmp.h>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <shared_mutex>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <shared_mutex>
 #endif
 #include <span>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <sstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <sstream>
 #endif
 #include <stack>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <streambuf>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <streambuf>
 #endif
 #include <string>
 #include <string.h>
 #include <string_view>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <strstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <strstream>
 #endif
 #include <system_error>
 #include <tgmath.h>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <thread>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <thread>
 #endif
 #include <tuple>
 #include <type_traits>
 #include <variant>
 #include <vector>
 #include <version>
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <wchar.h>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <wchar.h>
 #endif
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <wctype.h>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <wctype.h>
+#endif
+#include <experimental/algorithm>
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES)
+#   include <experimental/coroutine>
 #endif
-
-// experimental headers
 #if __cplusplus >= 201103L
-#    include <experimental/algorithm>
-#    ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
-#        include <experimental/coroutine>
-#    endif
-#    include <experimental/deque>
-#    include <experimental/forward_list>
-#    include <experimental/functional>
-#    include <experimental/iterator>
-#    include <experimental/list>
-#    include <experimental/map>
-#    include <experimental/memory_resource>
-#    include <experimental/propagate_const>
-#    ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#        include <experimental/regex>
-#    endif
-#    include <experimental/set>
-#    include <experimental/simd>
-#    include <experimental/string>
-#    include <experimental/type_traits>
-#    include <experimental/unordered_map>
-#    include <experimental/unordered_set>
-#    include <experimental/utility>
-#    include <experimental/vector>
-#endif // __cplusplus >= 201103L
-
-// clang-format on
-
-////////////////////////////////////////////////////////////////////////////////
-// END-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
+#   include <experimental/deque>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/forward_list>
+#endif
+#include <experimental/functional>
+#include <experimental/iterator>
+#if __cplusplus >= 201103L
+#   include <experimental/list>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/map>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/memory_resource>
+#endif
+#include <experimental/propagate_const>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L
+#   include <experimental/regex>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/set>
+#endif
+#include <experimental/simd>
+#if __cplusplus >= 201103L
+#   include <experimental/string>
+#endif
+#include <experimental/type_traits>
+#if __cplusplus >= 201103L
+#   include <experimental/unordered_map>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/unordered_set>
+#endif
+#include <experimental/utility>
+#if __cplusplus >= 201103L
+#   include <experimental/vector>
+#endif
+#include <ext/hash_map>
+#include <ext/hash_set>
+// GENERATED-MARKER
 
 #if defined(WITH_MAIN)
 int main(int, char**) { return 0; }
index b99b7aa..57d04e1 100644 (file)
 #define min() true
 #define max() true
 
-////////////////////////////////////////////////////////////////////////////////
-// BEGIN-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
+/*
+BEGIN-SCRIPT
 
-// clang-format off
+for header in public_headers:
+  print("{}#{}include <{}>\nTEST_MACROS();{}".format(
+    '#if ' + header_restrictions[header] + '\n' if header in header_restrictions else '',
+    3 * ' ' if header in header_restrictions else '',
+    header,
+    '\n#endif' if header in header_restrictions else ''
+  ))
 
-// WARNING: This test was generated by generate_header_tests.py
-// and should not be edited manually.
+END-SCRIPT
+*/
 
-// Top level headers
+// DO NOT MANUALLY EDIT ANYTHING BETWEEN THE MARKERS BELOW
+// GENERATED-MARKER
 #include <algorithm>
 TEST_MACROS();
 #include <any>
@@ -39,8 +45,8 @@ TEST_MACROS();
 TEST_MACROS();
 #include <atomic>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <barrier>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <barrier>
 TEST_MACROS();
 #endif
 #include <bit>
@@ -69,14 +75,14 @@ TEST_MACROS();
 TEST_MACROS();
 #include <climits>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <clocale>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <clocale>
 TEST_MACROS();
 #endif
 #include <cmath>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <codecvt>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <codecvt>
 TEST_MACROS();
 #endif
 #include <compare>
@@ -89,10 +95,8 @@ TEST_MACROS();
 TEST_MACROS();
 #include <condition_variable>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_CXX20_COROUTINES
-#    include <coroutine>
+#include <coroutine>
 TEST_MACROS();
-#endif
 #include <csetjmp>
 TEST_MACROS();
 #include <csignal>
@@ -119,12 +123,12 @@ TEST_MACROS();
 TEST_MACROS();
 #include <cuchar>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <cwchar>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <cwchar>
 TEST_MACROS();
 #endif
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <cwctype>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <cwctype>
 TEST_MACROS();
 #endif
 #include <deque>
@@ -137,54 +141,52 @@ TEST_MACROS();
 TEST_MACROS();
 #include <fenv.h>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
-#    include <filesystem>
+#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#   include <filesystem>
 TEST_MACROS();
 #endif
 #include <float.h>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
-#    include <format>
+#include <format>
 TEST_MACROS();
-#endif
 #include <forward_list>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <fstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <fstream>
 TEST_MACROS();
 #endif
 #include <functional>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <future>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <future>
 TEST_MACROS();
 #endif
 #include <initializer_list>
 TEST_MACROS();
 #include <inttypes.h>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <iomanip>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <iomanip>
 TEST_MACROS();
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <ios>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <ios>
 TEST_MACROS();
 #endif
 #include <iosfwd>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <iostream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <iostream>
 TEST_MACROS();
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <istream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <istream>
 TEST_MACROS();
 #endif
 #include <iterator>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <latch>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <latch>
 TEST_MACROS();
 #endif
 #include <limits>
@@ -193,12 +195,12 @@ TEST_MACROS();
 TEST_MACROS();
 #include <list>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <locale>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <locale>
 TEST_MACROS();
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <locale.h>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <locale.h>
 TEST_MACROS();
 #endif
 #include <map>
@@ -207,8 +209,8 @@ TEST_MACROS();
 TEST_MACROS();
 #include <memory>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <mutex>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <mutex>
 TEST_MACROS();
 #endif
 #include <new>
@@ -219,42 +221,40 @@ TEST_MACROS();
 TEST_MACROS();
 #include <optional>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <ostream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <ostream>
 TEST_MACROS();
 #endif
 #include <queue>
 TEST_MACROS();
 #include <random>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_RANGES
-#    include <ranges>
+#include <ranges>
 TEST_MACROS();
-#endif
 #include <ratio>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <regex>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <regex>
 TEST_MACROS();
 #endif
 #include <scoped_allocator>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <semaphore>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <semaphore>
 TEST_MACROS();
 #endif
 #include <set>
 TEST_MACROS();
 #include <setjmp.h>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <shared_mutex>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <shared_mutex>
 TEST_MACROS();
 #endif
 #include <span>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <sstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <sstream>
 TEST_MACROS();
 #endif
 #include <stack>
@@ -271,8 +271,8 @@ TEST_MACROS();
 TEST_MACROS();
 #include <stdlib.h>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <streambuf>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <streambuf>
 TEST_MACROS();
 #endif
 #include <string>
@@ -281,16 +281,16 @@ TEST_MACROS();
 TEST_MACROS();
 #include <string_view>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <strstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <strstream>
 TEST_MACROS();
 #endif
 #include <system_error>
 TEST_MACROS();
 #include <tgmath.h>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <thread>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <thread>
 TEST_MACROS();
 #endif
 #include <tuple>
@@ -317,63 +317,78 @@ TEST_MACROS();
 TEST_MACROS();
 #include <version>
 TEST_MACROS();
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <wchar.h>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <wchar.h>
 TEST_MACROS();
 #endif
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <wctype.h>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <wctype.h>
+TEST_MACROS();
+#endif
+#include <experimental/algorithm>
+TEST_MACROS();
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES)
+#   include <experimental/coroutine>
 TEST_MACROS();
 #endif
-
-// experimental headers
 #if __cplusplus >= 201103L
-#    include <experimental/algorithm>
+#   include <experimental/deque>
 TEST_MACROS();
-#    ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
-#        include <experimental/coroutine>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/forward_list>
 TEST_MACROS();
-#    endif
-#    include <experimental/deque>
+#endif
+#include <experimental/functional>
 TEST_MACROS();
-#    include <experimental/forward_list>
+#include <experimental/iterator>
 TEST_MACROS();
-#    include <experimental/functional>
+#if __cplusplus >= 201103L
+#   include <experimental/list>
 TEST_MACROS();
-#    include <experimental/iterator>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/map>
 TEST_MACROS();
-#    include <experimental/list>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/memory_resource>
 TEST_MACROS();
-#    include <experimental/map>
+#endif
+#include <experimental/propagate_const>
 TEST_MACROS();
-#    include <experimental/memory_resource>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L
+#   include <experimental/regex>
 TEST_MACROS();
-#    include <experimental/propagate_const>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/set>
 TEST_MACROS();
-#    ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#        include <experimental/regex>
+#endif
+#include <experimental/simd>
 TEST_MACROS();
-#    endif
-#    include <experimental/set>
+#if __cplusplus >= 201103L
+#   include <experimental/string>
 TEST_MACROS();
-#    include <experimental/simd>
+#endif
+#include <experimental/type_traits>
 TEST_MACROS();
-#    include <experimental/string>
+#if __cplusplus >= 201103L
+#   include <experimental/unordered_map>
 TEST_MACROS();
-#    include <experimental/type_traits>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/unordered_set>
 TEST_MACROS();
-#    include <experimental/unordered_map>
+#endif
+#include <experimental/utility>
 TEST_MACROS();
-#    include <experimental/unordered_set>
+#if __cplusplus >= 201103L
+#   include <experimental/vector>
 TEST_MACROS();
-#    include <experimental/utility>
+#endif
+#include <ext/hash_map>
 TEST_MACROS();
-#    include <experimental/vector>
+#include <ext/hash_set>
 TEST_MACROS();
-#endif // __cplusplus >= 201103L
-
-// clang-format on
-
-////////////////////////////////////////////////////////////////////////////////
-// END-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
+// GENERATED-MARKER
index 88eef5c..5916a11 100644 (file)
 #define Xp NASTY_MACRO
 #define Xs NASTY_MACRO
 
-////////////////////////////////////////////////////////////////////////////////
-// BEGIN-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
+/*
+BEGIN-SCRIPT
 
-// clang-format off
+for header in public_headers:
+  print("{}#{}include <{}>{}".format(
+    '#if ' + header_restrictions[header] + '\n' if header in header_restrictions else '',
+    3 * ' ' if header in header_restrictions else '',
+    header,
+    '\n#endif' if header in header_restrictions else ''
+  ))
 
-// WARNING: This test was generated by generate_header_tests.py
-// and should not be edited manually.
+END-SCRIPT
+*/
 
-// Top level headers
+// DO NOT MANUALLY EDIT ANYTHING BETWEEN THE MARKERS BELOW
+// GENERATED-MARKER
 #include <algorithm>
 #include <any>
 #include <array>
 #include <atomic>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <barrier>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <barrier>
 #endif
 #include <bit>
 #include <bitset>
 #include <cinttypes>
 #include <ciso646>
 #include <climits>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <clocale>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <clocale>
 #endif
 #include <cmath>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <codecvt>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <codecvt>
 #endif
 #include <compare>
 #include <complex>
 #include <complex.h>
 #include <concepts>
 #include <condition_variable>
-#ifndef _LIBCPP_HAS_NO_CXX20_COROUTINES
-#    include <coroutine>
-#endif
+#include <coroutine>
 #include <csetjmp>
 #include <csignal>
 #include <cstdarg>
 #include <ctime>
 #include <ctype.h>
 #include <cuchar>
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <cwchar>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <cwchar>
 #endif
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <cwctype>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <cwctype>
 #endif
 #include <deque>
 #include <errno.h>
 #include <exception>
 #include <execution>
 #include <fenv.h>
-#ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
-#    include <filesystem>
+#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#   include <filesystem>
 #endif
 #include <float.h>
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
-#    include <format>
-#endif
+#include <format>
 #include <forward_list>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <fstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <fstream>
 #endif
 #include <functional>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <future>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <future>
 #endif
 #include <initializer_list>
 #include <inttypes.h>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <iomanip>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <iomanip>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <ios>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <ios>
 #endif
 #include <iosfwd>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <iostream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <iostream>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <istream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <istream>
 #endif
 #include <iterator>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <latch>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <latch>
 #endif
 #include <limits>
 #include <limits.h>
 #include <list>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <locale>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <locale>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <locale.h>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <locale.h>
 #endif
 #include <map>
 #include <math.h>
 #include <memory>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <mutex>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <mutex>
 #endif
 #include <new>
 #include <numbers>
 #include <numeric>
 #include <optional>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <ostream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <ostream>
 #endif
 #include <queue>
 #include <random>
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_RANGES
-#    include <ranges>
-#endif
+#include <ranges>
 #include <ratio>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <regex>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <regex>
 #endif
 #include <scoped_allocator>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <semaphore>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <semaphore>
 #endif
 #include <set>
 #include <setjmp.h>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <shared_mutex>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <shared_mutex>
 #endif
 #include <span>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <sstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <sstream>
 #endif
 #include <stack>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <streambuf>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <streambuf>
 #endif
 #include <string>
 #include <string.h>
 #include <string_view>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <strstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <strstream>
 #endif
 #include <system_error>
 #include <tgmath.h>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <thread>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <thread>
 #endif
 #include <tuple>
 #include <type_traits>
 #include <variant>
 #include <vector>
 #include <version>
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <wchar.h>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <wchar.h>
 #endif
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <wctype.h>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <wctype.h>
+#endif
+#include <experimental/algorithm>
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES)
+#   include <experimental/coroutine>
 #endif
-
-// experimental headers
 #if __cplusplus >= 201103L
-#    include <experimental/algorithm>
-#    ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
-#        include <experimental/coroutine>
-#    endif
-#    include <experimental/deque>
-#    include <experimental/forward_list>
-#    include <experimental/functional>
-#    include <experimental/iterator>
-#    include <experimental/list>
-#    include <experimental/map>
-#    include <experimental/memory_resource>
-#    include <experimental/propagate_const>
-#    ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#        include <experimental/regex>
-#    endif
-#    include <experimental/set>
-#    include <experimental/simd>
-#    include <experimental/string>
-#    include <experimental/type_traits>
-#    include <experimental/unordered_map>
-#    include <experimental/unordered_set>
-#    include <experimental/utility>
-#    include <experimental/vector>
-#endif // __cplusplus >= 201103L
-
-// clang-format on
-
-////////////////////////////////////////////////////////////////////////////////
-// END-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
+#   include <experimental/deque>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/forward_list>
+#endif
+#include <experimental/functional>
+#include <experimental/iterator>
+#if __cplusplus >= 201103L
+#   include <experimental/list>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/map>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/memory_resource>
+#endif
+#include <experimental/propagate_const>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L
+#   include <experimental/regex>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/set>
+#endif
+#include <experimental/simd>
+#if __cplusplus >= 201103L
+#   include <experimental/string>
+#endif
+#include <experimental/type_traits>
+#if __cplusplus >= 201103L
+#   include <experimental/unordered_map>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/unordered_set>
+#endif
+#include <experimental/utility>
+#if __cplusplus >= 201103L
+#   include <experimental/vector>
+#endif
+#include <ext/hash_map>
+#include <ext/hash_set>
+// GENERATED-MARKER
index ee0a3bf..b173c46 100644 (file)
 #    undef __DEPRECATED
 #endif
 
-////////////////////////////////////////////////////////////////////////////////
-// BEGIN-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
+/*
+BEGIN-SCRIPT
 
-// clang-format off
+for header in public_headers:
+  if header == 'cassert':
+    continue
+  print("{}#{}include <{}>{}".format(
+    '#if ' + header_restrictions[header] + '\n' if header in header_restrictions else '',
+    3 * ' ' if header in header_restrictions else '',
+    header,
+    '\n#endif' if header in header_restrictions else ''
+  ))
 
-// WARNING: This test was generated by generate_header_tests.py
-// and should not be edited manually.
+END-SCRIPT
+*/
 
-// Top level headers
+// DO NOT MANUALLY EDIT ANYTHING BETWEEN THE MARKERS BELOW
+// GENERATED-MARKER
 #include <algorithm>
 #include <any>
 #include <array>
 #include <atomic>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <barrier>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <barrier>
 #endif
 #include <bit>
 #include <bitset>
 #include <cinttypes>
 #include <ciso646>
 #include <climits>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <clocale>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <clocale>
 #endif
 #include <cmath>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <codecvt>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <codecvt>
 #endif
 #include <compare>
 #include <complex>
 #include <complex.h>
 #include <concepts>
 #include <condition_variable>
-#ifndef _LIBCPP_HAS_NO_CXX20_COROUTINES
-#    include <coroutine>
-#endif
+#include <coroutine>
 #include <csetjmp>
 #include <csignal>
 #include <cstdarg>
 #include <ctime>
 #include <ctype.h>
 #include <cuchar>
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <cwchar>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <cwchar>
 #endif
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <cwctype>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <cwctype>
 #endif
 #include <deque>
 #include <errno.h>
 #include <exception>
 #include <execution>
 #include <fenv.h>
-#ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
-#    include <filesystem>
+#if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
+#   include <filesystem>
 #endif
 #include <float.h>
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_FORMAT
-#    include <format>
-#endif
+#include <format>
 #include <forward_list>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <fstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <fstream>
 #endif
 #include <functional>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <future>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <future>
 #endif
 #include <initializer_list>
 #include <inttypes.h>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <iomanip>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <iomanip>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <ios>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <ios>
 #endif
 #include <iosfwd>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <iostream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <iostream>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <istream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <istream>
 #endif
 #include <iterator>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <latch>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <latch>
 #endif
 #include <limits>
 #include <limits.h>
 #include <list>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <locale>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <locale>
 #endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <locale.h>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <locale.h>
 #endif
 #include <map>
 #include <math.h>
 #include <memory>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <mutex>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <mutex>
 #endif
 #include <new>
 #include <numbers>
 #include <numeric>
 #include <optional>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <ostream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <ostream>
 #endif
 #include <queue>
 #include <random>
-#ifndef _LIBCPP_HAS_NO_INCOMPLETE_RANGES
-#    include <ranges>
-#endif
+#include <ranges>
 #include <ratio>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <regex>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <regex>
 #endif
 #include <scoped_allocator>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <semaphore>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <semaphore>
 #endif
 #include <set>
 #include <setjmp.h>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <shared_mutex>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <shared_mutex>
 #endif
 #include <span>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <sstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <sstream>
 #endif
 #include <stack>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <streambuf>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <streambuf>
 #endif
 #include <string>
 #include <string.h>
 #include <string_view>
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#    include <strstream>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+#   include <strstream>
 #endif
 #include <system_error>
 #include <tgmath.h>
-#ifndef _LIBCPP_HAS_NO_THREADS
-#    include <thread>
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+#   include <thread>
 #endif
 #include <tuple>
 #include <type_traits>
 #include <variant>
 #include <vector>
 #include <version>
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <wchar.h>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <wchar.h>
 #endif
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#    include <wctype.h>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#   include <wctype.h>
+#endif
+#include <experimental/algorithm>
+#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES)
+#   include <experimental/coroutine>
 #endif
-
-// experimental headers
 #if __cplusplus >= 201103L
-#    include <experimental/algorithm>
-#    ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES
-#        include <experimental/coroutine>
-#    endif
-#    include <experimental/deque>
-#    include <experimental/forward_list>
-#    include <experimental/functional>
-#    include <experimental/iterator>
-#    include <experimental/list>
-#    include <experimental/map>
-#    include <experimental/memory_resource>
-#    include <experimental/propagate_const>
-#    ifndef _LIBCPP_HAS_NO_LOCALIZATION
-#        include <experimental/regex>
-#    endif
-#    include <experimental/set>
-#    include <experimental/simd>
-#    include <experimental/string>
-#    include <experimental/type_traits>
-#    include <experimental/unordered_map>
-#    include <experimental/unordered_set>
-#    include <experimental/utility>
-#    include <experimental/vector>
-#endif // __cplusplus >= 201103L
-
-// clang-format on
-
-////////////////////////////////////////////////////////////////////////////////
-// END-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
+#   include <experimental/deque>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/forward_list>
+#endif
+#include <experimental/functional>
+#include <experimental/iterator>
+#if __cplusplus >= 201103L
+#   include <experimental/list>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/map>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/memory_resource>
+#endif
+#include <experimental/propagate_const>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L
+#   include <experimental/regex>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/set>
+#endif
+#include <experimental/simd>
+#if __cplusplus >= 201103L
+#   include <experimental/string>
+#endif
+#include <experimental/type_traits>
+#if __cplusplus >= 201103L
+#   include <experimental/unordered_map>
+#endif
+#if __cplusplus >= 201103L
+#   include <experimental/unordered_set>
+#endif
+#include <experimental/utility>
+#if __cplusplus >= 201103L
+#   include <experimental/vector>
+#endif
+#include <ext/hash_map>
+#include <ext/hash_set>
+// GENERATED-MARKER
 
 #ifdef assert
 #error "Do not include cassert or assert.h in standard header files"
index d337935..ab703bf 100644 (file)
@@ -4,7 +4,7 @@ add_custom_target(libcxx-generate-public-header-transitive-inclusion-tests
     COMMENT "Generate tests checking for mandated transitive includes in public headers.")
 
 add_custom_target(libcxx-generate-public-header-tests
-    COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_header_tests.py"
+    COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_assertion_tests.py"
     COMMENT "Generate tests for including public headers.")
 
 add_custom_target(libcxx-generate-feature-test-macros
@@ -15,14 +15,9 @@ add_custom_target(libcxx-generate-private-header-tests
     COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_private_header_tests.py"
     COMMENT "Generate tests for ensuring that detail headers are private.")
 
-add_custom_target(libcxx-generate-assertion-tests
-    COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_assertion_tests.py"
-    COMMENT "Generate tests for inclusion of <__assert>.")
-
 add_custom_target(libcxx-generate-files
     DEPENDS libcxx-generate-public-header-transitive-inclusion-tests
             libcxx-generate-public-header-tests
             libcxx-generate-feature-test-macros
             libcxx-generate-private-header-tests
-            libcxx-generate-assertion-tests
     COMMENT "Create all the auto-generated files in libc++ and its tests.")
index 7f9888e..5acf191 100755 (executable)
@@ -129,6 +129,11 @@ def main():
     }
 
     produce(test.joinpath('libcxx/assertions/headers_declare_assertion_handler.sh.cpp'), variables)
+    produce(test.joinpath('libcxx/clang_tidy.sh.cpp'), variables)
+    produce(test.joinpath('libcxx/double_include.sh.cpp'), variables)
+    produce(test.joinpath('libcxx/min_max_macros.compile.pass.cpp'), variables)
+    produce(test.joinpath('libcxx/nasty_macros.compile.pass.cpp'), variables)
+    produce(test.joinpath('libcxx/no_assert_include.compile.pass.cpp'), variables)
 
 
 if __name__ == '__main__':
diff --git a/libcxx/utils/generate_header_tests.py b/libcxx/utils/generate_header_tests.py
deleted file mode 100755 (executable)
index a7b2f6d..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-#!/usr/bin/env python
-
-import glob
-import os
-import posixpath
-import re
-
-
-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)
-    include_path = os.path.join(src_root, 'include')
-    assert os.path.exists(include_path)
-    libcxx_test_path = os.path.join(src_root, 'test', 'libcxx')
-    assert os.path.exists(libcxx_test_path)
-    return script_name, src_root, include_path, libcxx_test_path
-
-
-script_name, source_root, include_path, libcxx_test_path = get_libcxx_paths()
-
-header_markup = {
-    "barrier": ["ifndef _LIBCPP_HAS_NO_THREADS"],
-    "future": ["ifndef _LIBCPP_HAS_NO_THREADS"],
-    "latch": ["ifndef _LIBCPP_HAS_NO_THREADS"],
-    "mutex": ["ifndef _LIBCPP_HAS_NO_THREADS"],
-    "semaphore": ["ifndef _LIBCPP_HAS_NO_THREADS"],
-    "shared_mutex": ["ifndef _LIBCPP_HAS_NO_THREADS"],
-    "thread": ["ifndef _LIBCPP_HAS_NO_THREADS"],
-
-    "filesystem": ["ifndef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY"],
-    "format": ["ifndef _LIBCPP_HAS_NO_INCOMPLETE_FORMAT"],
-
-    "clocale": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "codecvt": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "fstream": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "iomanip": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "ios": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "iostream": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "istream": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "locale.h": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "locale": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "ostream": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "ranges": ["ifndef _LIBCPP_HAS_NO_INCOMPLETE_RANGES"],
-    "regex": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "sstream": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "streambuf": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-    "strstream": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-
-    "wctype.h": ["ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS"],
-    "cwctype": ["ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS"],
-    "cwchar": ["ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS"],
-    "wchar.h": ["ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS"],
-
-    "experimental/coroutine": ["ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES"],
-    "coroutine": ["ifndef _LIBCPP_HAS_NO_CXX20_COROUTINES"],
-    "experimental/regex": ["ifndef _LIBCPP_HAS_NO_LOCALIZATION"],
-}
-
-allowed_extensions = ['', '.h']
-indent_width = 4
-
-
-begin_pattern = """\
-////////////////////////////////////////////////////////////////////////////////
-// BEGIN-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
-"""
-
-warning_note = """\
-// WARNING: This test was generated by {script_name}
-// and should not be edited manually.
-
-""".format(script_name=script_name)
-
-end_pattern = """\
-////////////////////////////////////////////////////////////////////////////////
-// END-GENERATED-HEADERS
-////////////////////////////////////////////////////////////////////////////////
-"""
-
-generated_part_pattern = re.compile(re.escape(begin_pattern) + ".*" + re.escape(end_pattern),
-                                    re.MULTILINE | re.DOTALL)
-
-headers_template = """\
-// Top level headers
-{top_level_headers}
-
-// experimental headers
-#if __cplusplus >= 201103L
-{experimental_headers}
-#endif // __cplusplus >= 201103L
-"""
-
-
-def should_keep_header(p, exclusions=None):
-    if os.path.isdir(p):
-        return False
-
-    if exclusions:
-        relpath = os.path.relpath(p, include_path)
-        relpath = posixpath.join(*os.path.split(relpath))
-        if relpath in exclusions:
-            return False
-
-    return os.path.splitext(p)[1] in allowed_extensions
-
-
-def produce_include(relpath, indent_level, post_include=None):
-    relpath = posixpath.join(*os.path.split(relpath))
-    template = "{preamble}#{indentation}include <{include}>{post_include}{postamble}"
-
-    base_indentation = ' '*(indent_width * indent_level)
-    next_indentation = base_indentation + ' '*(indent_width)
-    post_include = "\n{}".format(post_include) if post_include else ''
-
-    markup = header_markup.get(relpath, None)
-    if markup:
-        preamble = '#{indentation}{directive}\n'.format(
-            directive=markup[0],
-            indentation=base_indentation,
-        )
-        postamble = '\n#{indentation}endif'.format(
-            indentation=base_indentation,
-        )
-        indentation = next_indentation
-    else:
-        preamble = ''
-        postamble = ''
-        indentation = base_indentation
-
-    return template.format(
-        include=relpath,
-        post_include=post_include,
-        preamble=preamble,
-        postamble=postamble,
-        indentation=indentation,
-    )
-
-
-def produce_headers(path_parts, indent_level, post_include=None, exclusions=None):
-    pattern = os.path.join(*path_parts, '[a-z]*')
-
-    files = sorted(glob.glob(pattern, recursive=False))
-
-    include_headers = [
-        produce_include(os.path.relpath(p, include_path),
-                        indent_level, post_include=post_include)
-        for p in files
-        if should_keep_header(p, exclusions)
-    ]
-
-    return '\n'.join(include_headers)
-
-
-def produce_top_level_headers(post_include=None, exclusions=None):
-    return produce_headers([include_path], 0, post_include=post_include, exclusions=exclusions)
-
-
-def produce_experimental_headers(post_include=None, exclusions=None):
-    return produce_headers([include_path, 'experimental'], 1, post_include=post_include, exclusions=exclusions)
-
-
-def produce_extended_headers(post_include=None, exclusions=None):
-    return produce_headers([include_path, 'ext'], 1, post_include=post_include, exclusions=exclusions)
-
-
-def replace_generated_headers(test_path, test_str):
-    with open(test_path, 'r') as f:
-        content = f.read()
-
-    preamble = begin_pattern + '\n// clang-format off\n\n' + warning_note
-    postamble = '\n// clang-format on\n\n' + end_pattern
-    content = generated_part_pattern.sub(
-        preamble + test_str + postamble, content)
-
-    with open(test_path, 'w', newline='\n') as f:
-        f.write(content)
-
-
-def produce_test(test_filename, exclusions=None, post_include=None):
-    test_str = headers_template.format(
-        top_level_headers=produce_top_level_headers(
-            post_include=post_include,
-            exclusions=exclusions,
-        ),
-        experimental_headers=produce_experimental_headers(
-            post_include=post_include,
-        ),
-    )
-
-    replace_generated_headers(os.path.join(
-        libcxx_test_path, test_filename), test_str)
-
-
-def main():
-    produce_test('clang_tidy.sh.cpp')
-    produce_test('double_include.sh.cpp')
-    produce_test('min_max_macros.compile.pass.cpp', post_include='TEST_MACROS();')
-    produce_test('nasty_macros.compile.pass.cpp')
-    produce_test('no_assert_include.compile.pass.cpp', exclusions=['cassert'])
-
-
-if __name__ == '__main__':
-    main()