summaryrefslogtreecommitdiff
path: root/clang-tools-extra/docs
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@vmiklos.hu>2019-01-11 07:59:47 +0000
committerMiklos Vajna <vmiklos@vmiklos.hu>2019-01-11 07:59:47 +0000
commitc18a877acb9c1f60e556ef0353ea642998fa2453 (patch)
tree120c899401d771628e555bcb182b355d45926150 /clang-tools-extra/docs
parentb4d009e374cb758fd55d05b8b687b011dd01d06f (diff)
[clang-tidy] new check 'readability-redundant-preprocessor'
Finds potentially redundant preprocessor directives. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D54349
Diffstat (limited to 'clang-tools-extra/docs')
-rw-r--r--clang-tools-extra/docs/ReleaseNotes.rst5
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/list.rst1
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/readability-redundant-preprocessor.rst61
3 files changed, 67 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index f6cdc3efbdc..8731dc73c64 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -244,6 +244,11 @@ Improvements to clang-tidy
Detects usage of magic numbers, numbers that are used as literals instead of
introduced via constants or symbols.
+- New :doc:`readability-redundant-preprocessor
+ <clang-tidy/checks/readability-redundant-preprocessor>` check.
+
+ Finds potentially redundant preprocessor directives.
+
- New :doc:`readability-uppercase-literal-suffix
<clang-tidy/checks/readability-uppercase-literal-suffix>` check.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index b4a60e76c8e..080e747bdfa 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -254,6 +254,7 @@ Clang-Tidy Checks
readability-redundant-declaration
readability-redundant-function-ptr-dereference
readability-redundant-member-init
+ readability-redundant-preprocessor
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-preprocessor.rst b/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-preprocessor.rst
new file mode 100644
index 00000000000..f013a3417d3
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-preprocessor.rst
@@ -0,0 +1,61 @@
+.. title:: clang-tidy - readability-redundant-preprocessor
+
+readability-redundant-preprocessor
+==================================
+
+Finds potentially redundant preprocessor directives. At the moment the
+following cases are detected:
+
+* `#ifdef` .. `#endif` pairs which are nested inside an outer pair with the
+ same condition. For example:
+
+.. code-block:: c++
+
+ #ifdef FOO
+ #ifdef FOO // inner ifdef is considered redundant
+ void f();
+ #endif
+ #endif
+
+* Same for `#ifndef` .. `#endif` pairs. For example:
+
+.. code-block:: c++
+
+ #ifndef FOO
+ #ifndef FOO // inner ifndef is considered redundant
+ void f();
+ #endif
+ #endif
+
+* `#ifndef` inside an `#ifdef` with the same condition:
+
+.. code-block:: c++
+
+ #ifdef FOO
+ #ifndef FOO // inner ifndef is considered redundant
+ void f();
+ #endif
+ #endif
+
+* `#ifdef` inside an `#ifndef` with the same condition:
+
+.. code-block:: c++
+
+ #ifndef FOO
+ #ifdef FOO // inner ifdef is considered redundant
+ void f();
+ #endif
+ #endif
+
+* `#if` .. `#endif` pairs which are nested inside an outer pair with the same
+ condition. For example:
+
+.. code-block:: c++
+
+ #define FOO 4
+ #if FOO == 4
+ #if FOO == 4 // inner if is considered redundant
+ void f();
+ #endif
+ #endif
+