[clang-tools-extra] r299068 - [clang-tidy] add aliases for hicpp module

Jonathan Coe via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 30 04:57:55 PDT 2017


Author: jbcoe
Date: Thu Mar 30 06:57:54 2017
New Revision: 299068

URL: http://llvm.org/viewvc/llvm-project?rev=299068&view=rev
Log:
[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

Added:
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-explicit-conversions.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-function-size.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-member-init.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-named-parameter.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-new-delete-operators.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-special-member-functions.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-default.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-delete.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-override.rst
Modified:
    clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
    clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp?rev=299068&r1=299067&r2=299068&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp Thu Mar 30 06:57:54 2017
@@ -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");
   }
 };
 

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=299068&r1=299067&r2=299068&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Mar 30 06:57:54 2017
@@ -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

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-explicit-conversions.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-explicit-conversions.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-explicit-conversions.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-explicit-conversions.rst Thu Mar 30 06:57:54 2017
@@ -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>`_

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-function-size.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-function-size.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-function-size.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-function-size.rst Thu Mar 30 06:57:54 2017
@@ -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/>`_

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst Thu Mar 30 06:57:54 2017
@@ -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.

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-member-init.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-member-init.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-member-init.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-member-init.rst Thu Mar 30 06:57:54 2017
@@ -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.

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-named-parameter.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-named-parameter.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-named-parameter.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-named-parameter.rst Thu Mar 30 06:57:54 2017
@@ -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/>`_.

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-new-delete-operators.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-new-delete-operators.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-new-delete-operators.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-new-delete-operators.rst Thu Mar 30 06:57:54 2017
@@ -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.

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst Thu Mar 30 06:57:54 2017
@@ -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`.

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-special-member-functions.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-special-member-functions.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-special-member-functions.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-special-member-functions.rst Thu Mar 30 06:57:54 2017
@@ -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/>`_.

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst Thu Mar 30 06:57:54 2017
@@ -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();
+    }
+  };

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-default.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-default.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-default.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-default.rst Thu Mar 30 06:57:54 2017
@@ -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.

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-delete.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-delete.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-delete.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-delete.rst Thu Mar 30 06:57:54 2017
@@ -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.

Added: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-override.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-override.rst?rev=299068&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-override.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-override.rst Thu Mar 30 06:57:54 2017
@@ -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.




More information about the cfe-commits mailing list