43 lines · plain
1.. title:: clang-tidy - readability-redundant-parentheses2 3readability-redundant-parentheses4=================================5 6Detect redundant parentheses.7 8When modifying code, one often forgets to remove the corresponding parentheses.9This results in overly lengthy code. When the expression is complex, finding10the matching parentheses becomes particularly difficult.11 12Example13-------14 15.. code-block:: c++16 17 (1);18 ((a + 2)) * 3;19 (a);20 ("aaa");21 22Currently this check does not take into account the precedence of operations.23Even if the expression within the parentheses has a higher priority than that24outside the parentheses. In other words, removing the parentheses will not25affect the semantics.26 27.. code-block:: c++28 29 int a = (1 * 2) + 3; // no warning30 31Options32-------33 34.. option:: AllowedDecls35 36 Semicolon-separated list of regular expressions matching names of declarations37 to ignore when the parentheses are around. Declarations can include variables38 or functions. The default is an `std::max;std::min`.39 40 Some STL library functions may have the same name as widely used function-like41 macro. For example, ``std::max`` and ``max`` macro. A workaround to distinguish42 them is adding parentheses around functions to prevent function-like macro.43