2015-12-23 01:36:49 +08:00
|
|
|
.. title:: clang-tidy - misc-macro-parentheses
|
|
|
|
|
2015-08-28 02:10:07 +08:00
|
|
|
misc-macro-parentheses
|
|
|
|
======================
|
|
|
|
|
|
|
|
|
|
|
|
Finds macros that can have unexpected behaviour due to missing parentheses.
|
|
|
|
|
|
|
|
Macros are expanded by the preprocessor as-is. As a result, there can be
|
|
|
|
unexpected behaviour; operators may be evaluated in unexpected order and
|
|
|
|
unary operators may become binary operators, etc.
|
|
|
|
|
|
|
|
When the replacement list has an expression, it is recommended to surround
|
|
|
|
it with parentheses. This ensures that the macro result is evaluated
|
|
|
|
completely before it is used.
|
|
|
|
|
|
|
|
It is also recommended to surround macro arguments in the replacement list
|
|
|
|
with parentheses. This ensures that the argument value is calculated
|
|
|
|
properly.
|