[libcxx-commits] [libcxx] [libc++] Avoid including <string> in <mutex> (PR #116254)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Nov 16 10:25:41 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Nikolas Klauser (philnik777)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/116254.diff
15 Files Affected:
- (modified) libcxx/include/CMakeLists.txt (+1)
- (modified) libcxx/include/__condition_variable/condition_variable.h (+1-1)
- (modified) libcxx/include/__mutex/unique_lock.h (+1-1)
- (modified) libcxx/include/__system_error/system_error.h (-1)
- (added) libcxx/include/__system_error/throw_system_error.h (+25)
- (modified) libcxx/include/__thread/thread.h (+4-1)
- (modified) libcxx/include/module.modulemap (+1)
- (modified) libcxx/include/print (+1-1)
- (modified) libcxx/include/shared_mutex (+1-1)
- (modified) libcxx/src/chrono.cpp (+1-1)
- (modified) libcxx/src/filesystem/filesystem_clock.cpp (+1)
- (modified) libcxx/src/random.cpp (+1-1)
- (modified) libcxx/src/system_error.cpp (+1)
- (modified) libcxx/test/libcxx/transitive_includes/cxx23.csv (-44)
- (modified) libcxx/test/libcxx/transitive_includes/cxx26.csv (-44)
``````````diff
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 1610d1ee848a5f..9f5901cd471e73 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -716,6 +716,7 @@ set(files
__system_error/error_code.h
__system_error/error_condition.h
__system_error/system_error.h
+ __system_error/throw_system_error.h
__thread/formatter.h
__thread/id.h
__thread/jthread.h
diff --git a/libcxx/include/__condition_variable/condition_variable.h b/libcxx/include/__condition_variable/condition_variable.h
index 499e6f0f295dd3..4521fe274614ef 100644
--- a/libcxx/include/__condition_variable/condition_variable.h
+++ b/libcxx/include/__condition_variable/condition_variable.h
@@ -16,7 +16,7 @@
#include <__config>
#include <__mutex/mutex.h>
#include <__mutex/unique_lock.h>
-#include <__system_error/system_error.h>
+#include <__system_error/throw_system_error.h>
#include <__thread/support.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_floating_point.h>
diff --git a/libcxx/include/__mutex/unique_lock.h b/libcxx/include/__mutex/unique_lock.h
index c404921070f913..3642ab93cb1f7c 100644
--- a/libcxx/include/__mutex/unique_lock.h
+++ b/libcxx/include/__mutex/unique_lock.h
@@ -14,7 +14,7 @@
#include <__config>
#include <__memory/addressof.h>
#include <__mutex/tag_types.h>
-#include <__system_error/system_error.h>
+#include <__system_error/throw_system_error.h>
#include <__utility/swap.h>
#include <cerrno>
diff --git a/libcxx/include/__system_error/system_error.h b/libcxx/include/__system_error/system_error.h
index 2763aaba88f5fa..918effb6917cb4 100644
--- a/libcxx/include/__system_error/system_error.h
+++ b/libcxx/include/__system_error/system_error.h
@@ -39,7 +39,6 @@ class _LIBCPP_EXPORTED_FROM_ABI system_error : public runtime_error {
_LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; }
};
-[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg);
[[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) {
#if _LIBCPP_HAS_EXCEPTIONS
throw system_error(__ec, __what_arg);
diff --git a/libcxx/include/__system_error/throw_system_error.h b/libcxx/include/__system_error/throw_system_error.h
new file mode 100644
index 00000000000000..e4605b6f014dc5
--- /dev/null
+++ b/libcxx/include/__system_error/throw_system_error.h
@@ -0,0 +1,25 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H
+#define _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H
diff --git a/libcxx/include/__thread/thread.h b/libcxx/include/__thread/thread.h
index f417abc07b87c5..c40ffd25b903c2 100644
--- a/libcxx/include/__thread/thread.h
+++ b/libcxx/include/__thread/thread.h
@@ -18,10 +18,13 @@
#include <__functional/unary_function.h>
#include <__memory/unique_ptr.h>
#include <__mutex/mutex.h>
-#include <__system_error/system_error.h>
+#include <__system_error/throw_system_error.h>
#include <__thread/id.h>
#include <__thread/support.h>
#include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/remove_cvref.h>
#include <__utility/forward.h>
#include <tuple>
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index cd08b2810e437b..618261bd4eaa56 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -1921,6 +1921,7 @@ module std [system] {
}
module error_condition { header "__system_error/error_condition.h" }
module system_error { header "__system_error/system_error.h" }
+ module throw_system_error { header "__system_error/throw_system_error.h" }
header "system_error"
export *
diff --git a/libcxx/include/print b/libcxx/include/print
index 7c808300701383..8a8b686d18f34d 100644
--- a/libcxx/include/print
+++ b/libcxx/include/print
@@ -36,7 +36,7 @@ namespace std {
#include <__assert>
#include <__concepts/same_as.h>
#include <__config>
-#include <__system_error/system_error.h>
+#include <__system_error/throw_system_error.h>
#include <__utility/forward.h>
#include <cerrno>
#include <cstdio>
diff --git a/libcxx/include/shared_mutex b/libcxx/include/shared_mutex
index 68030e9ce8ff4e..2552119405419c 100644
--- a/libcxx/include/shared_mutex
+++ b/libcxx/include/shared_mutex
@@ -134,7 +134,7 @@ template <class Mutex>
# include <__mutex/mutex.h>
# include <__mutex/tag_types.h>
# include <__mutex/unique_lock.h>
-# include <__system_error/system_error.h>
+# include <__system_error/throw_system_error.h>
# include <__utility/swap.h>
# include <cerrno>
# include <version>
diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp
index 098b6a171c8892..35105693b9f900 100644
--- a/libcxx/src/chrono.cpp
+++ b/libcxx/src/chrono.cpp
@@ -12,7 +12,7 @@
# define _LARGE_TIME_API
#endif
-#include <__system_error/system_error.h>
+#include <__system_error/throw_system_error.h>
#include <cerrno> // errno
#include <chrono>
diff --git a/libcxx/src/filesystem/filesystem_clock.cpp b/libcxx/src/filesystem/filesystem_clock.cpp
index e4cfb9e72845c6..d174ecdc9e1060 100644
--- a/libcxx/src/filesystem/filesystem_clock.cpp
+++ b/libcxx/src/filesystem/filesystem_clock.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include <__config>
+#include <__system_error/throw_system_error.h>
#include <chrono>
#include <filesystem>
#include <time.h>
diff --git a/libcxx/src/random.cpp b/libcxx/src/random.cpp
index 14c6f4473d70b9..3830e3918d2ee4 100644
--- a/libcxx/src/random.cpp
+++ b/libcxx/src/random.cpp
@@ -13,7 +13,7 @@
# define _CRT_RAND_S
#endif // defined(_LIBCPP_USING_WIN32_RANDOM)
-#include <__system_error/system_error.h>
+#include <__system_error/throw_system_error.h>
#include <limits>
#include <random>
diff --git a/libcxx/src/system_error.cpp b/libcxx/src/system_error.cpp
index 53838c6c6d219b..d555bca995c454 100644
--- a/libcxx/src/system_error.cpp
+++ b/libcxx/src/system_error.cpp
@@ -8,6 +8,7 @@
#include <__assert>
#include <__config>
+#include <__system_error/throw_system_error.h>
#include <__verbose_abort>
#include <cerrno>
#include <cstdio>
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 854ad1b5df6f1e..1ba6afdb215f90 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -199,25 +199,15 @@ complex typeinfo
complex version
concepts version
condition_variable atomic
-condition_variable cctype
condition_variable cerrno
condition_variable climits
-condition_variable compare
condition_variable cstdint
-condition_variable cstdio
condition_variable cstring
condition_variable ctime
-condition_variable cwchar
-condition_variable cwctype
condition_variable initializer_list
-condition_variable iosfwd
condition_variable limits
condition_variable new
condition_variable ratio
-condition_variable stdexcept
-condition_variable string
-condition_variable string_view
-condition_variable tuple
condition_variable typeinfo
condition_variable version
coroutine compare
@@ -709,46 +699,25 @@ memory new
memory tuple
memory typeinfo
memory version
-memory_resource cctype
memory_resource cerrno
memory_resource climits
memory_resource compare
memory_resource cstdint
-memory_resource cstdio
-memory_resource cstring
memory_resource ctime
-memory_resource cwchar
-memory_resource cwctype
-memory_resource initializer_list
-memory_resource iosfwd
memory_resource limits
memory_resource mutex
memory_resource new
memory_resource ratio
-memory_resource stdexcept
-memory_resource string
-memory_resource string_view
memory_resource tuple
memory_resource typeinfo
memory_resource version
-mutex cctype
mutex cerrno
mutex climits
mutex compare
mutex cstdint
-mutex cstdio
-mutex cstring
mutex ctime
-mutex cwchar
-mutex cwctype
-mutex initializer_list
-mutex iosfwd
mutex limits
-mutex new
mutex ratio
-mutex stdexcept
-mutex string
-mutex string_view
mutex tuple
mutex typeinfo
mutex version
@@ -951,25 +920,12 @@ set new
set optional
set tuple
set version
-shared_mutex cctype
shared_mutex cerrno
shared_mutex climits
-shared_mutex compare
shared_mutex cstdint
-shared_mutex cstdio
-shared_mutex cstring
shared_mutex ctime
-shared_mutex cwchar
-shared_mutex cwctype
-shared_mutex initializer_list
-shared_mutex iosfwd
shared_mutex limits
-shared_mutex new
shared_mutex ratio
-shared_mutex stdexcept
-shared_mutex string
-shared_mutex string_view
-shared_mutex tuple
shared_mutex version
source_location cstdint
source_location version
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index ba2faaee5e3757..56756ce00bd6e0 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -199,25 +199,15 @@ complex typeinfo
complex version
concepts version
condition_variable atomic
-condition_variable cctype
condition_variable cerrno
condition_variable climits
-condition_variable compare
condition_variable cstdint
-condition_variable cstdio
condition_variable cstring
condition_variable ctime
-condition_variable cwchar
-condition_variable cwctype
condition_variable initializer_list
-condition_variable iosfwd
condition_variable limits
condition_variable new
condition_variable ratio
-condition_variable stdexcept
-condition_variable string
-condition_variable string_view
-condition_variable tuple
condition_variable typeinfo
condition_variable version
coroutine compare
@@ -708,46 +698,25 @@ memory new
memory tuple
memory typeinfo
memory version
-memory_resource cctype
memory_resource cerrno
memory_resource climits
memory_resource compare
memory_resource cstdint
-memory_resource cstdio
-memory_resource cstring
memory_resource ctime
-memory_resource cwchar
-memory_resource cwctype
-memory_resource initializer_list
-memory_resource iosfwd
memory_resource limits
memory_resource mutex
memory_resource new
memory_resource ratio
-memory_resource stdexcept
-memory_resource string
-memory_resource string_view
memory_resource tuple
memory_resource typeinfo
memory_resource version
-mutex cctype
mutex cerrno
mutex climits
mutex compare
mutex cstdint
-mutex cstdio
-mutex cstring
mutex ctime
-mutex cwchar
-mutex cwctype
-mutex initializer_list
-mutex iosfwd
mutex limits
-mutex new
mutex ratio
-mutex stdexcept
-mutex string
-mutex string_view
mutex tuple
mutex typeinfo
mutex version
@@ -950,25 +919,12 @@ set new
set optional
set tuple
set version
-shared_mutex cctype
shared_mutex cerrno
shared_mutex climits
-shared_mutex compare
shared_mutex cstdint
-shared_mutex cstdio
-shared_mutex cstring
shared_mutex ctime
-shared_mutex cwchar
-shared_mutex cwctype
-shared_mutex initializer_list
-shared_mutex iosfwd
shared_mutex limits
-shared_mutex new
shared_mutex ratio
-shared_mutex stdexcept
-shared_mutex string
-shared_mutex string_view
-shared_mutex tuple
shared_mutex version
source_location cstdint
source_location version
``````````
</details>
https://github.com/llvm/llvm-project/pull/116254
More information about the libcxx-commits
mailing list