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

An access path describes a memory location as a sequence of steps from some base symbol, with each step represented by a access_path object. More...

Public Member Functions

std::string as_repr () const
 Get a representation of a access_path object that includes information useful for debugging. More...
 
std::string as_string () const
 Get a simple string representation of a access_path object. More...
 

Static Public Member Functions

static access_path addr ()
 Get a new access path element corresponding to the address (&) operator. More...
 
static access_path offset_in_bits (size_t off)
 Get a new access path element corresponding to the offset ([]) operator, with offset as specified. More...
 
static access_path star ()
 Get a new access path element corresponding to the star (*) operator. More...
 

Detailed Description

An access path describes a memory location as a sequence of steps from some base symbol, with each step represented by a access_path object.

For example, suppose we have the following declarations.

char *p;
char **pp;
char A[10];
float f;
struct mys {
int i;
double d;
};
struct mys s;
struct mys *sp;

We can describe various code artifacts in terms of base and access path as shown in the following table.

Code artifactbase symbolaccess path
f f []
p[4] p [ access_path.offset_in_bits(32), star() ]
&p p [ access_path.addr() ]
(*pp)[4] pp [ access_path.offset_in_bits(32), access_path.star(), access_path.star() ]
*(pp[4]) pp [ access_path.star(), access_path.offset_in_bits(128), access_path.star() ]
A[5] A [ access_path.offset_in_bits(40) ]
s.d s [ access_path.offset_in_bits(32) ]
ps->d ps [ access_path.offset_in_bits(32), access_path.star() ]

Where:

Note that the access operator access_path.addr() can only ever appear in a singleton access path. No other access paths containing the address operator correspond to legal expressions.

Member Function Documentation

◆ addr()

static access_path cs::access_path::addr ( )
inlinestatic

Get a new access path element corresponding to the address (&) operator.

Returns
The newly created access_path element.

◆ as_repr()

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

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

Returns
The string representation.

◆ as_string()

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

Get a simple string representation of a access_path object.

Returns
The string representation.

◆ offset_in_bits()

static access_path cs::access_path::offset_in_bits ( size_t  off)
inlinestatic

Get a new access path element corresponding to the offset ([]) operator, with offset as specified.

Parameters
[in]offThe offset, in bits.
Returns
The newly created access_path element.

◆ star()

static access_path cs::access_path::star ( )
inlinestatic

Get a new access path element corresponding to the star (*) operator.

Returns
The newly created access_path element.

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