summaryrefslogtreecommitdiff
path: root/clang-tools-extra/docs
diff options
context:
space:
mode:
authorJonas Toth <jonas.toth@gmail.com>2018-10-22 19:20:01 +0000
committerJonas Toth <jonas.toth@gmail.com>2018-10-22 19:20:01 +0000
commit952e154e5432a4ea17c728247e8e3037fd447646 (patch)
tree1dbbaf3531661e1f5dfd2c88a95dd0fccfd89cf7 /clang-tools-extra/docs
parent4fbc44d503964d4d006ce72652e2f302167fdf57 (diff)
[clang-tidy] implement cppcoreguidelines macro rules
Summary: In short macros are discouraged by multiple rules (and sometimes reference randomly). [Enum.1], [ES.30], [ES.31] This check allows only headerguards and empty macros for annotation. Reviewers: aaron.ballman, hokein Reviewed By: aaron.ballman Subscribers: jbcoe, Eugene.Zelenko, klimek, nemanjai, mgorny, xazax.hun, kbarton, cfe-commits Differential Revision: https://reviews.llvm.org/D41648
Diffstat (limited to 'clang-tools-extra/docs')
-rw-r--r--clang-tools-extra/docs/ReleaseNotes.rst6
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst28
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/list.rst1
3 files changed, 35 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 2afb6317793..cbb2fa3874a 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -103,6 +103,12 @@ Improvements to clang-tidy
Flags uses of ``absl::StrCat()`` to append to a ``std::string``. Suggests
``absl::StrAppend()`` should be used instead.
+- New :doc:`cppcoreguidelines-macro-usage
+ <clang-tidy/checks/cppcoreguidelines-macro-usage>` check.
+
+ Find macro usage that is considered problematic because better language
+ constructs exist for the task.
+
- New :doc:`misc-non-private-member-variables-in-classes
<clang-tidy/checks/misc-non-private-member-variables-in-classes>` check.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst
new file mode 100644
index 00000000000..514ad8659f1
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-macro-usage.rst
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - cppcoreguidelines-macro-usage
+
+cppcoreguidelines-macro-usage
+=============================
+
+Find macro usage that is considered problematic because better language
+constructs exist for the task.
+
+The relevant sections in the C++ Core Guidelines are
+`Enum.1 <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#enum1-prefer-enumerations-over-macros>`_,
+`ES.30 <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es30-dont-use-macros-for-program-text-manipulation>`_,
+`ES.31 <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es31-dont-use-macros-for-constants-or-functions>`_ and
+`ES.33 <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es33-if-you-must-use-macros-give-them-unique-names>`_.
+
+Options
+-------
+
+.. option:: AllowedRegexp
+
+ A regular expression to filter allowed macros. For example
+ `DEBUG*|LIBTORRENT*|TORRENT*|UNI*` could be applied to filter `libtorrent`.
+ Default value is `^DEBUG_*`.
+
+.. option:: CheckCapsOnly
+
+ Boolean flag to warn on all macros except those with CAPS_ONLY names.
+ This option is intended to ease introduction of this check into older
+ code bases. Default value is `0`/`false`.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index fc915d75b76..f7fa7c5a33f 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -89,6 +89,7 @@ Clang-Tidy Checks
cppcoreguidelines-avoid-magic-numbers (redirects to readability-magic-numbers) <cppcoreguidelines-avoid-magic-numbers>
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) <cppcoreguidelines-c-copy-assignment-signature>
cppcoreguidelines-interfaces-global-init
+ cppcoreguidelines-macro-usage
cppcoreguidelines-narrowing-conversions
cppcoreguidelines-no-malloc
cppcoreguidelines-non-private-member-variables-in-classes (redirects to misc-non-private-member-variables-in-classes) <cppcoreguidelines-non-private-member-variables-in-classes>