[libcxx-commits] [libcxx] [libc++] Remove obsolete header restrictions (PR #107437)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Sep 5 10:30:38 PDT 2024
https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/107437
The _LIBCPP_HAS_NO_THREADS and _LIBCPP_HAS_NO_LOCALIZATION carve-outs do not result in hard errors anymore, but the patch that changed that forgot to update the header restrictions we use to auto-generate several files.
>From 7ae129b03fcab43e8a77aa99a4b4b9c019d79892 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 5 Sep 2024 13:27:33 -0400
Subject: [PATCH] [libc++] Remove obsolete header restrictions
The _LIBCPP_HAS_NO_THREADS and _LIBCPP_HAS_NO_LOCALIZATION carve-outs
do not result in hard errors anymore, but the patch that changed that
forgot to update the header restrictions we use to auto-generate
several files.
---
libcxx/include/__std_clang_module | 92 ++++++-----------------
libcxx/modules/std.compat.cppm.in | 4 +-
libcxx/modules/std.cppm.in | 84 ++++++---------------
libcxx/utils/libcxx/header_information.py | 28 -------
4 files changed, 45 insertions(+), 163 deletions(-)
diff --git a/libcxx/include/__std_clang_module b/libcxx/include/__std_clang_module
index 18d6ce6b46c1f6..703c8099ed584a 100644
--- a/libcxx/include/__std_clang_module
+++ b/libcxx/include/__std_clang_module
@@ -33,9 +33,7 @@
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
# include <atomic>
#endif
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <barrier>
-#endif
+#include <barrier>
#include <bit>
#include <bitset>
#include <cassert>
@@ -49,13 +47,9 @@
#include <cinttypes>
#include <ciso646>
#include <climits>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <clocale>
-#endif
+#include <clocale>
#include <cmath>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <codecvt>
-#endif
+#include <codecvt>
#include <compare>
#include <complex.h>
#include <complex>
@@ -97,40 +91,22 @@
#include <float.h>
#include <format>
#include <forward_list>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <fstream>
-#endif
+#include <fstream>
#include <functional>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <future>
-#endif
+#include <future>
#include <initializer_list>
#include <inttypes.h>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <iomanip>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <ios>
-#endif
+#include <iomanip>
+#include <ios>
#include <iosfwd>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <iostream>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <istream>
-#endif
+#include <iostream>
+#include <istream>
#include <iterator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <latch>
-#endif
+#include <latch>
#include <limits>
#include <list>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <locale.h>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <locale>
-#endif
+#include <locale.h>
+#include <locale>
#include <map>
#include <math.h>
#include <mdspan>
@@ -141,60 +117,38 @@
#include <numbers>
#include <numeric>
#include <optional>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <ostream>
-#endif
+#include <ostream>
#include <print>
#include <queue>
#include <random>
#include <ranges>
#include <ratio>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <regex>
-#endif
+#include <regex>
#include <scoped_allocator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <semaphore>
-#endif
+#include <semaphore>
#include <set>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <shared_mutex>
-#endif
+#include <shared_mutex>
#include <source_location>
#include <span>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <sstream>
-#endif
+#include <sstream>
#include <stack>
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
-# include <stdatomic.h>
-#endif
+#include <stdatomic.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdexcept>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <stop_token>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <streambuf>
-#endif
+#include <stop_token>
+#include <streambuf>
#include <string.h>
#include <string>
#include <string_view>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <strstream>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <syncstream>
-#endif
+#include <strstream>
+#include <syncstream>
#include <system_error>
#include <tgmath.h>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <thread>
-#endif
+#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
diff --git a/libcxx/modules/std.compat.cppm.in b/libcxx/modules/std.compat.cppm.in
index 0f547a2dc8b715..d743da50ca04f0 100644
--- a/libcxx/modules/std.compat.cppm.in
+++ b/libcxx/modules/std.compat.cppm.in
@@ -24,9 +24,7 @@ module;
#include <cfloat>
#include <cinttypes>
#include <climits>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <clocale>
-#endif
+#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
diff --git a/libcxx/modules/std.cppm.in b/libcxx/modules/std.cppm.in
index ad8a639b7f71a1..4a3cc2d38fc6b3 100644
--- a/libcxx/modules/std.cppm.in
+++ b/libcxx/modules/std.cppm.in
@@ -23,9 +23,7 @@ module;
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
# include <atomic>
#endif
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <barrier>
-#endif
+#include <barrier>
#include <bit>
#include <bitset>
#include <cassert>
@@ -37,13 +35,9 @@ module;
#include <chrono>
#include <cinttypes>
#include <climits>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <clocale>
-#endif
+#include <clocale>
#include <cmath>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <codecvt>
-#endif
+#include <codecvt>
#include <compare>
#include <complex>
#include <concepts>
@@ -72,36 +66,20 @@ module;
#include <filesystem>
#include <format>
#include <forward_list>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <fstream>
-#endif
+#include <fstream>
#include <functional>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <future>
-#endif
+#include <future>
#include <initializer_list>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <iomanip>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <ios>
-#endif
+#include <iomanip>
+#include <ios>
#include <iosfwd>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <iostream>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <istream>
-#endif
+#include <iostream>
+#include <istream>
#include <iterator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <latch>
-#endif
+#include <latch>
#include <limits>
#include <list>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <locale>
-#endif
+#include <locale>
#include <map>
#include <mdspan>
#include <memory>
@@ -111,50 +89,30 @@ module;
#include <numbers>
#include <numeric>
#include <optional>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <ostream>
-#endif
+#include <ostream>
#include <print>
#include <queue>
#include <random>
#include <ranges>
#include <ratio>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <regex>
-#endif
+#include <regex>
#include <scoped_allocator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <semaphore>
-#endif
+#include <semaphore>
#include <set>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <shared_mutex>
-#endif
+#include <shared_mutex>
#include <source_location>
#include <span>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <sstream>
-#endif
+#include <sstream>
#include <stack>
#include <stdexcept>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <stop_token>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <streambuf>
-#endif
+#include <stop_token>
+#include <streambuf>
#include <string>
#include <string_view>
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <strstream>
-#endif
-#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# include <syncstream>
-#endif
+#include <strstream>
+#include <syncstream>
#include <system_error>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-# include <thread>
-#endif
+#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index 166c9a77c08e70..c2b900670d4c93 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -11,34 +11,6 @@
header_restrictions = {
# headers with #error directives
"atomic": "!defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)",
- "stdatomic.h": "!defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)",
-
- # headers with #error directives
- "ios": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "locale.h": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- # transitive includers of the above headers
- "clocale": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "codecvt": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "fstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "iomanip": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "iostream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
- "istream": "!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)",
- "syncstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
-
- # headers with #error directives
- "barrier": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "future": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "latch": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "semaphore": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "shared_mutex": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "stop_token": "!defined(_LIBCPP_HAS_NO_THREADS)",
- "thread": "!defined(_LIBCPP_HAS_NO_THREADS)",
# headers with #error directives
"wchar.h": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
More information about the libcxx-commits
mailing list