[clang-tidy] add aliases for hicpp module
authorJonathan Coe <jbcoe@me.com>
Thu, 30 Mar 2017 11:57:54 +0000 (11:57 +0000)
committerJonathan Coe <jbcoe@me.com>
Thu, 30 Mar 2017 11:57:54 +0000 (11:57 +0000)
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

14 files changed:
clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/hicpp-explicit-conversions.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/hicpp-function-size.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/hicpp-member-init.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/hicpp-named-parameter.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/hicpp-new-delete-operators.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/hicpp-noexcept-move.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/hicpp-special-member-functions.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/hicpp-use-equals-default.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/hicpp-use-equals-delete.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/hicpp-use-override.rst [new file with mode: 0644]

index 26b21cf..3cde368 100644 (file)
 #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");
   }
 };
 
index a13c227..8f995c6 100644 (file)
@@ -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 (file)
index 0000000..1779473
--- /dev/null
@@ -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 (file)
index 0000000..b82a722
--- /dev/null
@@ -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 (file)
index 0000000..d016eae
--- /dev/null
@@ -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 (file)
index 0000000..eb948ae
--- /dev/null
@@ -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 (file)
index 0000000..d848d07
--- /dev/null
@@ -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 (file)
index 0000000..8994644
--- /dev/null
@@ -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 (file)
index 0000000..8a2fdad
--- /dev/null
@@ -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 (file)
index 0000000..b50c934
--- /dev/null
@@ -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 (file)
index 0000000..d05d762
--- /dev/null
@@ -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 (file)
index 0000000..380ecfc
--- /dev/null
@@ -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 (file)
index 0000000..c05da23
--- /dev/null
@@ -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 (file)
index 0000000..fa1f158
--- /dev/null
@@ -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.