Miscellaneous-ExpressionsWithoutSideEffect

There shall be no expressions that could be removed because they do not affect program behaviour

Required inputs: IR

Code that has no effect should be eliminated to improve readability.

Possible Messages

Key

Text

Severity

Disabled

redundant_expression

Binary operator with this operand is redundant, expression can be simplified (operator can be removed) without affecting program behaviour

None

False

removable_expression

Expression (but not necessarily all subexpressions) can be removed without affecting program behaviour

None

False

Options

check_preprocessor_expressions

check_preprocessor_expressions : bool = False

Whether preprocessor expressions should be checked for redundant operations like expr || 0 as well.
 

list_side_effect_free_statements

list_side_effect_free_statements : bool = False

Whether toplevel expressions from completely side-effect free statements should be listed as well.
 

report_redundant_expressions_from_macros

report_redundant_expressions_from_macros : bool = False

Whether redundant expressions like expr + 0 should be reported if the constant comes from a macro (and the operator does not come from the same macro).
 

report_redundant_sizeof_expressions

report_redundant_sizeof_expressions : bool = False

Whether redundant expressions like expr * 1 should be reported if the constant comes from evaluating sizeof().