CodeQL library for C/C++
codeql/cpp-all 0.12.9 (changelog, source)
Search

Predicate exprWithEmptyRange

Holds if expr has a provably empty range. For example:

10 < expr and expr < 5

The range of an expression can only be empty if it can never be executed. For example:

if (10 < x) {
  if (x < 5) {
    // Unreachable code
    return x; // x has an empty range: 10 < x && x < 5
  }
}

Import path

import semmle.code.cpp.rangeanalysis.new.SimpleRangeAnalysis
predicate exprWithEmptyRange(Expr expr)