Skip to content

Commit 489637e

Browse files
committed
[libc++] Granularize chrono includes
Reviewed By: Quuxplusone, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D120141
1 parent 8f780ba commit 489637e

File tree

19 files changed

+42
-22
lines changed

19 files changed

+42
-22
lines changed

libcxx/docs/ReleaseNotes.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ API Changes
5353
``<filesystem>`` header. The associated macro
5454
``_LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM`` has also been removed.
5555

56-
- Transitive includes of ``<algorithm>`` have been removed. If you see compiler errors
57-
related to missing declarations inside namespace ``std`` when updating libc++,
58-
you are probably missing ``#include <algorithm>`` in a file where you use algorithms.
59-
56+
- Some libc++ headers no longer transitively include all of ``<algorithm>``and ``<chrono>``.
57+
If, after updating libc++, you see compiler errors related to missing declarations in
58+
namespace ``std``, it might be because one of your source files now needs to
59+
``#include <algorithm>`` and/or ``#include <chrono>``.
6060
ABI Changes
6161
-----------
6262

libcxx/include/__filesystem/directory_entry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
1212

1313
#include <__availability>
14+
#include <__chrono/time_point.h>
1415
#include <__config>
1516
#include <__errc>
1617
#include <__filesystem/file_status.h>
@@ -21,7 +22,6 @@
2122
#include <__filesystem/path.h>
2223
#include <__filesystem/perms.h>
2324
#include <__utility/unreachable.h>
24-
#include <chrono>
2525
#include <cstdint>
2626
#include <cstdlib>
2727
#include <iosfwd>

libcxx/include/__filesystem/file_time_type.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
#define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H
1212

1313
#include <__availability>
14+
#include <__chrono/file_clock.h>
15+
#include <__chrono/time_point.h>
1416
#include <__config>
15-
#include <chrono>
1617

1718
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1819
# pragma GCC system_header

libcxx/include/__filesystem/operations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define _LIBCPP___FILESYSTEM_OPERATIONS_H
1212

1313
#include <__availability>
14+
#include <__chrono/time_point.h>
1415
#include <__config>
1516
#include <__filesystem/copy_options.h>
1617
#include <__filesystem/file_status.h>
@@ -20,7 +21,6 @@
2021
#include <__filesystem/perm_options.h>
2122
#include <__filesystem/perms.h>
2223
#include <__filesystem/space_info.h>
23-
#include <chrono>
2424
#include <cstdint>
2525
#include <system_error>
2626

libcxx/include/__mutex_base

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
#ifndef _LIBCPP___MUTEX_BASE
1111
#define _LIBCPP___MUTEX_BASE
1212

13+
#include <__chrono/duration.h>
14+
#include <__chrono/steady_clock.h>
15+
#include <__chrono/system_clock.h>
16+
#include <__chrono/time_point.h>
1317
#include <__config>
1418
#include <__threading_support>
15-
#include <chrono>
1619
#include <ratio>
1720
#include <system_error>
1821
#include <time.h>

libcxx/include/__thread/poll_with_backoff.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
1111

1212
#include <__availability>
13+
#include <__chrono/duration.h>
14+
#include <__chrono/high_resolution_clock.h>
15+
#include <__chrono/steady_clock.h>
16+
#include <__chrono/time_point.h>
1317
#include <__config>
14-
#include <chrono>
18+
#include <__filesystem/file_time_type.h>
1519

1620
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1721
# pragma GCC system_header

libcxx/include/__thread/timed_backoff_policy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
#ifndef _LIBCPP_HAS_NO_THREADS
1515

16-
#include <__threading_support>
17-
#include <chrono>
16+
# include <__chrono/duration.h>
17+
# include <__threading_support>
1818

1919
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2020
# pragma GCC system_header

libcxx/include/__threading_support

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
#define _LIBCPP_THREADING_SUPPORT
1212

1313
#include <__availability>
14+
#include <__chrono/convert_to_timespec.h>
15+
#include <__chrono/duration.h>
1416
#include <__config>
1517
#include <__thread/poll_with_backoff.h>
16-
#include <chrono>
1718
#include <errno.h>
1819
#include <iosfwd>
1920
#include <limits>

libcxx/include/atomic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ template <class T>
519519
*/
520520

521521
#include <__availability>
522+
#include <__chrono/duration.h>
522523
#include <__config>
523524
#include <__thread/poll_with_backoff.h>
524525
#include <__thread/timed_backoff_policy.h>

libcxx/include/future

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,19 +363,22 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
363363

364364
#include <__assert>
365365
#include <__availability>
366+
#include <__chrono/duration.h>
367+
#include <__chrono/time_point.h>
366368
#include <__config>
367369
#include <__memory/allocator_arg_t.h>
368370
#include <__memory/uses_allocator.h>
369371
#include <__utility/auto_cast.h>
370372
#include <__utility/forward.h>
371-
#include <chrono>
372373
#include <exception>
373374
#include <memory>
374375
#include <mutex>
375376
#include <system_error>
376377
#include <thread>
377378
#include <version>
378379

380+
#include <chrono> // TODO: Remove unused header
381+
379382
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
380383
# pragma GCC system_header
381384
#endif

libcxx/include/semaphore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ using binary_semaphore = counting_semaphore<1>;
4646
*/
4747

4848
#include <__availability>
49+
#include <__chrono/time_point.h>
4950
#include <__config>
5051
#include <__thread/timed_backoff_policy.h>
5152
#include <__threading_support>

libcxx/include/thread

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
8989
#include <__thread/timed_backoff_policy.h>
9090
#include <__threading_support>
9191
#include <__utility/forward.h>
92-
#include <chrono>
9392
#include <cstddef>
9493
#include <functional>
9594
#include <iosfwd>

libcxx/test/std/thread/futures/futures.async/async.pass.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
// async(launch policy, F&& f, Args&&... args);
2121

2222

23-
#include <future>
2423
#include <atomic>
25-
#include <memory>
2624
#include <cassert>
25+
#include <chrono>
26+
#include <future>
27+
#include <memory>
2728

2829
#include "test_macros.h"
2930

libcxx/test/std/thread/futures/futures.shared_future/wait.pass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
// void wait() const;
1717

18-
#include <future>
1918
#include <cassert>
19+
#include <chrono>
20+
#include <future>
2021

2122
#include "make_test_thread.h"
2223
#include "test_macros.h"

libcxx/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
// future_status
1818
// wait_for(const chrono::duration<Rep, Period>& rel_time) const;
1919

20-
#include <future>
2120
#include <cassert>
21+
#include <chrono>
22+
#include <future>
2223

2324
#include "make_test_thread.h"
2425
#include "test_macros.h"

libcxx/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
// future_status
1818
// wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
1919

20-
#include <future>
2120
#include <atomic>
2221
#include <cassert>
22+
#include <chrono>
23+
#include <future>
2324

2425
#include "make_test_thread.h"
2526
#include "test_macros.h"

libcxx/test/std/thread/futures/futures.unique_future/wait.pass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
// void wait() const;
1717

18-
#include <future>
1918
#include <cassert>
19+
#include <chrono>
20+
#include <future>
2021

2122
#include "make_test_thread.h"
2223
#include "test_macros.h"

libcxx/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
// future_status
2020
// wait_for(const chrono::duration<Rep, Period>& rel_time) const;
2121

22-
#include <future>
2322
#include <cassert>
23+
#include <chrono>
24+
#include <future>
2425

2526
#include "make_test_thread.h"
2627
#include "test_macros.h"

libcxx/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
// future_status
1818
// wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
1919

20-
#include <future>
2120
#include <atomic>
2221
#include <cassert>
22+
#include <chrono>
23+
#include <future>
2324

2425
#include "make_test_thread.h"
2526
#include "test_macros.h"

0 commit comments

Comments
 (0)