[all-commits] [llvm/llvm-project] d87f15: [libcxx][NFC] removes `swap`'s dependency on `swap...

Christopher Di Bella via All-commits all-commits at lists.llvm.org
Thu Jun 24 11:02:35 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d87f159ab675153ef58eae138d6ca223c45f14c8
      https://github.com/llvm/llvm-project/commit/d87f159ab675153ef58eae138d6ca223c45f14c8
  Author: Christopher Di Bella <cjdb at google.com>
  Date:   2021-06-24 (Thu, 24 Jun 2021)

  Changed paths:
    M libcxx/include/type_traits

  Log Message:
  -----------
  [libcxx][NFC] removes `swap`'s dependency on `swap_ranges`

Under the as-if rule, we can directly implement the array overload for
`std::swap`. By removing this circular dependency where `swap` is
implemented in terms of `swap_ranges` and `swap_ranges` is defined in
terms of `swap`, we can split them into their own headers. This will:

* limit the surface area in which Hyrum's law can bite us;
* force users to include the correct headers;
* make finding the definitions trivial (`swap` is a utility;
  `swap_ranges` is an algorithm).

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


  Commit: 6adbc83ee9e46b476e0f75d5671c3a21f675a936
      https://github.com/llvm/llvm-project/commit/6adbc83ee9e46b476e0f75d5671c3a21f675a936
  Author: Christopher Di Bella <cjdb at google.com>
  Date:   2021-06-24 (Thu, 24 Jun 2021)

  Changed paths:
    M libcxx/include/CMakeLists.txt
    M libcxx/include/__algorithm/inplace_merge.h
    A libcxx/include/__algorithm/iter_swap.h
    M libcxx/include/__algorithm/move.h
    M libcxx/include/__algorithm/next_permutation.h
    M libcxx/include/__algorithm/nth_element.h
    M libcxx/include/__algorithm/partial_sort.h
    M libcxx/include/__algorithm/partition.h
    M libcxx/include/__algorithm/pop_heap.h
    M libcxx/include/__algorithm/prev_permutation.h
    M libcxx/include/__algorithm/push_heap.h
    M libcxx/include/__algorithm/remove.h
    M libcxx/include/__algorithm/reverse.h
    M libcxx/include/__algorithm/rotate.h
    M libcxx/include/__algorithm/shift_right.h
    M libcxx/include/__algorithm/shuffle.h
    M libcxx/include/__algorithm/sift_down.h
    M libcxx/include/__algorithm/sort.h
    M libcxx/include/__algorithm/stable_partition.h
    M libcxx/include/__algorithm/stable_sort.h
    A libcxx/include/__algorithm/swap_ranges.h
    M libcxx/include/__algorithm/unique.h
    M libcxx/include/__iterator/concepts.h
    M libcxx/include/__iterator/iter_move.h
    M libcxx/include/__memory/allocator.h
    M libcxx/include/__memory/allocator_traits.h
    M libcxx/include/__memory/compressed_pair.h
    M libcxx/include/__memory/construct_at.h
    M libcxx/include/__memory/shared_ptr.h
    M libcxx/include/__memory/unique_ptr.h
    M libcxx/include/__ranges/access.h
    M libcxx/include/__ranges/all.h
    M libcxx/include/__ranges/data.h
    M libcxx/include/__ranges/empty.h
    M libcxx/include/__ranges/size.h
    M libcxx/include/__split_buffer
    M libcxx/include/__tree
    A libcxx/include/__utility/__decay_copy.h
    A libcxx/include/__utility/declval.h
    A libcxx/include/__utility/forward.h
    A libcxx/include/__utility/move.h
    A libcxx/include/__utility/swap.h
    M libcxx/include/algorithm
    M libcxx/include/any
    M libcxx/include/deque
    M libcxx/include/exception
    M libcxx/include/experimental/iterator
    M libcxx/include/filesystem
    M libcxx/include/forward_list
    M libcxx/include/functional
    M libcxx/include/future
    M libcxx/include/istream
    M libcxx/include/iterator
    M libcxx/include/list
    M libcxx/include/map
    M libcxx/include/module.modulemap
    M libcxx/include/mutex
    M libcxx/include/queue
    M libcxx/include/scoped_allocator
    M libcxx/include/set
    M libcxx/include/stack
    M libcxx/include/thread
    M libcxx/include/tuple
    M libcxx/include/type_traits
    M libcxx/include/unordered_map
    M libcxx/include/unordered_set
    M libcxx/include/utility
    M libcxx/include/variant
    M libcxx/include/vector
    M libcxx/test/std/utilities/utility/forward/forward.fail.cpp
    M libcxx/test/std/utilities/utility/utility.swap/swap.pass.cpp
    M libcxx/test/std/utilities/utility/utility.swap/swap_array.pass.cpp
    M libcxx/test/support/poisoned_hash_helper.h

  Log Message:
  -----------
  [libcxx][modularisation] moves <utility> content out of <type_traits>

Moves:

* `std::move`, `std::forward`, `std::declval`, and `std::swap` into
  `__utility/${FUNCTION_NAME}`.
* `std::swap_ranges` and `std::iter_swap` into
  `__algorithm/${FUNCTION_NAME}`

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


Compare: https://github.com/llvm/llvm-project/compare/652f4b5140e2...6adbc83ee9e4


More information about the All-commits mailing list