Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang-tidy] add aliases for hicpp module
Summary: Add some hicpp checks that can be implmented as alises for existing clang-tidy checks: hicpp-explicit-conversions hicpp-function-size hicpp-named-parameter hicpp-invalid-access-moved hicpp-member-init hicpp-new-delete-operators hicpp-noexcept-move hicpp-special-member-functions hicpp-undelegated-constructor hicpp-use-equals-default hicpp-use-equals-delete hicpp-use-override Reviewers: dberlin, jbcoe, aaron.ballman, alexfh Reviewed By: aaron.ballman Subscribers: JDevlieghere Differential Revision: https://reviews.llvm.org/D30383 Patch By: Jonas Toth llvm-svn: 299068
- Loading branch information
Showing
14 changed files
with
161 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
clang-tools-extra/docs/clang-tidy/checks/hicpp-explicit-conversions.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>`_ |
11 changes: 11 additions & 0 deletions
11
clang-tools-extra/docs/clang-tidy/checks/hicpp-function-size.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/>`_ |
8 changes: 8 additions & 0 deletions
8
clang-tools-extra/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
9 changes: 9 additions & 0 deletions
9
clang-tools-extra/docs/clang-tidy/checks/hicpp-member-init.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
8 changes: 8 additions & 0 deletions
8
clang-tools-extra/docs/clang-tidy/checks/hicpp-named-parameter.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/>`_. |
8 changes: 8 additions & 0 deletions
8
clang-tools-extra/docs/clang-tidy/checks/hicpp-new-delete-operators.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
7 changes: 7 additions & 0 deletions
7
clang-tools-extra/docs/clang-tidy/checks/hicpp-noexcept-move.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
7 changes: 7 additions & 0 deletions
7
clang-tools-extra/docs/clang-tidy/checks/hicpp-special-member-functions.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/>`_. |
23 changes: 23 additions & 0 deletions
23
clang-tools-extra/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
}; |
7 changes: 7 additions & 0 deletions
7
clang-tools-extra/docs/clang-tidy/checks/hicpp-use-equals-default.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
8 changes: 8 additions & 0 deletions
8
clang-tools-extra/docs/clang-tidy/checks/hicpp-use-equals-delete.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
8 changes: 8 additions & 0 deletions
8
clang-tools-extra/docs/clang-tidy/checks/hicpp-use-override.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |