From f7b943e4ed5c46a340f16bda42e20b9d43f52fef Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 14 Jan 2026 06:05:22 +0200 Subject: [PATCH] [libc++][ranges][NFC] Merge `join_with_view`s `[[nodiscard]]` tests (#175734) This just merges all tests in a single `nodiscard.verify.cpp` as is the common practice. --- .../range.join.with/nodiscard.verify.cpp | 99 +++++++++++++++++++ .../deref.nodiscard.verify.cpp | 28 ------ .../eq.nodiscard.verify.cpp | 30 ------ .../iter_move.nodiscard.verify.cpp | 28 ------ .../adaptor.nodiscard.verify.cpp | 33 ------- .../eq.nodiscard.verify.cpp | 35 ------- .../base.nodiscard.verify.cpp | 30 ------ .../begin.nodiscard.verify.cpp | 28 ------ .../end.nodiscard.verify.cpp | 28 ------ 9 files changed, 99 insertions(+), 240 deletions(-) create mode 100644 libcxx/test/libcxx/ranges/range.adaptors/range.join.with/nodiscard.verify.cpp delete mode 100644 libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/deref.nodiscard.verify.cpp delete mode 100644 libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/eq.nodiscard.verify.cpp delete mode 100644 libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/iter_move.nodiscard.verify.cpp delete mode 100644 libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.overview/adaptor.nodiscard.verify.cpp delete mode 100644 libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.sentinel/eq.nodiscard.verify.cpp delete mode 100644 libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/base.nodiscard.verify.cpp delete mode 100644 libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/begin.nodiscard.verify.cpp delete mode 100644 libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/end.nodiscard.verify.cpp diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/nodiscard.verify.cpp new file mode 100644 index 000000000000..dc2a9f5074ae --- /dev/null +++ b/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/nodiscard.verify.cpp @@ -0,0 +1,99 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// REQUIRES: std-at-least-c++23 + +// Test that functions are marked [[nodiscard]]. + +#include +#include +#include + +#include "test_iterators.h" +#include "test_range.h" + +void test() { + int range[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; + int pattern[2] = {-1, -1}; + + std::ranges::join_with_view view(range, pattern); + + // clang-format off + view.base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::as_const(view).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::move(std::as_const(view)).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::move(view).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + // clang-format on + + // clang-format off + view.begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::as_const(view).begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + // clang-format on + + // clang-format off + view.end(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::as_const(view).end(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + // clang-format on +} + +void test_iterator() { + char range[3][2] = {{'x', 'x'}, {'y', 'y'}, {'z', 'z'}}; + char pattern[2] = {',', ' '}; + + std::ranges::join_with_view view(range, pattern); + + // clang-format off + *view.begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + *std::as_const(view).begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + // clang-format on + + // clang-format off + (view.begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + (std::as_const(view).begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + (view.begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + (std::as_const(view).begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + // clang-format on + + // clang-format off + iter_move(view.begin()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + iter_move(std::as_const(view).begin()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + // clang-format on +} + +void test_sentinel() { + std::array, 0> range; + std::array pattern; + + std::ranges::join_with_view view(range, pattern); + static_assert(!std::ranges::common_range); + + // clang-format off + (view.begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + (std::as_const(view).begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + (view.begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + (std::as_const(view).begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + // clang-format on +} + +void test_overview() { + int range[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; + int pattern_base[2] = {-1, -1}; + auto pattern = std::views::all(pattern_base); + + // clang-format off + std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::views::join_with(range, pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + range | std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::views::reverse | std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + + std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::views::join_with(range, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + range | std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::views::reverse | std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + // clang-format on +} diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/deref.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/deref.nodiscard.verify.cpp deleted file mode 100644 index 97133613bf58..000000000000 --- a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/deref.nodiscard.verify.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// REQUIRES: std-at-least-c++23 - -// - -// Test the libc++ extension that std::ranges::join_with_view::iterator::operator* is marked as [[nodiscard]]. - -#include -#include - -void test() { - char range[3][2] = {{'x', 'x'}, {'y', 'y'}, {'z', 'z'}}; - char pattern[2] = {',', ' '}; - - std::ranges::join_with_view view(range, pattern); - - // clang-format off - *view.begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - *std::as_const(view).begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - // clang-format on -} diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/eq.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/eq.nodiscard.verify.cpp deleted file mode 100644 index 823d8def9808..000000000000 --- a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/eq.nodiscard.verify.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// REQUIRES: std-at-least-c++23 - -// - -// Test the libc++ extension that std::ranges::join_with_view::iterator::operator== is marked as [[nodiscard]]. - -#include -#include - -void test() { - char16_t range[3][1] = {{u'x'}, {u'y'}, {u'z'}}; - char16_t pattern[1] = {u'-'}; - - std::ranges::join_with_view view(range, pattern); - - // clang-format off - (view.begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - (std::as_const(view).begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - (view.begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - (std::as_const(view).begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - // clang-format on -} diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/iter_move.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/iter_move.nodiscard.verify.cpp deleted file mode 100644 index 9e046ef43fda..000000000000 --- a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.iterator/iter_move.nodiscard.verify.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// REQUIRES: std-at-least-c++23 - -// - -// Test the libc++ extension that std::ranges::join_with_view::iterator::iter_move is marked as [[nodiscard]]. - -#include -#include - -void test() { - long range[2][1] = {{0L}, {2L}}; - long pattern[1] = {1L}; - - std::ranges::join_with_view view(range, pattern); - - // clang-format off - iter_move(view.begin()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - iter_move(std::as_const(view).begin()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - // clang-format on -} diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.overview/adaptor.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.overview/adaptor.nodiscard.verify.cpp deleted file mode 100644 index 3efe77a3765d..000000000000 --- a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.overview/adaptor.nodiscard.verify.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// REQUIRES: std-at-least-c++23 - -// - -// Test the libc++ extension that std::views::join_with is marked as [[nodiscard]]. - -#include - -void test() { - int range[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; - int pattern_base[2] = {-1, -1}; - auto pattern = std::views::all(pattern_base); - - // clang-format off - std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - std::views::join_with(range, pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - range | std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - std::views::reverse | std::views::join_with(pattern); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - - std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - std::views::join_with(range, 0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - range | std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - std::views::reverse | std::views::join_with(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - // clang-format on -} diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.sentinel/eq.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.sentinel/eq.nodiscard.verify.cpp deleted file mode 100644 index e7e4d262eedb..000000000000 --- a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.sentinel/eq.nodiscard.verify.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// REQUIRES: std-at-least-c++23 - -// - -// Test the libc++ extension that std::ranges::join_with_view::sentinel::operator== is marked as [[nodiscard]]. - -#include -#include -#include - -#include "test_iterators.h" -#include "test_range.h" - -void test() { - std::array, 0> range; - std::array pattern; - - std::ranges::join_with_view view(range, pattern); - static_assert(!std::ranges::common_range); - - // clang-format off - (view.begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - (std::as_const(view).begin() == view.end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - (view.begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - (std::as_const(view).begin() == std::as_const(view).end()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - // clang-format on -} diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/base.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/base.nodiscard.verify.cpp deleted file mode 100644 index ddf1ebdc5e46..000000000000 --- a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/base.nodiscard.verify.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// REQUIRES: std-at-least-c++23 - -// - -// Test the libc++ extension that std::ranges::join_with_view::base is marked as [[nodiscard]]. - -#include -#include - -void test() { - int range[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; - int pattern[2] = {-1, -1}; - - std::ranges::join_with_view view(range, pattern); - - // clang-format off - view.base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - std::as_const(view).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - std::move(std::as_const(view)).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - std::move(view).base(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - // clang-format on -} diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/begin.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/begin.nodiscard.verify.cpp deleted file mode 100644 index 858490a82c75..000000000000 --- a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/begin.nodiscard.verify.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// REQUIRES: std-at-least-c++23 - -// - -// Test the libc++ extension that std::ranges::join_with_view::begin is marked as [[nodiscard]]. - -#include -#include - -void test() { - int range[3][2] = {{1, 3}, {4, 6}, {7, 9}}; - int pattern[1] = {-2}; - - std::ranges::join_with_view view(range, pattern); - - // clang-format off - view.begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - std::as_const(view).begin(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - // clang-format on -} diff --git a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/end.nodiscard.verify.cpp b/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/end.nodiscard.verify.cpp deleted file mode 100644 index e57e0ee3f0d0..000000000000 --- a/libcxx/test/libcxx/ranges/range.adaptors/range.join.with/range.join.with.view/end.nodiscard.verify.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// REQUIRES: std-at-least-c++23 - -// - -// Test the libc++ extension that std::ranges::join_with_view::end is marked as [[nodiscard]]. - -#include -#include - -void test() { - int range[3][2] = {{1, 2}, {4, 5}, {7, 8}}; - int pattern[1] = {-3}; - - std::ranges::join_with_view view(range, pattern); - - // clang-format off - view.end(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - std::as_const(view).end(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - // clang-format on -}