Author: Zeyi Xu Date: 2026-05-11T08:28:36Z New Revision: d1b0c854354cb9bc0033b126fa1f71b2a6c721b2
URL: https://github.com/llvm/llvm-project/commit/d1b0c854354cb9bc0033b126fa1f71b2a6c721b2 DIFF: https://github.com/llvm/llvm-project/commit/d1b0c854354cb9bc0033b126fa1f71b2a6c721b2.diff LOG: [clang-tidy] Remove hicpp modules [2/4] (#196870) This is part two of removing the hicpp-* checks. RFC: https://discourse.llvm.org/t/rfc-regarding-the-current-status-of-hicpp-checks/89883 Part of https://github.com/llvm/llvm-project/issues/183462 Added: Modified: clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp clang-tools-extra/clangd/TidyFastChecks.inc clang-tools-extra/clangd/TidyProvider.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/test/clang-tidy/infrastructure/duplicate-conflicted-fixes-of-alias-checkers.cpp clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp Removed: clang-tools-extra/docs/clang-tidy/checks/hicpp/invalid-access-moved.rst clang-tools-extra/docs/clang-tidy/checks/hicpp/member-init.rst clang-tools-extra/docs/clang-tidy/checks/hicpp/move-const-arg.rst clang-tools-extra/docs/clang-tidy/checks/hicpp/named-parameter.rst clang-tools-extra/docs/clang-tidy/checks/hicpp/new-delete-operators.rst clang-tools-extra/docs/clang-tidy/checks/hicpp/no-array-decay.rst clang-tools-extra/docs/clang-tidy/checks/hicpp/noexcept-move.rst clang-tools-extra/docs/clang-tidy/checks/hicpp/signed-bitwise.rst ################################################################################ diff --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp index 3679b70ab2117..8d08e0cb87046 100644 --- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp @@ -8,16 +8,11 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" -#include "../bugprone/SignedBitwiseCheck.h" #include "../bugprone/UndelegatedConstructorCheck.h" #include "../bugprone/UnhandledCodePathsCheck.h" -#include "../bugprone/UseAfterMoveCheck.h" #include "../cppcoreguidelines/NoMallocCheck.h" -#include "../cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h" -#include "../cppcoreguidelines/ProTypeMemberInitCheck.h" #include "../cppcoreguidelines/ProTypeVarargCheck.h" #include "../cppcoreguidelines/SpecialMemberFunctionsCheck.h" -#include "../misc/NewDeleteOverloadsCheck.h" #include "../misc/StaticAssertCheck.h" #include "../modernize/UseAutoCheck.h" #include "../modernize/UseEmplaceCheck.h" @@ -26,10 +21,7 @@ #include "../modernize/UseNoexceptCheck.h" #include "../modernize/UseNullptrCheck.h" #include "../modernize/UseOverrideCheck.h" -#include "../performance/MoveConstArgCheck.h" -#include "../performance/NoexceptMoveConstructorCheck.h" #include "../portability/NoAssemblerCheck.h" -#include "../readability/NamedParameterCheck.h" #include "../readability/UppercaseLiteralSuffixCheck.h" namespace clang::tidy { @@ -41,23 +33,6 @@ class HICPPModule : public ClangTidyModule { void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFactories.registerCheck<bugprone::UnhandledCodePathsCheck>( "hicpp-multiway-paths-covered"); - CheckFactories.registerCheck<bugprone::SignedBitwiseCheck>( - "hicpp-signed-bitwise"); - CheckFactories.registerCheck<readability::NamedParameterCheck>( - "hicpp-named-parameter"); - CheckFactories.registerCheck<bugprone::UseAfterMoveCheck>( - "hicpp-invalid-access-moved"); - CheckFactories.registerCheck<cppcoreguidelines::ProTypeMemberInitCheck>( - "hicpp-member-init"); - CheckFactories.registerCheck<performance::MoveConstArgCheck>( - "hicpp-move-const-arg"); - CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>( - "hicpp-new-delete-operators"); - CheckFactories.registerCheck<performance::NoexceptMoveConstructorCheck>( - "hicpp-noexcept-move"); - CheckFactories - .registerCheck<cppcoreguidelines::ProBoundsArrayToPointerDecayCheck>( - "hicpp-no-array-decay"); CheckFactories.registerCheck<portability::NoAssemblerCheck>( "hicpp-no-assembler"); CheckFactories.registerCheck<cppcoreguidelines::NoMallocCheck>( diff --git a/clang-tools-extra/clangd/TidyFastChecks.inc b/clang-tools-extra/clangd/TidyFastChecks.inc index c1a72bae035b7..e289e3cce99a5 100644 --- a/clang-tools-extra/clangd/TidyFastChecks.inc +++ b/clang-tools-extra/clangd/TidyFastChecks.inc @@ -272,17 +272,9 @@ FAST(google-runtime-float, 1.0) FAST(google-runtime-int, 2.0) FAST(google-runtime-operator, 1.0) FAST(google-upgrade-googletest-case, 1.0) -FAST(hicpp-invalid-access-moved, 9.0) -FAST(hicpp-member-init, 2.0) -FAST(hicpp-move-const-arg, 2.0) FAST(hicpp-multiway-paths-covered, -0.0) -FAST(hicpp-named-parameter, 1.0) -FAST(hicpp-new-delete-operators, 1.0) -FAST(hicpp-no-array-decay, 2.0) FAST(hicpp-no-assembler, 1.0) FAST(hicpp-no-malloc, 1.0) -FAST(hicpp-noexcept-move, -0.0) -FAST(hicpp-signed-bitwise, -1.0) FAST(hicpp-special-member-functions, -1.0) FAST(hicpp-static-assert, 2.0) FAST(hicpp-undelegated-constructor, 1.0) @@ -492,4 +484,3 @@ FAST(zircon-temporary-objects, 1.0) #undef FAST #undef SLOW - diff --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp index bfb0835af2245..aae7d6b126c5a 100644 --- a/clang-tools-extra/clangd/TidyProvider.cpp +++ b/clang-tools-extra/clangd/TidyProvider.cpp @@ -218,8 +218,6 @@ TidyProvider disableUnusableChecks(llvm::ArrayRef<std::string> ExtraBadChecks) { // code, which is often the case when clangd // tries to build an AST. "-bugprone-use-after-move", - // Alias for bugprone-use-after-move. - "-hicpp-invalid-access-moved", // Check uses dataflow analysis, which might hang/crash unexpectedly on // incomplete code. "-bugprone-unchecked-optional-access", diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index c5a6857c7077f..241ae52cffdd2 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -58,9 +58,9 @@ Potentially Breaking Changes - Removed the :program:`clang-tidy` ``hicpp`` module. All checks have been moved to the other modules. Use the replacement checks instead: - ================================== ========================================================= + ================================== ======================================================================== Removed check Replacement check - ================================== ========================================================= + ================================== ======================================================================== ``hicpp-avoid-c-arrays`` :doc:`modernize-avoid-c-arrays <clang-tidy/checks/modernize/avoid-c-arrays>` ``hicpp-avoid-goto`` :doc:`cppcoreguidelines-avoid-goto @@ -77,7 +77,23 @@ Potentially Breaking Changes <clang-tidy/checks/readability/function-size>` ``hicpp-ignored-remove-result`` :doc:`bugprone-unused-return-value <clang-tidy/checks/bugprone/unused-return-value>` - ================================== ========================================================= + ``hicpp-invalid-access-moved`` :doc:`bugprone-use-after-move + <clang-tidy/checks/bugprone/use-after-move>` + ``hicpp-member-init`` :doc:`cppcoreguidelines-pro-type-member-init + <clang-tidy/checks/cppcoreguidelines/pro-type-member-init>` + ``hicpp-move-const-arg`` :doc:`performance-move-const-arg + <clang-tidy/checks/performance/move-const-arg>` + ``hicpp-named-parameter`` :doc:`readability-named-parameter + <clang-tidy/checks/readability/named-parameter>` + ``hicpp-new-delete-operators`` :doc:`misc-new-delete-overloads + <clang-tidy/checks/misc/new-delete-overloads>` + ``hicpp-no-array-decay`` :doc:`cppcoreguidelines-pro-bounds-array-to-pointer-decay + <clang-tidy/checks/cppcoreguidelines/pro-bounds-array-to-pointer-decay>` + ``hicpp-noexcept-move`` :doc:`performance-noexcept-move-constructor + <clang-tidy/checks/performance/noexcept-move-constructor>` + ``hicpp-signed-bitwise`` :doc:`bugprone-signed-bitwise + <clang-tidy/checks/bugprone/signed-bitwise>` + ================================== ======================================================================== Improvements to clangd ---------------------- @@ -258,11 +274,6 @@ New check aliases <clang-tidy/checks/portability/no-assembler>`. The `hicpp-no-assembler` name is kept as an alias. -- Renamed :doc:`hicpp-signed-bitwise <clang-tidy/checks/hicpp/signed-bitwise>` - to :doc:`bugprone-signed-bitwise - <clang-tidy/checks/bugprone/signed-bitwise>`. The `hicpp-signed-bitwise` - name is kept as an alias. - - Renamed :doc:`performance-faster-string-find <clang-tidy/checks/performance/faster-string-find>` to :doc:`performance-prefer-single-char-overloads diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/invalid-access-moved.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/invalid-access-moved.rst deleted file mode 100644 index 05f7968287d8b..0000000000000 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/invalid-access-moved.rst +++ /dev/null @@ -1,9 +0,0 @@ -.. title:: clang-tidy - hicpp-invalid-access-moved - -hicpp-invalid-access-moved -========================== - -This check is an alias for -:doc:`bugprone-use-after-move <../bugprone/use-after-move>`. - -Implements parts of the `rule 8.4.1 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-rules>`_ to check if moved-from objects are accessed. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/member-init.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/member-init.rst deleted file mode 100644 index fca19f4d407f9..0000000000000 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/member-init.rst +++ /dev/null @@ -1,9 +0,0 @@ -.. title:: clang-tidy - hicpp-member-init - -hicpp-member-init -================= - -This check is an alias for :doc:`cppcoreguidelines-pro-type-member-init <../cppcoreguidelines/pro-type-member-init>`. -Implements the check for -`rule 12.4.2 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-rules>`_ -to initialize class members in the right order. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/move-const-arg.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/move-const-arg.rst deleted file mode 100644 index 6818e7b24a9dd..0000000000000 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/move-const-arg.rst +++ /dev/null @@ -1,9 +0,0 @@ -.. title:: clang-tidy - hicpp-move-const-arg - -hicpp-move-const-arg -==================== - -The `hicpp-move-const-arg` check is an alias, please see -:doc:`performance-move-const-arg <../performance/move-const-arg>` -for more information. -It enforces the `rule 17.3.1 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-rules>`_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/named-parameter.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/named-parameter.rst deleted file mode 100644 index 93b51400cb04c..0000000000000 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/named-parameter.rst +++ /dev/null @@ -1,9 +0,0 @@ -.. title:: clang-tidy - hicpp-named-parameter - -hicpp-named-parameter -===================== - -This check is an alias for :doc:`readability-named-parameter -<../readability/named-parameter>`. - -Implements `rule 8.2.1 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-rules>`_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/new-delete-operators.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/new-delete-operators.rst deleted file mode 100644 index dcf3c756f9224..0000000000000 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/new-delete-operators.rst +++ /dev/null @@ -1,8 +0,0 @@ -.. title:: clang-tidy - hicpp-new-delete-operators - -hicpp-new-delete-operators -========================== - -This check is an alias for :doc:`misc-new-delete-overloads <../misc/new-delete-overloads>`. -Implements `rule 12.3.1 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-rules>`_ to ensure -the `new` and `delete` operators have the correct signature. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/no-array-decay.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/no-array-decay.rst deleted file mode 100644 index 9a84fde7b0aae..0000000000000 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/no-array-decay.rst +++ /dev/null @@ -1,10 +0,0 @@ -.. title:: clang-tidy - hicpp-no-array-decay - -hicpp-no-array-decay -==================== - -The `hicpp-no-array-decay` check is an alias, please see -:doc:`cppcoreguidelines-pro-bounds-array-to-pointer-decay -<../cppcoreguidelines/pro-bounds-array-to-pointer-decay>` -for more information. -It enforces the `rule 4.1.1 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-rules>`_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/noexcept-move.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/noexcept-move.rst deleted file mode 100644 index dee62948f3393..0000000000000 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/noexcept-move.rst +++ /dev/null @@ -1,8 +0,0 @@ -.. title:: clang-tidy - hicpp-noexcept-move - -hicpp-noexcept-move -=================== - -This check is an alias for :doc:`performance-noexcept-move-constructor -<../performance/noexcept-move-constructor>`. -Checks `rule 12.5.4 <https://www.perforce.com/resources/qac/high-integrity-cpp-coding-rules>`_ to mark move assignment and move construction `noexcept`. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/signed-bitwise.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/signed-bitwise.rst deleted file mode 100644 index dca5279534fd7..0000000000000 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/signed-bitwise.rst +++ /dev/null @@ -1,9 +0,0 @@ -.. title:: clang-tidy - hicpp-signed-bitwise - -hicpp-signed-bitwise -==================== - -The `hicpp-signed-bitwise` check is an alias, please see -`bugprone-signed-bitwise <../bugprone/signed-bitwise.html>`_ 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 f193c0920ec1b..f80df56d1a4ad 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -603,17 +603,9 @@ Check aliases :doc:`google-readability-casting <google/readability-casting>`, :doc:`modernize-avoid-c-style-cast <modernize/avoid-c-style-cast>`, "Yes" :doc:`google-readability-function-size <google/readability-function-size>`, :doc:`readability-function-size <readability/function-size>`, :doc:`google-readability-namespace-comments <google/readability-namespace-comments>`, :doc:`llvm-namespace-comment <llvm/namespace-comment>`, - :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" :doc:`hicpp-multiway-paths-covered <hicpp/multiway-paths-covered>`, :doc:`bugprone-unhandled-code-paths <bugprone/unhandled-code-paths>`, - :doc:`hicpp-named-parameter <hicpp/named-parameter>`, :doc:`readability-named-parameter <readability/named-parameter>`, "Yes" - :doc:`hicpp-new-delete-operators <hicpp/new-delete-operators>`, :doc:`misc-new-delete-overloads <misc/new-delete-overloads>`, - :doc:`hicpp-no-array-decay <hicpp/no-array-decay>`, :doc:`cppcoreguidelines-pro-bounds-array-to-pointer-decay <cppcoreguidelines/pro-bounds-array-to-pointer-decay>`, :doc:`hicpp-no-assembler <hicpp/no-assembler>`, :doc:`portability-no-assembler <portability/no-assembler>`, :doc:`hicpp-no-malloc <hicpp/no-malloc>`, :doc:`cppcoreguidelines-no-malloc <cppcoreguidelines/no-malloc>`, - :doc:`hicpp-noexcept-move <hicpp/noexcept-move>`, :doc:`performance-noexcept-move-constructor <performance/noexcept-move-constructor>`, "Yes" - :doc:`hicpp-signed-bitwise <hicpp/signed-bitwise>`, :doc:`bugprone-signed-bitwise <bugprone/signed-bitwise>`, :doc:`hicpp-special-member-functions <hicpp/special-member-functions>`, :doc:`cppcoreguidelines-special-member-functions <cppcoreguidelines/special-member-functions>`, :doc:`hicpp-static-assert <hicpp/static-assert>`, :doc:`misc-static-assert <misc/static-assert>`, "Yes" :doc:`hicpp-undelegated-constructor <hicpp/undelegated-constructor>`, :doc:`bugprone-undelegated-constructor <bugprone/undelegated-constructor>`, diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/duplicate-conflicted-fixes-of-alias-checkers.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/duplicate-conflicted-fixes-of-alias-checkers.cpp index 365908107e563..7549bcafd41ff 100644 --- a/clang-tools-extra/test/clang-tidy/infrastructure/duplicate-conflicted-fixes-of-alias-checkers.cpp +++ b/clang-tools-extra/test/clang-tidy/infrastructure/duplicate-conflicted-fixes-of-alias-checkers.cpp @@ -1,23 +1,20 @@ -// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init,hicpp-member-init,modernize-use-emplace,hicpp-use-emplace %t -- \ +// RUN: %check_clang_tidy %s cppcoreguidelines-use-default-member-init,modernize-use-default-member-init %t -- \ //// RUN: -config='{CheckOptions: { \ -//// RUN: cppcoreguidelines-pro-type-member-init.UseAssignment: true, \ +//// RUN: cppcoreguidelines-use-default-member-init.UseAssignment: true, \ //// RUN: }}' class Foo { public: - Foo() : _num1(0) - // CHECK-MESSAGES: warning: constructor does not initialize these fields: _num2 [cppcoreguidelines-pro-type-member-init,hicpp-member-init] - // CHECK-MESSAGES: note: cannot apply fix-it because an alias checker has suggested a diff erent fix-it; please remove one of the checkers ('cppcoreguidelines-pro-type-member-init', 'hicpp-member-init') or ensure they are both configured the same - { - _num1 = 10; - } + Foo() : _num(0) + // CHECK-MESSAGES: warning: use default member initializer for '_num' [cppcoreguidelines-use-default-member-init,modernize-use-default-member-init] + // CHECK-MESSAGES: note: cannot apply fix-it because an alias checker has suggested a diff erent fix-it; please remove one of the checkers ('cppcoreguidelines-use-default-member-init', 'modernize-use-default-member-init') or ensure they are both configured the same + {} int use_the_members() const { - return _num1 + _num2; + return _num; } private: - int _num1; - int _num2; - // CHECK-FIXES: int _num2; + int _num; + // CHECK-FIXES: int _num; }; diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp index 78a903a2feec0..4c5d5a957ff7e 100644 --- a/clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp +++ b/clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp @@ -1,39 +1,23 @@ -// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init,hicpp-member-init,modernize-use-emplace,hicpp-use-emplace %t - -namespace std { - -template <typename T> -class vector { -public: - void push_back(const T &) {} - void push_back(T &&) {} - - template <typename... Args> - void emplace_back(Args &&... args){}; -}; -} // namespace std +// RUN: %check_clang_tidy %s cppcoreguidelines-use-default-member-init,modernize-use-default-member-init,cppcoreguidelines-explicit-constructor,misc-explicit-constructor %t class Foo { public: - Foo() : _num1(0) - // CHECK-MESSAGES: warning: constructor does not initialize these fields: _num2 [cppcoreguidelines-pro-type-member-init,hicpp-member-init] - { - _num1 = 10; - } + Foo() : _num(0) + // CHECK-MESSAGES: warning: use default member initializer for '_num' [cppcoreguidelines-use-default-member-init,modernize-use-default-member-init] + {} int use_the_members() const { - return _num1 + _num2; + return _num; } private: - int _num1; - int _num2; - // CHECK-FIXES: int _num2{}; + int _num; + // CHECK-FIXES: int _num{0}; }; -void should_use_emplace(std::vector<Foo> &v) { - v.push_back(Foo()); - // CHECK-FIXES: v.emplace_back(); - // CHECK-MESSAGES: warning: use emplace_back instead of push_back [hicpp-use-emplace,modernize-use-emplace] -} - +class Bar { +public: + Bar(int); + // CHECK-MESSAGES: warning: single-argument constructors must be marked explicit to avoid unintentional implicit conversions [cppcoreguidelines-explicit-constructor,misc-explicit-constructor] + // CHECK-FIXES: explicit Bar(int); +}; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
