[libc++] Granularize chrono includes
authorNikolas Klauser <nikolasklauser@berlin.de>
Wed, 23 Feb 2022 22:05:22 +0000 (23:05 +0100)
committerNikolas Klauser <nikolasklauser@berlin.de>
Wed, 23 Feb 2022 22:06:26 +0000 (23:06 +0100)
Reviewed By: Quuxplusone, #libc

Spies: libcxx-commits

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

19 files changed:
libcxx/docs/ReleaseNotes.rst
libcxx/include/__filesystem/directory_entry.h
libcxx/include/__filesystem/file_time_type.h
libcxx/include/__filesystem/operations.h
libcxx/include/__mutex_base
libcxx/include/__thread/poll_with_backoff.h
libcxx/include/__thread/timed_backoff_policy.h
libcxx/include/__threading_support
libcxx/include/atomic
libcxx/include/future
libcxx/include/semaphore
libcxx/include/thread
libcxx/test/std/thread/futures/futures.async/async.pass.cpp
libcxx/test/std/thread/futures/futures.shared_future/wait.pass.cpp
libcxx/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp
libcxx/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp
libcxx/test/std/thread/futures/futures.unique_future/wait.pass.cpp
libcxx/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp
libcxx/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp

index 1e24ad6..ce13166 100644 (file)
@@ -53,10 +53,10 @@ API Changes
   ``<filesystem>`` header. The associated macro
   ``_LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM`` has also been removed.
 
-- Transitive includes of ``<algorithm>`` have been removed. If you see compiler errors
-  related to missing declarations inside namespace ``std`` when updating libc++,
-  you are probably missing ``#include <algorithm>`` in a file where you use algorithms.
-
+- Some libc++ headers no longer transitively include all of ``<algorithm>``and ``<chrono>``.
+  If, after updating libc++, you see compiler errors related to missing declarations in
+  namespace ``std``, it might be because one of your source files now needs to
+  ``#include <algorithm>`` and/or ``#include <chrono>``.
 ABI Changes
 -----------
 
index a1f18ad..3db2445 100644 (file)
@@ -11,6 +11,7 @@
 #define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
 
 #include <__availability>
+#include <__chrono/time_point.h>
 #include <__config>
 #include <__errc>
 #include <__filesystem/file_status.h>
@@ -21,7 +22,6 @@
 #include <__filesystem/path.h>
 #include <__filesystem/perms.h>
 #include <__utility/unreachable.h>
-#include <chrono>
 #include <cstdint>
 #include <cstdlib>
 #include <iosfwd>
index 620b5ec..7c4932e 100644 (file)
@@ -11,8 +11,9 @@
 #define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H
 
 #include <__availability>
+#include <__chrono/file_clock.h>
+#include <__chrono/time_point.h>
 #include <__config>
-#include <chrono>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 894c501..85c71f0 100644 (file)
@@ -11,6 +11,7 @@
 #define _LIBCPP___FILESYSTEM_OPERATIONS_H
 
 #include <__availability>
+#include <__chrono/time_point.h>
 #include <__config>
 #include <__filesystem/copy_options.h>
 #include <__filesystem/file_status.h>
@@ -20,7 +21,6 @@
 #include <__filesystem/perm_options.h>
 #include <__filesystem/perms.h>
 #include <__filesystem/space_info.h>
-#include <chrono>
 #include <cstdint>
 #include <system_error>
 
index 78eda08..da056b6 100644 (file)
 #ifndef _LIBCPP___MUTEX_BASE
 #define _LIBCPP___MUTEX_BASE
 
+#include <__chrono/duration.h>
+#include <__chrono/steady_clock.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
 #include <__config>
 #include <__threading_support>
-#include <chrono>
 #include <ratio>
 #include <system_error>
 #include <time.h>
index 9b084b3..0bbafd1 100644 (file)
 #define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
 
 #include <__availability>
+#include <__chrono/duration.h>
+#include <__chrono/high_resolution_clock.h>
+#include <__chrono/steady_clock.h>
+#include <__chrono/time_point.h>
 #include <__config>
-#include <chrono>
+#include <__filesystem/file_time_type.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 58c2390..28fe75d 100644 (file)
@@ -13,8 +13,8 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-#include <__threading_support>
-#include <chrono>
+#  include <__chrono/duration.h>
+#  include <__threading_support>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 11899e6..4f1640a 100644 (file)
 #define _LIBCPP_THREADING_SUPPORT
 
 #include <__availability>
+#include <__chrono/convert_to_timespec.h>
+#include <__chrono/duration.h>
 #include <__config>
 #include <__thread/poll_with_backoff.h>
-#include <chrono>
 #include <errno.h>
 #include <iosfwd>
 #include <limits>
index 4a5c484..dfa01bf 100644 (file)
@@ -519,6 +519,7 @@ template <class T>
 */
 
 #include <__availability>
+#include <__chrono/duration.h>
 #include <__config>
 #include <__thread/poll_with_backoff.h>
 #include <__thread/timed_backoff_policy.h>
index 15685df..fff746a 100644 (file)
@@ -363,12 +363,13 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
 
 #include <__assert>
 #include <__availability>
+#include <__chrono/duration.h>
+#include <__chrono/time_point.h>
 #include <__config>
 #include <__memory/allocator_arg_t.h>
 #include <__memory/uses_allocator.h>
 #include <__utility/auto_cast.h>
 #include <__utility/forward.h>
-#include <chrono>
 #include <exception>
 #include <memory>
 #include <mutex>
@@ -376,6 +377,8 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
 #include <thread>
 #include <version>
 
+#include <chrono> // TODO: Remove unused header
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
index 753d50f..df7b0d9 100644 (file)
@@ -46,6 +46,7 @@ using binary_semaphore = counting_semaphore<1>;
 */
 
 #include <__availability>
+#include <__chrono/time_point.h>
 #include <__config>
 #include <__thread/timed_backoff_policy.h>
 #include <__threading_support>
index b059cfb..5a8e830 100644 (file)
@@ -89,7 +89,6 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
 #include <__thread/timed_backoff_policy.h>
 #include <__threading_support>
 #include <__utility/forward.h>
-#include <chrono>
 #include <cstddef>
 #include <functional>
 #include <iosfwd>
index 5eded05..2fdafec 100644 (file)
 //     async(launch policy, F&& f, Args&&... args);
 
 
-#include <future>
 #include <atomic>
-#include <memory>
 #include <cassert>
+#include <chrono>
+#include <future>
+#include <memory>
 
 #include "test_macros.h"
 
index 4be8c1b..26a5f1f 100644 (file)
@@ -15,8 +15,9 @@
 
 // void wait() const;
 
-#include <future>
 #include <cassert>
+#include <chrono>
+#include <future>
 
 #include "make_test_thread.h"
 #include "test_macros.h"
index d8b0ce3..44b88f3 100644 (file)
@@ -17,8 +17,9 @@
 //   future_status
 //   wait_for(const chrono::duration<Rep, Period>& rel_time) const;
 
-#include <future>
 #include <cassert>
+#include <chrono>
+#include <future>
 
 #include "make_test_thread.h"
 #include "test_macros.h"
index 1d58dc2..fc356dc 100644 (file)
 //   future_status
 //   wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
 
-#include <future>
 #include <atomic>
 #include <cassert>
+#include <chrono>
+#include <future>
 
 #include "make_test_thread.h"
 #include "test_macros.h"
index 712ee3b..2b9b0f6 100644 (file)
@@ -15,8 +15,9 @@
 
 // void wait() const;
 
-#include <future>
 #include <cassert>
+#include <chrono>
+#include <future>
 
 #include "make_test_thread.h"
 #include "test_macros.h"
index ff5d979..3f41bc1 100644 (file)
@@ -19,8 +19,9 @@
 //   future_status
 //   wait_for(const chrono::duration<Rep, Period>& rel_time) const;
 
-#include <future>
 #include <cassert>
+#include <chrono>
+#include <future>
 
 #include "make_test_thread.h"
 #include "test_macros.h"
index e5171e5..d4e27d9 100644 (file)
 //   future_status
 //   wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
 
-#include <future>
 #include <atomic>
 #include <cassert>
+#include <chrono>
+#include <future>
 
 #include "make_test_thread.h"
 #include "test_macros.h"