[all-commits] [llvm/llvm-project] 02540b: [libc++] Make sure ranges algorithms and views han...

Louis Dionne via All-commits all-commits at lists.llvm.org
Mon Nov 6 23:20:10 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 02540b2f6dc6c2d42a3365bef78833d7fab98491
      https://github.com/llvm/llvm-project/commit/02540b2f6dc6c2d42a3365bef78833d7fab98491
  Author: Louis Dionne <ldionne.2 at gmail.com>
  Date:   2023-11-06 (Mon, 06 Nov 2023)

  Changed paths:
    M libcxx/include/__algorithm/make_projected.h
    M libcxx/include/__algorithm/ranges_find_if_not.h
    M libcxx/include/__algorithm/ranges_max.h
    M libcxx/include/__algorithm/ranges_max_element.h
    M libcxx/include/__algorithm/ranges_remove.h
    M libcxx/include/__algorithm/ranges_remove_copy.h
    M libcxx/include/__algorithm/ranges_replace.h
    M libcxx/include/__algorithm/ranges_replace_copy.h
    M libcxx/include/__algorithm/ranges_upper_bound.h
    M libcxx/include/__memory/ranges_uninitialized_algorithms.h
    M libcxx/include/__ranges/chunk_by_view.h
    M libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/ranges.remove.pass.cpp
    M libcxx/test/std/algorithms/alg.modifying.operations/alg.remove/ranges.remove_if.pass.cpp
    M libcxx/test/std/algorithms/alg.modifying.operations/alg.replace/ranges.replace.pass.cpp
    M libcxx/test/std/algorithms/alg.modifying.operations/alg.replace/ranges.replace_if.pass.cpp
    M libcxx/test/std/algorithms/alg.nonmodifying/alg.adjacent.find/ranges.adjacent_find.pass.cpp
    M libcxx/test/std/algorithms/alg.nonmodifying/alg.find.first.of/ranges.find_first_of.pass.cpp
    M libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find.pass.cpp
    M libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find_if.pass.cpp
    M libcxx/test/std/algorithms/alg.nonmodifying/alg.find/ranges.find_if_not.pass.cpp
    M libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/ranges_make_heap.pass.cpp
    M libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/ranges_pop_heap.pass.cpp
    M libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/ranges_push_heap.pass.cpp
    M libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/ranges_sort_heap.pass.cpp
    M libcxx/test/std/algorithms/alg.sorting/alg.lex.comparison/ranges.lexicographical_compare.pass.cpp
    M libcxx/test/std/algorithms/alg.sorting/alg.nth.element/ranges_nth_element.pass.cpp
    M libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort/ranges_partial_sort.pass.cpp
    M libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/ranges.sort.pass.cpp
    M libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/ranges.stable.sort.pass.cpp
    A libcxx/test/std/algorithms/ranges_robust_against_nonbool.compile.pass.cpp
    R libcxx/test/std/algorithms/ranges_robust_against_nonbool_predicates.pass.cpp
    A libcxx/test/std/ranges/range.adaptors/robust_against_nonbool.compile.pass.cpp
    A libcxx/test/std/utilities/memory/specialized.algorithms/ranges_robust_against_nonbool.compile.pass.cpp
    M libcxx/test/support/boolean_testable.h
    M libcxx/utils/data/ignore_format.txt

  Log Message:
  -----------
  [libc++] Make sure ranges algorithms and views handle boolean-testable correctly (#69378)

Before this patch, we would fail to implicitly convert the result of
predicates to bool, which means we'd potentially perform a copy or move
construction of the boolean-testable, which isn't allowed. The same
holds true for comparing iterators against sentinels, which is allowed
to return a boolean-testable type.

We already had tests aiming to ensure correct handling of these types,
but they failed to provide appropriate coverage in several cases due to
guaranteed RVO. This patch fixes the tests, adds tests for missing
algorithms and views, and fixes the actual problems in the code.

Fixes #69074




More information about the All-commits mailing list