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

Module RangeAnalysisUtils

Import path

import semmle.code.cpp.rangeanalysis.RangeAnalysisUtils

Imports

cpp

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

Predicates

cmpWithLinearBound

Holds if guard is a comparison operation (<, <=, >, >=, == or !=), one of its arguments is equivalent (up to associativity, commutativity and distributivity or the simple arithmetic operations) to p*v + q (for some p and q), direction describes whether guard give an upper or lower bound on v, and branch indicates which control-flow branch this bound is valid on.

directionIsGreater

Holds if dir is Greater (that is, a > or >= relation)

directionIsLesser

Holds if dir is Lesser (that is, a < or <= relation)

eqOpWithSwapAndNegate

Holds if cmp is an equality operation (== or !=) with fully-converted children a and b, isEQ is true if cmp is an == operation and false if it is an != operation, and the result is branch.

eqZeroWithNegate

Holds if branch of cmp is taken when a compares isEQ to zero.

exprMaxVal

Gets the maximum value that this expression could represent, based on its type.

exprMinVal

Gets the minimum value that this expression could represent, based on its type.

getVariableRangeType

Gets the type used by range analysis for the given StackVariable.

linearAccess

Holds if expr is equivalent to p*v + q, where p is a non-zero number. This takes into account the associativity, commutativity and distributivity of arithmetic operations.

relOpWithSwap

Holds if rel is a relational operation (<, >, <= or >=) with fully-converted children a and b, described by dir and strict.

relOpWithSwapAndNegate

Holds if rel is a comparison operation (<, >, <= or >=) with fully-converted children a and b, described by dir and strict, with result branch.

typeLowerBound

Gets the lower bound for the unspecified type t.

typeUpperBound

Gets the upper bound for the unspecified type t.

varMaxVal

Gets the maximum value that this variable could represent, based on its type.

varMinVal

Gets the minimum value that this variable could represent, based on its type.

Datatypes

RelationDirection

Describes whether a relation is ‘greater’ (that is, a > or >= relation) or ‘lesser’ (a < or <= relation).

RelationStrictness

Describes whether a relation is ‘strict’ (that is, a < or > relation) or ‘non-strict’ (a <= or >= relation).