CodeSonar C++ API
[For improved navigation, enable JavaScript.]
Public Member Functions | Static Public Member Functions | Static Public Attributes | Related Functions | List of all members
cs::xform_expr_mode Class Reference

Enumeration class: the evaluation mode for an xform_expr. More...

Public Member Functions

csint64 as_integer () const
 Get an integer representation of this. More...
 
std::string as_repr () const
 Get a representation of a xform_expr_mode object that includes information useful for debugging. More...
 
std::string as_string () const
 Get a simple string representation of a xform_expr_mode object. More...
 
int cmp (const xform_expr_mode &other) const
 Comparison function for xform_expr_mode, with respect to a stable overall ordering. More...
 
cs_hash_t hash () const
 Hash function for xform_expr_mode. More...
 
std::string name () const
 Get the name of a xform_expr_mode object. More...
 

Static Public Member Functions

static xform_expr_mode from_integer (csint64 _inner)
 Construct an instance from an integer representation. More...
 

Static Public Attributes

static const xform_expr_mode POST
 The expression should be evaluated using values of variables at the end of the transformation. More...
 
static const xform_expr_mode POST_DEREFS_PRE
 The expression is evaluated as follows. More...
 
static const xform_expr_mode POST_DEREFS_PRE_STRICT
 The expression is evaluated as specified for xform_expr_mode::POST_DEREFS_PRE. More...
 
static const xform_expr_mode POST_STRICT
 The expression should be evaluated using values of variables at the end of the transformation. More...
 
static const xform_expr_mode PRE
 The expression should be evaluated using values of variables at the beginning of the transformation. More...
 

Related Functions

(Note that these are not member functions.)

bool operator!= (const xform_expr_mode &a, const xform_expr_mode &b)
 Inequality operator for xform_expr_mode. More...
 
bool operator< (const xform_expr_mode &a, const xform_expr_mode &b)
 Less-than operator for xform_expr_mode. More...
 
std::ostream & operator<< (std::ostream &out, const xform_expr_mode &a)
 Print a representation of a xform_expr_mode object to the specified stream. More...
 
bool operator<= (const xform_expr_mode &a, const xform_expr_mode &b)
 Less-than-or-equal operator for xform_expr_mode. More...
 
bool operator== (const xform_expr_mode &a, const xform_expr_mode &b)
 Equality operator for xform_expr_mode. More...
 
bool operator> (const xform_expr_mode &a, const xform_expr_mode &b)
 Greater-than operator for xform_expr_mode. More...
 
bool operator>= (const xform_expr_mode &a, const xform_expr_mode &b)
 Greater-than-or-equal operator for xform_expr_mode. More...
 

Detailed Description

Enumeration class: the evaluation mode for an xform_expr.

Note that constants a, b, and c cannot be modified by a tranformation, so the value of an xform_expr representing an expression of the form (ax+b)/c can only change if x changes. There are two possible cases:

Example:

int *p;
void f(){
if( *p == 1 ){
int i = 2;
int j = 3;
j = 4;
*p = 5;
*p = 6;
p = &i;
p = &j;
return;
}
}

If you were to query the value of *p using the step_xform covering the path from the start of the function to the return statement in these various modes, the results would be as follows.

Member Function Documentation

◆ as_integer()

csint64 cs::xform_expr_mode::as_integer ( ) const
inline

Get an integer representation of this.

Returns
An integer suitable for use with from_integer(). Invariant: For xform_expr_mode x, xform_expr_mode.from_integer(x.as_integer()) == x

◆ as_repr()

std::string cs::xform_expr_mode::as_repr ( ) const
inline

Get a representation of a xform_expr_mode object that includes information useful for debugging.

Returns
The string representation.

◆ as_string()

std::string cs::xform_expr_mode::as_string ( ) const
inline

Get a simple string representation of a xform_expr_mode object.

Returns
The string representation.

◆ cmp()

int cs::xform_expr_mode::cmp ( const xform_expr_mode other) const
inline

Comparison function for xform_expr_mode, with respect to a stable overall ordering.

Parameters
otherThe xform_expr_mode object to compare against.
Returns
An integer N such that:
  • N==0 if the two objects compare equal
  • N<0 if this < other
  • N>0 if this > other

◆ from_integer()

static xform_expr_mode cs::xform_expr_mode::from_integer ( csint64  _inner)
inlinestatic

Construct an instance from an integer representation.

Parameters
[in]_innerThe integer representation, as returned by as_integer(). Invariant: For xform_expr_mode x, xform_expr_mode.from_integer(x.as_integer()) == x
Exceptions
cs::result::ERROR_INVALID_ARGUMENTif _inner is not a valid integer representation for a xform_expr_mode instance.

◆ hash()

cs_hash_t cs::xform_expr_mode::hash ( ) const
inline

Hash function for xform_expr_mode.

◆ name()

std::string cs::xform_expr_mode::name ( ) const
inline

Get the name of a xform_expr_mode object.

Returns
The name.

Friends And Related Function Documentation

◆ operator!=()

bool operator!= ( const xform_expr_mode a,
const xform_expr_mode b 
)
related

Inequality operator for xform_expr_mode.

Parameters
[in]aThe xform_expr_mode object to compare.
[in]bThe xform_expr_mode object to compare against.
Returns
false if a and b are equal according to xform_expr_mode::cmp(), true otherwise.

◆ operator<()

bool operator< ( const xform_expr_mode a,
const xform_expr_mode b 
)
related

Less-than operator for xform_expr_mode.

Parameters
[in]aThe xform_expr_mode object to compare.
[in]bThe xform_expr_mode object to compare against.
Returns
true if a < b according to xform_expr_mode::cmp() , false otherwise.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  out,
const xform_expr_mode a 
)
related

Print a representation of a xform_expr_mode object to the specified stream.

Parameters
[in]outThe stream to print to.
[in]aThe xform_expr_mode object to print.
Returns
void

◆ operator<=()

bool operator<= ( const xform_expr_mode a,
const xform_expr_mode b 
)
related

Less-than-or-equal operator for xform_expr_mode.

Parameters
[in]aThe xform_expr_mode object to compare.
[in]bThe xform_expr_mode object to compare against.
Returns
true if a <= b according to xform_expr_mode::cmp() , false otherwise.

◆ operator==()

bool operator== ( const xform_expr_mode a,
const xform_expr_mode b 
)
related

Equality operator for xform_expr_mode.

Parameters
[in]aThe xform_expr_mode object to compare.
[in]bThe xform_expr_mode object to compare against.
Returns
true if a and b are equal according to xform_expr_mode::cmp(), false otherwise.

◆ operator>()

bool operator> ( const xform_expr_mode a,
const xform_expr_mode b 
)
related

Greater-than operator for xform_expr_mode.

Parameters
[in]aThe xform_expr_mode object to compare.
[in]bThe xform_expr_mode object to compare against.
Returns
true if a > b according to xform_expr_mode::cmp() , false otherwise.

◆ operator>=()

bool operator>= ( const xform_expr_mode a,
const xform_expr_mode b 
)
related

Greater-than-or-equal operator for xform_expr_mode.

Parameters
[in]aThe xform_expr_mode object to compare.
[in]bThe xform_expr_mode object to compare against.
Returns
true if a >= b according to xform_expr_mode::cmp() , false otherwise.

Member Data Documentation

◆ POST

const xform_expr_mode cs::xform_expr_mode::POST
static

The expression should be evaluated using values of variables at the end of the transformation.

If the value of the expression is not modified in the transformation, the evaluated expression will be the same as it would have been with xform_expr_mode::PRE.

◆ POST_DEREFS_PRE

const xform_expr_mode cs::xform_expr_mode::POST_DEREFS_PRE
static

The expression is evaluated as follows.

Let A be the memory location whose attribute x is used in the expression.

  • Address A is computed using the values of variables at the beginning of the transformation.
  • The expression is evaluated by taking the value of attribute x at address A at the end of the transformation.

If the value of the expression is not modified in the transformation, the evaluated expression will be the same as it would have been with xform_expr_mode::PRE.

◆ POST_DEREFS_PRE_STRICT

const xform_expr_mode cs::xform_expr_mode::POST_DEREFS_PRE_STRICT
static

The expression is evaluated as specified for xform_expr_mode::POST_DEREFS_PRE.

If the value of the expression is not modified in the transformation, the query fails (as distinct from xform_expr_mode::POST_DEREFS_PRE, where the query proceeds).

◆ POST_STRICT

const xform_expr_mode cs::xform_expr_mode::POST_STRICT
static

The expression should be evaluated using values of variables at the end of the transformation.

If the value of the expression is not modified in the transformation, the query fails (as distinct from xform_expr_mode::POST, where the query proceeds).

◆ PRE

const xform_expr_mode cs::xform_expr_mode::PRE
static

The expression should be evaluated using values of variables at the beginning of the transformation.

This can be useful for reasoning about constraints imposed on the original values later in the path (implied by 'if' statements for example).

(C API only: This is the recommended setting for constant-valued xform_expr (ax+b)/c with a==0.)


The documentation for this class was generated from the following file: