Query module NoBooleanSideEffects

name
Side effect in a Boolean expression
description
The evaluation of a Boolean expression shall have no side effects.
kind
problem
id
cpp/jpl-c/no-boolean-side-effects
problem.severity
warning

Imports

cpp

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

Predicates

getAPointerType

Gets a “pointer type” contained in the given type. This traverses typedefs and derived types, including types of struct or union members, returning each “pointer to X” type encountered on that traversal.

hasSideEffect
inherentlyUnsafe

A function is “inherently unsafe” for side effects if it writes a global or static variable, or if it calls another inherently unsafe function.

safeFunctionWhitelist

A whitelist of functions that should be considered side-effect free.

safeToCall

Find functions that are “safe to call” without causing a side effect. Being safe to call means that any “pointer type” in an argument type actually refers to a “const” object, and, moreover, the function is not inherently unsafe.

Classes

BooleanExpression

A “Boolean expression” is an expression forbidden from having side effects by this rule.