[clang-tools-extra] [clang-tidy] Add check hicpp-ignored-remove-result (PR #73119)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 6 22:28:07 PST 2023


=?utf-8?q?Björn?= Svensson <bjorn.a.svensson at est.tech>,
=?utf-8?q?Björn?= Svensson <bjorn.a.svensson at est.tech>,
=?utf-8?q?Björn?= Svensson <bjorn.a.svensson at est.tech>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/73119 at github.com>


================
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - hicpp-ignored-remove-result
+
+hicpp-ignored-remove-result
+===========================
+
+Ensure that the result of ``std::remove``, ``std::remove_if`` and ``std::unique``
+are not ignored according to
+`rule 17.5.1 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-standard/standard-library>`_.
+
+The mutating algorithms ``std::remove``, ``std::remove_if`` and both overloads
+of ``std::unique`` operate by swapping or moving elements of the range they are
+operating over. On completion, they return an iterator to the last valid
+element. In the majority of cases the correct behavior is to use this result as
+the first operand in a call to ``std::erase``.
+
----------------
PiotrZSL wrote:

Add info that this check is a subset of bugprone-unused-return-value, and if that's enabled then this doesn't have to be.

https://github.com/llvm/llvm-project/pull/73119


More information about the cfe-commits mailing list