62 lines · plain
1.. title:: clang-tidy - readability-redundant-preprocessor2 3readability-redundant-preprocessor4==================================5 6Finds potentially redundant preprocessor directives. At the moment the7following cases are detected:8 9* `#ifdef` .. `#endif` pairs which are nested inside an outer pair with the10 same condition. For example:11 12.. code-block:: c++13 14 #ifdef FOO15 #ifdef FOO // inner ifdef is considered redundant16 void f();17 #endif18 #endif19 20* Same for `#ifndef` .. `#endif` pairs. For example:21 22.. code-block:: c++23 24 #ifndef FOO25 #ifndef FOO // inner ifndef is considered redundant26 void f();27 #endif28 #endif29 30* `#ifndef` inside an `#ifdef` with the same condition:31 32.. code-block:: c++33 34 #ifdef FOO35 #ifndef FOO // inner ifndef is considered redundant36 void f();37 #endif38 #endif39 40* `#ifdef` inside an `#ifndef` with the same condition:41 42.. code-block:: c++43 44 #ifndef FOO45 #ifdef FOO // inner ifdef is considered redundant46 void f();47 #endif48 #endif49 50* `#if` .. `#endif` pairs which are nested inside an outer pair with the same51 condition. For example:52 53.. code-block:: c++54 55 #define FOO 456 #if FOO == 457 #if FOO == 4 // inner if is considered redundant58 void f();59 #endif60 #endif61 62