Query module ComparisonWithCancelingSubExpr

name
Comparison with canceling sub-expression
description
If the same sub-expression is added to both sides of a comparison, and there is no possibility of overflow or rounding, then the sub-expression is redundant and could be removed.
kind
problem
problem.severity
recommendation
precision
medium
id
cpp/comparison-canceling-subexpr
tags
readability maintainability

Imports

BadAdditionOverflowCheck

Provides the implementation of the BadAdditionOverflowCheck query. The query is implemented as a library, so that we can avoid producing duplicate results in other similar queries.

PointlessSelfComparison

Provides the implementation of the PointlessSelfComparison query. The query is implemented as a library, so that we can avoid producing duplicate results in other similar queries.

SimpleRangeAnalysis

Simple range analysis library. Range analysis is usually done as an abstract interpretation over the lattice of range values. (A range is a pair, containing a lower and upper bound for the value.) The problem with this approach is that the lattice is very tall, which means it can take an extremely large number of iterations to find the least fixed point. This example illustrates the problem:

cpp

Provides classes and predicates for working with C/C++/ObjC/ObjC++ code.