Author: LeeYoungJoon
Date: 2026-03-09T20:44:15+08:00
New Revision: 61a58cfa5c9aafc70f5e2faecc334c9b4373d89f

URL: 
https://github.com/llvm/llvm-project/commit/61a58cfa5c9aafc70f5e2faecc334c9b4373d89f
DIFF: 
https://github.com/llvm/llvm-project/commit/61a58cfa5c9aafc70f5e2faecc334c9b4373d89f.diff

LOG: [clang-tidy] Redirect hicpp-ignored-remove-result to 
bugprone-unused-return-value (#184547)

Part of the work in https://github.com/llvm/llvm-project/issues/183462.

Closes https://github.com/llvm/llvm-project/issues/183518.

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
    clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
    clang-tools-extra/docs/ReleaseNotes.rst
    clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
    clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst
    clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 
    clang-tools-extra/clang-tidy/hicpp/IgnoredRemoveResultCheck.cpp
    clang-tools-extra/clang-tidy/hicpp/IgnoredRemoveResultCheck.h


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
index 9179e5dea4ea9..e8401e750642d 100644
--- a/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
@@ -6,7 +6,6 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangTidyHICPPModule STATIC
   ExceptionBaseclassCheck.cpp
   HICPPTidyModule.cpp
-  IgnoredRemoveResultCheck.cpp
   MultiwayPathsCoveredCheck.cpp
   SignedBitwiseCheck.cpp
 

diff  --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp 
b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
index a4601d9cdde9f..3eb6d5de39d04 100644
--- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../bugprone/UndelegatedConstructorCheck.h"
+#include "../bugprone/UnusedReturnValueCheck.h"
 #include "../bugprone/UseAfterMoveCheck.h"
 #include "../cppcoreguidelines/AvoidGotoCheck.h"
 #include "../cppcoreguidelines/NoMallocCheck.h"
@@ -36,7 +37,6 @@
 #include "../readability/NamedParameterCheck.h"
 #include "../readability/UppercaseLiteralSuffixCheck.h"
 #include "ExceptionBaseclassCheck.h"
-#include "IgnoredRemoveResultCheck.h"
 #include "MultiwayPathsCoveredCheck.h"
 #include "SignedBitwiseCheck.h"
 
@@ -57,7 +57,7 @@ class HICPPModule : public ClangTidyModule {
         "hicpp-deprecated-headers");
     CheckFactories.registerCheck<ExceptionBaseclassCheck>(
         "hicpp-exception-baseclass");
-    CheckFactories.registerCheck<IgnoredRemoveResultCheck>(
+    CheckFactories.registerCheck<bugprone::UnusedReturnValueCheck>(
         "hicpp-ignored-remove-result");
     CheckFactories.registerCheck<MultiwayPathsCoveredCheck>(
         "hicpp-multiway-paths-covered");
@@ -110,6 +110,16 @@ class HICPPModule : public ClangTidyModule {
     CheckFactories.registerCheck<cppcoreguidelines::ProTypeVarargCheck>(
         "hicpp-vararg");
   }
+
+  ClangTidyOptions getModuleOptions() override {
+    ClangTidyOptions Options;
+    ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;
+    Opts["hicpp-ignored-remove-result.CheckedFunctions"] =
+        "^::std::remove$;^::std::remove_if$;^::std::unique$";
+    Opts["hicpp-ignored-remove-result.CheckedReturnTypes"] = "";
+    Opts["hicpp-ignored-remove-result.AllowCastToVoid"] = "true";
+    return Options;
+  }
 };
 
 } // namespace

diff  --git a/clang-tools-extra/clang-tidy/hicpp/IgnoredRemoveResultCheck.cpp 
b/clang-tools-extra/clang-tidy/hicpp/IgnoredRemoveResultCheck.cpp
deleted file mode 100644
index 5321fd8d5b1c2..0000000000000
--- a/clang-tools-extra/clang-tidy/hicpp/IgnoredRemoveResultCheck.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
-//
-//===----------------------------------------------------------------------===//
-
-#include "IgnoredRemoveResultCheck.h"
-
-namespace clang::tidy::hicpp {
-
-IgnoredRemoveResultCheck::IgnoredRemoveResultCheck(llvm::StringRef Name,
-                                                   ClangTidyContext *Context)
-    : UnusedReturnValueCheck(Name, Context,
-                             {
-                                 "::std::remove$",
-                                 "::std::remove_if$",
-                                 "::std::unique$",
-                             }) {
-  // The constructor for ClangTidyCheck needs to have been called
-  // before we can access options via Options.get().
-  AllowCastToVoid = Options.get("AllowCastToVoid", true);
-}
-
-void IgnoredRemoveResultCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) 
{
-  Options.store(Opts, "AllowCastToVoid", AllowCastToVoid);
-}
-
-} // namespace clang::tidy::hicpp

diff  --git a/clang-tools-extra/clang-tidy/hicpp/IgnoredRemoveResultCheck.h 
b/clang-tools-extra/clang-tidy/hicpp/IgnoredRemoveResultCheck.h
deleted file mode 100644
index 07e624e446403..0000000000000
--- a/clang-tools-extra/clang-tidy/hicpp/IgnoredRemoveResultCheck.h
+++ /dev/null
@@ -1,32 +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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_IGNOREDREMOVERESULTCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_IGNOREDREMOVERESULTCHECK_H
-
-#include "../bugprone/UnusedReturnValueCheck.h"
-
-namespace clang::tidy::hicpp {
-
-/// Ensure that the result of std::remove, std::remove_if and std::unique
-/// are not ignored according to rule 17.5.1.
-///
-/// For the user-facing documentation see:
-/// 
https://clang.llvm.org/extra/clang-tidy/checks/hicpp/ignored-remove-result.html
-class IgnoredRemoveResultCheck : public bugprone::UnusedReturnValueCheck {
-public:
-  IgnoredRemoveResultCheck(StringRef Name, ClangTidyContext *Context);
-  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
-    return LangOpts.CPlusPlus;
-  }
-  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
-};
-
-} // namespace clang::tidy::hicpp
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_IGNOREDREMOVERESULTCHECK_H

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6e1a116a30bf8..66290bc80f754 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -157,6 +157,12 @@ New checks
 New check aliases
 ^^^^^^^^^^^^^^^^^
 
+- Renamed :doc:`hicpp-ignored-remove-result
+  <clang-tidy/checks/hicpp/ignored-remove-result>`
+  to :doc:`bugprone-unused-return-value
+  <clang-tidy/checks/bugprone/unused-return-value>`.
+  The `hicpp-ignored-remove-result` name is kept as an alias.
+
 - Renamed :doc:`hicpp-no-assembler <clang-tidy/checks/hicpp/no-assembler>`
   to :doc:`portability-no-assembler
   <clang-tidy/checks/portability/no-assembler>`. The `hicpp-no-assembler`

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
index 725403a6eb818..3e7c51a9b1ac4 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unused-return-value.rst
@@ -67,3 +67,8 @@ Options
 
 :doc:`cert-err33-c <../cert/err33-c>` is an alias of this check that checks a
 fixed and large set of standard library functions.
+
+:doc:`hicpp-ignored-remove-result <../hicpp/ignored-remove-result>` is an
+alias of this check that checks a restricted set of functions:
+``std::remove``, ``std::remove_if``, and ``std::unique``.
+The `AllowCastToVoid` option is set to `true` by default.

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst 
b/clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst
index 1c749b169828e..622e4b79d20be 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst
@@ -1,25 +1,10 @@
 .. title:: clang-tidy - hicpp-ignored-remove-result
+.. meta::
+   :http-equiv=refresh: 5;URL=../bugprone/unused-return-value.html
 
 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-rules>`_.
-
-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``.
-
-This check is a subset of :doc:`bugprone-unused-return-value
-<../bugprone/unused-return-value>`
-and depending on used options it can be superfluous to enable both checks.
-
-Options
--------
-
-.. option:: AllowCastToVoid
-
-   Controls whether casting return values to ``void`` is permitted. Default: 
`true`.
+The hicpp-ignored-remove-result check is an alias, please see
+:doc:`bugprone-unused-return-value <../bugprone/unused-return-value>`
+for more information.

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 068431fb5c94c..8e94ff964af1b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -241,7 +241,6 @@ Clang-Tidy Checks
    :doc:`google-runtime-operator <google/runtime-operator>`,
    :doc:`google-upgrade-googletest-case <google/upgrade-googletest-case>`, 
"Yes"
    :doc:`hicpp-exception-baseclass <hicpp/exception-baseclass>`,
-   :doc:`hicpp-ignored-remove-result <hicpp/ignored-remove-result>`,
    :doc:`hicpp-multiway-paths-covered <hicpp/multiway-paths-covered>`,
    :doc:`hicpp-signed-bitwise <hicpp/signed-bitwise>`,
    :doc:`linuxkernel-must-check-errs <linuxkernel/must-check-errs>`,
@@ -602,6 +601,7 @@ Check aliases
    :doc:`hicpp-deprecated-headers <hicpp/deprecated-headers>`, 
:doc:`modernize-deprecated-headers <modernize/deprecated-headers>`, "Yes"
    :doc:`hicpp-explicit-conversions <hicpp/explicit-conversions>`, 
:doc:`google-explicit-constructor <google/explicit-constructor>`, "Yes"
    :doc:`hicpp-function-size <hicpp/function-size>`, 
:doc:`readability-function-size <readability/function-size>`,
+   :doc:`hicpp-ignored-remove-result <hicpp/ignored-remove-result>`, 
:doc:`bugprone-unused-return-value <bugprone/unused-return-value>`,
    :doc:`hicpp-invalid-access-moved <hicpp/invalid-access-moved>`, 
:doc:`bugprone-use-after-move <bugprone/use-after-move>`,
    :doc:`hicpp-member-init <hicpp/member-init>`, 
:doc:`cppcoreguidelines-pro-type-member-init 
<cppcoreguidelines/pro-type-member-init>`, "Yes"
    :doc:`hicpp-move-const-arg <hicpp/move-const-arg>`, 
:doc:`performance-move-const-arg <performance/move-const-arg>`, "Yes"


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to