[libcxx-commits] [libcxx] [libc++] Applied `[[nodiscard]]` to `optional::iterator` (PR #198489)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 29 22:01:16 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- libcxx/test/libcxx/utilities/optional/nodiscard.iterator.verify.cpp libcxx/include/__iterator/bounded_iter.h libcxx/include/__iterator/capacity_aware_iterator.h --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/test/libcxx/utilities/optional/nodiscard.iterator.verify.cpp b/libcxx/test/libcxx/utilities/optional/nodiscard.iterator.verify.cpp
index 37480fc0e..7fd964988 100644
--- a/libcxx/test/libcxx/utilities/optional/nodiscard.iterator.verify.cpp
+++ b/libcxx/test/libcxx/utilities/optional/nodiscard.iterator.verify.cpp
@@ -21,7 +21,7 @@ void test() {
using Container = std::optional<int>;
Container c;
- Container::iterator it = c.begin();
+ Container::iterator it = c.begin();
Container::const_iterator cit = std::as_const(c).begin();
// expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
``````````
</details>
https://github.com/llvm/llvm-project/pull/198489
More information about the libcxx-commits
mailing list