[libcxx-commits] [libcxx] 1ee839d - [libc++] Use the new .gen tests to implement __verbose_abort tests
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon May 29 12:29:03 PDT 2023
Author: Louis Dionne
Date: 2023-05-29T12:28:52-07:00
New Revision: 1ee839d0ce13820955749a6d0e2506c4ea55d030
URL: https://github.com/llvm/llvm-project/commit/1ee839d0ce13820955749a6d0e2506c4ea55d030
DIFF: https://github.com/llvm/llvm-project/commit/1ee839d0ce13820955749a6d0e2506c4ea55d030.diff
LOG: [libc++] Use the new .gen tests to implement __verbose_abort tests
This reduces the amount of boilerplate that we need to generate
for each commit. It also resolves a problem where the modular CI
would run extremely slow on this test because we'd define a macro
before including the standard library, defeating the module cache.
Differential Revision: https://reviews.llvm.org/D151156
Added:
libcxx/test/libcxx/assertions/headers_declare_verbose_abort.gen.py
libcxx/utils/libcxx/test/header_information.py
Modified:
libcxx/utils/generate_header_tests.py
Removed:
libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp
################################################################################
diff --git a/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.gen.py b/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.gen.py
new file mode 100644
index 0000000000000..2bf9b66f1be94
--- /dev/null
+++ b/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.gen.py
@@ -0,0 +1,35 @@
+#===----------------------------------------------------------------------===##
+#
+# 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
+#
+#===----------------------------------------------------------------------===##
+
+# Test that all public C++ headers define the verbose termination function, which
+# is required for users to be able to include any public header and then override
+# the function using a strong definition.
+
+# RUN: %{python} %s %{libcxx}/utils
+
+import sys
+sys.path.append(sys.argv[1])
+from libcxx.test.header_information import header_restrictions, public_headers
+
+for header in public_headers:
+ # Skip C compatibility headers.
+ if header.endswith('.h'):
+ continue
+
+ test_condition_begin = f'#if {header_restrictions[header]}' if header in header_restrictions else ''
+ test_condition_end = '#endif' if header in header_restrictions else ''
+ XFAIL = 'XFAIL' # Make sure Lit doesn't think we are XFAILing this test
+ print(f"""\
+//--- {header}.compile.pass.cpp
+// {XFAIL}: availability-verbose_abort-missing
+#include <__config>
+{test_condition_begin}
+#include <{header}>
+using HandlerType = decltype(std::__libcpp_verbose_abort);
+{test_condition_end}
+""")
diff --git a/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp b/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp
deleted file mode 100644
index 5587e21a131ad..0000000000000
--- a/libcxx/test/libcxx/assertions/headers_declare_verbose_abort.sh.cpp
+++ /dev/null
@@ -1,755 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// Test that all public C++ headers define the verbose termination function, which
-// is required for users to be able to include any public header and then override
-// the function using a strong definition.
-
-// XFAIL: availability-verbose_abort-missing
-
-/*
-BEGIN-SCRIPT
-
-for i, header in enumerate(public_headers):
- # Skip C compatibility headers.
- if header.endswith('.h'):
- continue
-
- vars = {
- 'run': 'RUN',
- 'i': i,
- 'restrictions': ' && ' + header_restrictions[header] if header in header_restrictions else '',
- 'header': header
- }
-
- print("""\
-// {run}: %{{build}} -DTEST_{i}
-#if defined(TEST_{i}){restrictions}
-# include <{header}>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-""".format(**vars))
-
-END-SCRIPT
-*/
-
-#include <__config>
-
-int main(int, char**) { return 0; }
-
-// DO NOT MANUALLY EDIT ANYTHING BETWEEN THE MARKERS BELOW
-// GENERATED-MARKER
-// RUN: %{build} -DTEST_0
-#if defined(TEST_0)
-# include <algorithm>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_1
-#if defined(TEST_1)
-# include <any>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_2
-#if defined(TEST_2)
-# include <array>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_3
-#if defined(TEST_3)
-# include <atomic>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_4
-#if defined(TEST_4) && !defined(_LIBCPP_HAS_NO_THREADS)
-# include <barrier>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_5
-#if defined(TEST_5)
-# include <bit>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_6
-#if defined(TEST_6)
-# include <bitset>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_7
-#if defined(TEST_7)
-# include <cassert>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_8
-#if defined(TEST_8)
-# include <ccomplex>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_9
-#if defined(TEST_9)
-# include <cctype>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_10
-#if defined(TEST_10)
-# include <cerrno>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_11
-#if defined(TEST_11)
-# include <cfenv>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_12
-#if defined(TEST_12)
-# include <cfloat>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_13
-#if defined(TEST_13)
-# include <charconv>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_14
-#if defined(TEST_14)
-# include <chrono>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_15
-#if defined(TEST_15)
-# include <cinttypes>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_16
-#if defined(TEST_16)
-# include <ciso646>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_17
-#if defined(TEST_17)
-# include <climits>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_18
-#if defined(TEST_18) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <clocale>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_19
-#if defined(TEST_19)
-# include <cmath>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_20
-#if defined(TEST_20) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <codecvt>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_21
-#if defined(TEST_21)
-# include <compare>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_22
-#if defined(TEST_22)
-# include <complex>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_24
-#if defined(TEST_24)
-# include <concepts>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_25
-#if defined(TEST_25)
-# include <condition_variable>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_26
-#if defined(TEST_26) && (defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)
-# include <coroutine>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_27
-#if defined(TEST_27)
-# include <csetjmp>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_28
-#if defined(TEST_28)
-# include <csignal>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_29
-#if defined(TEST_29)
-# include <cstdarg>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_30
-#if defined(TEST_30)
-# include <cstdbool>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_31
-#if defined(TEST_31)
-# include <cstddef>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_32
-#if defined(TEST_32)
-# include <cstdint>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_33
-#if defined(TEST_33)
-# include <cstdio>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_34
-#if defined(TEST_34)
-# include <cstdlib>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_35
-#if defined(TEST_35)
-# include <cstring>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_36
-#if defined(TEST_36)
-# include <ctgmath>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_37
-#if defined(TEST_37)
-# include <ctime>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_39
-#if defined(TEST_39)
-# include <cuchar>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_40
-#if defined(TEST_40) && !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
-# include <cwchar>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_41
-#if defined(TEST_41) && !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
-# include <cwctype>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_42
-#if defined(TEST_42)
-# include <deque>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_44
-#if defined(TEST_44)
-# include <exception>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_45
-#if defined(TEST_45)
-# include <execution>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_46
-#if defined(TEST_46)
-# include <expected>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_48
-#if defined(TEST_48) && !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
-# include <filesystem>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_50
-#if defined(TEST_50)
-# include <format>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_51
-#if defined(TEST_51)
-# include <forward_list>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_52
-#if defined(TEST_52) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) && !defined(_LIBCPP_HAS_NO_FSTREAM)
-# include <fstream>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_53
-#if defined(TEST_53)
-# include <functional>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_54
-#if defined(TEST_54) && !defined(_LIBCPP_HAS_NO_THREADS)
-# include <future>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_55
-#if defined(TEST_55)
-# include <initializer_list>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_57
-#if defined(TEST_57) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <iomanip>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_58
-#if defined(TEST_58) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <ios>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_59
-#if defined(TEST_59)
-# include <iosfwd>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_60
-#if defined(TEST_60) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <iostream>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_61
-#if defined(TEST_61) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <istream>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_62
-#if defined(TEST_62)
-# include <iterator>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_63
-#if defined(TEST_63) && !defined(_LIBCPP_HAS_NO_THREADS)
-# include <latch>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_64
-#if defined(TEST_64)
-# include <limits>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_66
-#if defined(TEST_66)
-# include <list>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_67
-#if defined(TEST_67) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <locale>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_69
-#if defined(TEST_69)
-# include <map>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_71
-#if defined(TEST_71)
-# include <mdspan>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_72
-#if defined(TEST_72)
-# include <memory>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_73
-#if defined(TEST_73)
-# include <memory_resource>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_74
-#if defined(TEST_74) && !defined(_LIBCPP_HAS_NO_THREADS)
-# include <mutex>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_75
-#if defined(TEST_75)
-# include <new>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_76
-#if defined(TEST_76)
-# include <numbers>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_77
-#if defined(TEST_77)
-# include <numeric>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_78
-#if defined(TEST_78)
-# include <optional>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_79
-#if defined(TEST_79) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <ostream>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_80
-#if defined(TEST_80)
-# include <queue>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_81
-#if defined(TEST_81)
-# include <random>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_82
-#if defined(TEST_82)
-# include <ranges>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_83
-#if defined(TEST_83)
-# include <ratio>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_84
-#if defined(TEST_84) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <regex>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_85
-#if defined(TEST_85)
-# include <scoped_allocator>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_86
-#if defined(TEST_86) && !defined(_LIBCPP_HAS_NO_THREADS)
-# include <semaphore>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_87
-#if defined(TEST_87)
-# include <set>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_89
-#if defined(TEST_89) && !defined(_LIBCPP_HAS_NO_THREADS)
-# include <shared_mutex>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_90
-#if defined(TEST_90)
-# include <source_location>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_91
-#if defined(TEST_91)
-# include <span>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_92
-#if defined(TEST_92) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <sstream>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_93
-#if defined(TEST_93)
-# include <stack>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_97
-#if defined(TEST_97)
-# include <stdexcept>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_101
-#if defined(TEST_101) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <streambuf>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_102
-#if defined(TEST_102)
-# include <string>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_104
-#if defined(TEST_104)
-# include <string_view>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_105
-#if defined(TEST_105) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <strstream>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_106
-#if defined(TEST_106)
-# include <system_error>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_108
-#if defined(TEST_108) && !defined(_LIBCPP_HAS_NO_THREADS)
-# include <thread>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_109
-#if defined(TEST_109)
-# include <tuple>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_110
-#if defined(TEST_110)
-# include <type_traits>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_111
-#if defined(TEST_111)
-# include <typeindex>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_112
-#if defined(TEST_112)
-# include <typeinfo>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_114
-#if defined(TEST_114)
-# include <unordered_map>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_115
-#if defined(TEST_115)
-# include <unordered_set>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_116
-#if defined(TEST_116)
-# include <utility>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_117
-#if defined(TEST_117)
-# include <valarray>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_118
-#if defined(TEST_118)
-# include <variant>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_119
-#if defined(TEST_119)
-# include <vector>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_120
-#if defined(TEST_120)
-# include <version>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_123
-#if defined(TEST_123) && __cplusplus >= 201103L
-# include <experimental/deque>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_124
-#if defined(TEST_124) && __cplusplus >= 201103L
-# include <experimental/forward_list>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_125
-#if defined(TEST_125) && __cplusplus >= 201103L
-# include <experimental/iterator>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_126
-#if defined(TEST_126) && __cplusplus >= 201103L
-# include <experimental/list>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_127
-#if defined(TEST_127) && __cplusplus >= 201103L
-# include <experimental/map>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_128
-#if defined(TEST_128) && __cplusplus >= 201103L
-# include <experimental/memory_resource>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_129
-#if defined(TEST_129) && __cplusplus >= 201103L
-# include <experimental/propagate_const>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_130
-#if defined(TEST_130) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L
-# include <experimental/regex>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_131
-#if defined(TEST_131) && __cplusplus >= 201103L
-# include <experimental/set>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_132
-#if defined(TEST_132) && __cplusplus >= 201103L
-# include <experimental/simd>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_133
-#if defined(TEST_133) && __cplusplus >= 201103L
-# include <experimental/string>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_134
-#if defined(TEST_134) && __cplusplus >= 201103L
-# include <experimental/type_traits>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_135
-#if defined(TEST_135) && __cplusplus >= 201103L
-# include <experimental/unordered_map>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_136
-#if defined(TEST_136) && __cplusplus >= 201103L
-# include <experimental/unordered_set>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_137
-#if defined(TEST_137) && __cplusplus >= 201103L
-# include <experimental/utility>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// RUN: %{build} -DTEST_138
-#if defined(TEST_138) && __cplusplus >= 201103L
-# include <experimental/vector>
- using HandlerType = decltype(std::__libcpp_verbose_abort);
-#endif
-
-// GENERATED-MARKER
diff --git a/libcxx/utils/generate_header_tests.py b/libcxx/utils/generate_header_tests.py
index 905e7a4cec4f4..439cf4862a249 100755
--- a/libcxx/utils/generate_header_tests.py
+++ b/libcxx/utils/generate_header_tests.py
@@ -7,68 +7,7 @@
import pathlib
import re
-header_restrictions = {
- "barrier": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "future": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "latch": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "mutex": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "semaphore": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "shared_mutex": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "stdatomic.h": "__cplusplus > 202002L && !defined(_LIBCPP_HAS_NO_THREADS)",
- "thread": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "filesystem": "!defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)",
- # TODO(LLVM-17): simplify this to __cplusplus >= 202002L
- "coroutine": "(defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)",
- "clocale": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "codecvt": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "fstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION) && !defined(_LIBCPP_HAS_NO_FSTREAM)",
- "iomanip": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "ios": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "iostream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "istream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "locale.h": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "locale": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "ostream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "regex": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "sstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "streambuf": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "strstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "wctype.h": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
- "cwctype": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
- "cwchar": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
- "wchar.h": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
- "experimental/algorithm": "__cplusplus >= 201103L",
- "experimental/deque": "__cplusplus >= 201103L",
- "experimental/forward_list": "__cplusplus >= 201103L",
- "experimental/functional": "__cplusplus >= 201103L",
- "experimental/iterator": "__cplusplus >= 201103L",
- "experimental/list": "__cplusplus >= 201103L",
- "experimental/map": "__cplusplus >= 201103L",
- "experimental/memory_resource": "__cplusplus >= 201103L",
- "experimental/propagate_const": "__cplusplus >= 201103L",
- "experimental/regex": "!defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L",
- "experimental/set": "__cplusplus >= 201103L",
- "experimental/simd": "__cplusplus >= 201103L",
- "experimental/span": "__cplusplus >= 201103L",
- "experimental/string": "__cplusplus >= 201103L",
- "experimental/type_traits": "__cplusplus >= 201103L",
- "experimental/unordered_map": "__cplusplus >= 201103L",
- "experimental/unordered_set": "__cplusplus >= 201103L",
- "experimental/utility": "__cplusplus >= 201103L",
- "experimental/vector": "__cplusplus >= 201103L",
-}
-
-private_headers_still_public_in_modules = [
- "__assert",
- "__config",
- "__config_site.in",
- "__debug",
- "__hash_table",
- "__threading_support",
- "__tree",
- "__undef_macros",
- "__verbose_abort",
-]
+import libcxx.test.header_information
def find_script(file):
@@ -131,60 +70,21 @@ def produce(test_file, variables):
f.write(new_content)
-def is_header(file):
- """Returns whether the given file is a header (i.e. not a directory or the modulemap file)."""
- return (
- not file.is_dir()
- and not file.name == "module.modulemap.in"
- and file.name != "libcxx.imp"
- )
-
-
def main():
monorepo_root = pathlib.Path(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
)
- include = pathlib.Path(os.path.join(monorepo_root, "libcxx", "include"))
test = pathlib.Path(os.path.join(monorepo_root, "libcxx", "test"))
assert monorepo_root.exists()
- toplevel_headers = sorted(
- str(p.relative_to(include)) for p in include.glob("[a-z]*") if is_header(p)
- )
- experimental_headers = sorted(
- str(p.relative_to(include))
- for p in include.glob("experimental/[a-z]*")
- if is_header(p)
- )
- public_headers = toplevel_headers + experimental_headers
- private_headers = sorted(
- str(p.relative_to(include))
- for p in include.rglob("*")
- if is_header(p)
- and str(p.relative_to(include)).startswith("__")
- and not p.name.startswith("pstl")
- )
- variables = {
- "toplevel_headers": toplevel_headers,
- "experimental_headers": experimental_headers,
- "public_headers": public_headers,
- "private_headers": private_headers,
- "header_restrictions": header_restrictions,
- "private_headers_still_public_in_modules": private_headers_still_public_in_modules,
- }
-
- produce(
- test.joinpath("libcxx/assertions/headers_declare_verbose_abort.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/modules_include.sh.cpp"), variables)
- produce(test.joinpath("libcxx/nasty_macros.compile.pass.cpp"), variables)
- produce(test.joinpath("libcxx/no_assert_include.compile.pass.cpp"), variables)
- produce(test.joinpath("libcxx/private_headers.verify.cpp"), variables)
- produce(test.joinpath("libcxx/transitive_includes.sh.cpp"), variables)
+ produce(test.joinpath("libcxx/clang_tidy.sh.cpp"), libcxx.test.header_information.variables)
+ produce(test.joinpath("libcxx/double_include.sh.cpp"), libcxx.test.header_information.variables)
+ produce(test.joinpath("libcxx/min_max_macros.compile.pass.cpp"), libcxx.test.header_information.variables)
+ produce(test.joinpath("libcxx/modules_include.sh.cpp"), libcxx.test.header_information.variables)
+ produce(test.joinpath("libcxx/nasty_macros.compile.pass.cpp"), libcxx.test.header_information.variables)
+ produce(test.joinpath("libcxx/no_assert_include.compile.pass.cpp"), libcxx.test.header_information.variables)
+ produce(test.joinpath("libcxx/private_headers.verify.cpp"), libcxx.test.header_information.variables)
+ produce(test.joinpath("libcxx/transitive_includes.sh.cpp"), libcxx.test.header_information.variables)
if __name__ == "__main__":
diff --git a/libcxx/utils/libcxx/test/header_information.py b/libcxx/utils/libcxx/test/header_information.py
new file mode 100644
index 0000000000000..1f4bb34248566
--- /dev/null
+++ b/libcxx/utils/libcxx/test/header_information.py
@@ -0,0 +1,113 @@
+# ===----------------------------------------------------------------------===##
+#
+# 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
+#
+# ===----------------------------------------------------------------------===##
+
+import os, pathlib
+
+header_restrictions = {
+ "barrier": "!defined(_LIBCPP_HAS_NO_THREADS)",
+ "future": "!defined(_LIBCPP_HAS_NO_THREADS)",
+ "latch": "!defined(_LIBCPP_HAS_NO_THREADS)",
+ "mutex": "!defined(_LIBCPP_HAS_NO_THREADS)",
+ "semaphore": "!defined(_LIBCPP_HAS_NO_THREADS)",
+ "shared_mutex": "!defined(_LIBCPP_HAS_NO_THREADS)",
+ "stdatomic.h": "__cplusplus > 202002L && !defined(_LIBCPP_HAS_NO_THREADS)",
+ "thread": "!defined(_LIBCPP_HAS_NO_THREADS)",
+ "filesystem": "!defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)",
+ # TODO(LLVM-17): simplify this to __cplusplus >= 202002L
+ "coroutine": "(defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)",
+ "clocale": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "codecvt": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "fstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION) && !defined(_LIBCPP_HAS_NO_FSTREAM)",
+ "iomanip": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "ios": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "iostream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "istream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "locale.h": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "locale": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "ostream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "regex": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "sstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "streambuf": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "strstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
+ "wctype.h": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
+ "cwctype": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
+ "cwchar": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
+ "wchar.h": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
+ "experimental/algorithm": "__cplusplus >= 201103L",
+ "experimental/deque": "__cplusplus >= 201103L",
+ "experimental/forward_list": "__cplusplus >= 201103L",
+ "experimental/functional": "__cplusplus >= 201103L",
+ "experimental/iterator": "__cplusplus >= 201103L",
+ "experimental/list": "__cplusplus >= 201103L",
+ "experimental/map": "__cplusplus >= 201103L",
+ "experimental/memory_resource": "__cplusplus >= 201103L",
+ "experimental/propagate_const": "__cplusplus >= 201103L",
+ "experimental/regex": "!defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L",
+ "experimental/set": "__cplusplus >= 201103L",
+ "experimental/simd": "__cplusplus >= 201103L",
+ "experimental/span": "__cplusplus >= 201103L",
+ "experimental/string": "__cplusplus >= 201103L",
+ "experimental/type_traits": "__cplusplus >= 201103L",
+ "experimental/unordered_map": "__cplusplus >= 201103L",
+ "experimental/unordered_set": "__cplusplus >= 201103L",
+ "experimental/utility": "__cplusplus >= 201103L",
+ "experimental/vector": "__cplusplus >= 201103L",
+}
+
+private_headers_still_public_in_modules = [
+ "__assert",
+ "__config",
+ "__config_site.in",
+ "__debug",
+ "__hash_table",
+ "__threading_support",
+ "__tree",
+ "__undef_macros",
+ "__verbose_abort",
+]
+
+def is_header(file):
+ """Returns whether the given file is a header (i.e. not a directory or the modulemap file)."""
+ return (
+ not file.is_dir()
+ and not file.name == "module.modulemap.in"
+ and not file.name == "CMakeLists.txt"
+ and file.name != "libcxx.imp"
+ )
+
+monorepo_root = pathlib.Path(
+ os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
+)
+include = pathlib.Path(os.path.join(monorepo_root, "libcxx", "include"))
+test = pathlib.Path(os.path.join(monorepo_root, "libcxx", "test"))
+assert monorepo_root.exists()
+
+toplevel_headers = sorted(
+ str(p.relative_to(include)) for p in include.glob("[a-z]*") if is_header(p)
+)
+experimental_headers = sorted(
+ str(p.relative_to(include))
+ for p in include.glob("experimental/[a-z]*")
+ if is_header(p)
+)
+public_headers = toplevel_headers + experimental_headers
+private_headers = sorted(
+ str(p.relative_to(include))
+ for p in include.rglob("*")
+ if is_header(p)
+ and str(p.relative_to(include)).startswith("__")
+ and not p.name.startswith("pstl")
+)
+variables = {
+ "toplevel_headers": toplevel_headers,
+ "experimental_headers": experimental_headers,
+ "public_headers": public_headers,
+ "private_headers": private_headers,
+ "header_restrictions": header_restrictions,
+ "private_headers_still_public_in_modules": private_headers_still_public_in_modules,
+}
More information about the libcxx-commits
mailing list