HomePhabricator

[clang-tidy] Misc redundant expressions checker updated for macros

Description

[clang-tidy] Misc redundant expressions checker updated for macros

Redundant Expression Checker is updated to be able to detect expressions that
contain macros. Also, other small details are modified to improve the current
implementation.

The improvements in detail are as follows:

  • Binary and ternary operator expressions containing two constants, with at

least one of them from a macro, are detected and tested for redundancy.

Macro expressions are treated somewhat differently from other expressions,
because the particular values of macros can vary across builds.
They can be considered correct and intentional, even if macro values equal,
produce ranges that exclude each other or fully overlap, etc.

  • The code structure is slightly modified: typos are corrected,

comments are added and some functions are renamed to improve comprehensibility,
both in the checker and the test file. A few test cases are moved to another
function.

  • The checker is now able to detect redundant CXXFunctionalCastExprs as well.

A corresponding test case is added.

Patch by: Lilla Barancsuk!

Differential Revision: https://reviews.llvm.org/D38688