[all-commits] [llvm/llvm-project] 346a29: [libc++][test] Fix unused and nodiscard warnings (...

Stephan T. Lavavej via All-commits all-commits at lists.llvm.org
Sun Nov 26 09:00:32 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 346a29908e0a0401073169ea94c17be72a9c83db
      https://github.com/llvm/llvm-project/commit/346a29908e0a0401073169ea94c17be72a9c83db
  Author: Stephan T. Lavavej <stl at nuwen.net>
  Date:   2023-11-26 (Sun, 26 Nov 2023)

  Changed paths:
    M libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/complexity.pass.cpp
    M libcxx/test/std/containers/sequences/deque/deque.cons/from_range.pass.cpp
    M libcxx/test/std/containers/sequences/deque/deque.modifiers/append_range.pass.cpp
    M libcxx/test/std/containers/sequences/deque/deque.modifiers/assign_range.pass.cpp
    M libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_range.pass.cpp
    M libcxx/test/std/containers/sequences/deque/deque.modifiers/prepend_range.pass.cpp
    M libcxx/test/std/containers/sequences/vector.bool/append_range.pass.cpp
    M libcxx/test/std/containers/sequences/vector.bool/assign_range.pass.cpp
    M libcxx/test/std/containers/sequences/vector.bool/construct_from_range.pass.cpp
    M libcxx/test/std/containers/sequences/vector.bool/insert_range.pass.cpp
    M libcxx/test/std/containers/sequences/vector/vector.cons/construct_from_range.pass.cpp
    M libcxx/test/std/containers/sequences/vector/vector.modifiers/append_range.pass.cpp
    M libcxx/test/std/containers/sequences/vector/vector.modifiers/assign_range.pass.cpp
    M libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_range.pass.cpp
    M libcxx/test/std/strings/basic.string/string.modifiers/string_append/append_range.pass.cpp
    M libcxx/test/std/strings/basic.string/string.modifiers/string_assign/assign_range.pass.cpp
    M libcxx/test/std/strings/basic.string/string.modifiers/string_insert/insert_range.pass.cpp
    M libcxx/test/std/thread/futures/futures.future_error/what.pass.cpp
    M libcxx/test/std/utilities/function.objects/func.invoke/invoke_r.pass.cpp
    M libcxx/test/support/deduction_guides_sfinae_checks.h

  Log Message:
  -----------
  [libc++][test] Fix unused and nodiscard warnings (#73437)

Found while running libc++'s test suite with MSVC's STL.

This is structured into a series of commits for easier reviewing; I
could also split this into smaller PRs if desired.

* Add void-casts for `invoke_r` calls to fix MSVC STL `[[nodiscard]]`
warnings.
+ Our rationale is that if someone is calling `invoke_r<NonVoidType>`,
it sure looks like they care about the return value.
* Add `[[maybe_unused]]` to silence `-Wunused-parameter` warnings.
+ This happens because the parameters are used within `LIBCPP_ASSERT`,
which vanishes for MSVC's STL. This also motivates the following
changes.
* Add `[[maybe_unused]]` to fix `-Wunused-variable` warnings.
* Always void-cast `debug_comparisons` to fix `-Wunused-variable`
warnings.
+ As this was already unused with a void-cast in one
`_LIBCPP_HARDENING_MODE` branch, I'm simply lifting it next to the
variable definition.
* Add `[[maybe_unused]]` to fix `-Wunused-local-typedef` warnings.




More information about the All-commits mailing list