diff options
14 files changed, 161 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp index 26b21cf3d31..3cde3684e9e 100644 --- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp @@ -10,6 +10,19 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" +#include "../cppcoreguidelines/ProTypeMemberInitCheck.h" +#include "../cppcoreguidelines/SpecialMemberFunctionsCheck.h" +#include "../google/DefaultArgumentsCheck.h" +#include "../google/ExplicitConstructorCheck.h" +#include "../misc/NewDeleteOverloadsCheck.h" +#include "../misc/NoexceptMoveConstructorCheck.h" +#include "../misc/UndelegatedConstructor.h" +#include "../misc/UseAfterMoveCheck.h" +#include "../modernize/UseEqualsDefaultCheck.h" +#include "../modernize/UseEqualsDeleteCheck.h" +#include "../modernize/UseOverrideCheck.h" +#include "../readability/FunctionSizeCheck.h" +#include "../readability/IdentifierNamingCheck.h" #include "NoAssemblerCheck.h" namespace clang { @@ -19,8 +32,32 @@ namespace hicpp { class HICPPModule : public ClangTidyModule { public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { - CheckFactories.registerCheck<NoAssemblerCheck>( - "hicpp-no-assembler"); + CheckFactories.registerCheck<google::ExplicitConstructorCheck>( + "hicpp-explicit-conversions"); + CheckFactories.registerCheck<readability::FunctionSizeCheck>( + "hicpp-function-size"); + CheckFactories.registerCheck<readability::IdentifierNamingCheck>( + "hicpp-named-parameter"); + CheckFactories.registerCheck<misc::UseAfterMoveCheck>( + "hicpp-invalid-access-moved"); + CheckFactories.registerCheck<cppcoreguidelines::ProTypeMemberInitCheck>( + "hicpp-member-init"); + CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>( + "hicpp-new-delete-operators"); + CheckFactories.registerCheck<misc::NoexceptMoveConstructorCheck>( + "hicpp-noexcept-move"); + CheckFactories.registerCheck<NoAssemblerCheck>("hicpp-no-assembler"); + CheckFactories + .registerCheck<cppcoreguidelines::SpecialMemberFunctionsCheck>( + "hicpp-special-member-functions"); + CheckFactories.registerCheck<misc::UndelegatedConstructorCheck>( + "hicpp-undelegated-constructor"); + CheckFactories.registerCheck<modernize::UseEqualsDefaultCheck>( + "hicpp-use-equals-default"); + CheckFactories.registerCheck<modernize::UseEqualsDeleteCheck>( + "hicpp-use-equals-delete"); + CheckFactories.registerCheck<modernize::UseOverrideCheck>( + "hicpp-use-override"); } }; diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index a13c22743a3..8f995c6fc12 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -76,10 +76,10 @@ Improvements to clang-tidy Finds functions that have more then `ParameterThreshold` parameters and emits a warning. -- New `safety-no-assembler - <http://clang.llvm.org/extra/clang-tidy/checks/safety-no-assembler.html>`_ check +- New `hicpp` module - Finds uses of inline assembler. + Adds checks that implement the `High Integrity C++ Coding Standard <http://www.codingstandard.com/section/index/>`_ and other safety + standards. Many checks are aliased to other modules. - New `modernize-return-braced-init-list <http://clang.llvm.org/extra/clang-tidy/checks/modernize-return-braced-init-list.html>`_ check diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp-explicit-conversions.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp-explicit-conversions.rst new file mode 100644 index 00000000000..1779473a07c --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-explicit-conversions.rst @@ -0,0 +1,15 @@ +.. title:: clang-tidy - hicpp-explicit-conversions + +hicpp-explicit-conversions +========================== + +This check is an alias for `google-explicit-constructor <google-explicit-constructor.hml>`_. +Used to enforce parts of `rule 5.4.1 <http://www.codingstandard.com/rule/5-4-1-only-use-casting-forms-static_cast-excl-void-dynamic_cast-or-explicit-constructor-call/>`_. +This check will enforce that constructors and conversion operators are marked `explicit`. +Other forms of casting checks are implemented in other places. +The following checks can be used to check for more forms of casting: + +- `cppcoreguidelines-pro-type-static-cast-downcast <cppcoreguidelines-pro-type-static-cast-downcast.html>`_ +- `cppcoreguidelines-pro-type-reinterpret-cast <cppcoreguidelines-pro-type-reinterpret-cast.html>`_ +- `cppcoreguidelines-pro-type-const-cast <cppcoreguidelines-pro-type-const-cast.html>`_ +- `cppcoreguidelines-pro-type-cstyle-cast <cppcoreguidelines-pro-type-cstyle-cast.html>`_ diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp-function-size.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp-function-size.rst new file mode 100644 index 00000000000..b82a72214f0 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-function-size.rst @@ -0,0 +1,11 @@ +.. title:: clang-tidy - hicpp-function-size + +hicpp-function-size +=================== + +This check is an alias for `readability-function-size <readability-function-size.hml>`_. +Useful to enforce multiple sections on function complexity. + +- `rule 8.2.2 <http://www.codingstandard.com/rule/8-2-2-do-not-declare-functions-with-an-excessive-number-of-parameters/>`_ +- `rule 8.3.1 <http://www.codingstandard.com/rule/8-3-1-do-not-write-functions-with-an-excessive-mccabe-cyclomatic-complexity/>`_ +- `rule 8.3.2 <http://www.codingstandard.com/rule/8-3-2-do-not-write-functions-with-a-high-static-program-path-count/>`_ 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 new file mode 100644 index 00000000000..d016eaee7e2 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst @@ -0,0 +1,8 @@ +.. title:: clang-tidy - hicpp-invalid-access-moved + +hicpp-invalid-access-moved +========================== + +This check is an alias for `misc-use-after-move <misc-use-after-move.hml>`_. + +Implements parts of the `rule 8.4.1 <http://www.codingstandard.com/rule/8-4-1-do-not-access-an-invalid-object-or-an-object-with-indeterminate-value/>`_ 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 new file mode 100644 index 00000000000..eb948ae8ae3 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-member-init.rst @@ -0,0 +1,9 @@ +.. title:: clang-tidy - hicpp-member-init + +hicpp-member-init +================= + +This check is an alias for `cppcoreguidelines-pro-type-member-init <cppcoreguidelines-pro-type-member-init.hml>`_. +Implements the check for +`rule 12.4.2 <http://www.codingstandard.com/rule/12-4-2-ensure-that-a-constructor-initializes-explicitly-all-base-classes-and-non-static-data-members/>`_ +to initialize class members in the right order. 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 new file mode 100644 index 00000000000..d848d07fc4d --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-named-parameter.rst @@ -0,0 +1,8 @@ +.. title:: clang-tidy - hicpp-named-parameter + +hicpp-named-parameter +===================== + +This check is an alias for `readability-named-parameter <readability-named-parameter.hml>`_. + +Implements `rule 8.2.1 <http://www.codingstandard.com/rule/8-2-1-make-parameter-names-absent-or-identical-in-all-declarations/>`_. 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 new file mode 100644 index 00000000000..8994644f23b --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-new-delete-operators.rst @@ -0,0 +1,8 @@ +.. title:: clang-tidy - hicpp-new-delete-operators + +hicpp-new-delete-operators +========================== + +This check is an alias for `misc-new-delete-overloads <misc-new-delete-overloads.hml>`_. +Implements `rule 12.3.1 <http://www.codingstandard.com/section/12-3-free-store/>`_ to ensure +the `new` and `delete` operators have the correct signature. 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 new file mode 100644 index 00000000000..8a2fdadda56 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-noexcept-move.rst @@ -0,0 +1,7 @@ +.. title:: clang-tidy - hicpp-noexcept-move + +hicpp-noexcept-move +=================== + +This check is an alias for `misc-noexcept-moveconstructor <misc-noexcept-moveconstructor.hml>`_. +Checks `rule 12.5.4 <http://www.codingstandard.com/rule/12-5-4-declare-noexcept-the-move-constructor-and-move-assignment-operator/`_ to mark move assignment and move construction `noexcept`. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp-special-member-functions.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp-special-member-functions.rst new file mode 100644 index 00000000000..b50c934964a --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-special-member-functions.rst @@ -0,0 +1,7 @@ +.. title:: clang-tidy - hicpp-special-member-functions + +hicpp-special-member-functions +============================== + +This check is an alias for `cppcoreguidelines-special-member-functions <cppcoreguidelines-special-member-functions.hml>`_. +Checks that special member functions have the correct signature, according to `rule 12.5.7 <http://www.codingstandard.com/rule/12-5-7-declare-assignment-operators-with-the-ref-qualifier/>`_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst new file mode 100644 index 00000000000..d05d7629c16 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst @@ -0,0 +1,23 @@ +.. title:: clang-tidy - hicpp-undelegated-construtor + +hicpp-undelegated-constructor +============================= + +This check is an alias for `misc-undelegated-constructor <misc-undelegated-constructor.hml>`_. +Partially implements `rule 12.4.5 <http://www.codingstandard.com/rule/12-4-5-use-delegating-constructors-to-reduce-code-duplication/>`_ +to find misplaced constructor calls inside a constructor. + +.. code-block:: c++ + + struct Ctor { + Ctor(); + Ctor(int); + Ctor(int, int); + Ctor(Ctor *i) { + // All Ctor() calls result in a temporary object + Ctor(); // did you intend to call a delegated constructor? + Ctor(0); // did you intend to call a delegated constructor? + Ctor(1, 2); // did you intend to call a delegated constructor? + foo(); + } + }; diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp-use-equals-default.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp-use-equals-default.rst new file mode 100644 index 00000000000..380ecfc10f6 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-use-equals-default.rst @@ -0,0 +1,7 @@ +.. title:: clang-tidy - hicpp-use-equals-defaults + +hicpp-use-equals-default +======================== + +This check is an alias for `modernize-use-equals-default <modernize-use-equals-default.hml>`_. +Implements `rule 12.5.1 <http://www.codingstandard.com/rule/12-5-1-define-explicitly-default-or-delete-implicit-special-member-functions-of-concrete-classes/>`_ to explicitly default special member functions. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp-use-equals-delete.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp-use-equals-delete.rst new file mode 100644 index 00000000000..c05da237d3a --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-use-equals-delete.rst @@ -0,0 +1,8 @@ +.. title:: clang-tidy - hicpp-use-equals-delete + +hicpp-use-equals-delete +======================= + +This check is an alias for `modernize-use-equals-delete <modernize-use-equals-delete.hml>`_. +Implements `rule 12.5.1 <http://www.codingstandard.com/rule/12-5-1-define-explicitly-default-or-delete-implicit-special-member-functions-of-concrete-classes/>`_ +to explicitly default or delete special member functions. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp-use-override.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp-use-override.rst new file mode 100644 index 00000000000..fa1f158a4e7 --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-use-override.rst @@ -0,0 +1,8 @@ +.. title:: clang-tidy - hicpp-use-override + +hicpp-use-override +================== + +This check is an alias for `modernize-use-override <modernize-use-override.hml>`_. +Implements `rule 10.2.1 <http://www.codingstandard.com/section/10-2-virtual-functions/>`_ to +declare a virtual function `override` when overriding. |

