Code Listener  [unstable] git snapshot
Data Structures | Namespaces | Typedefs | Functions
clutil.hh File Reference

some generic utilities working on top of code_listener/CodeStorage More...

#include "code_listener.h"
#include <cassert>
#include <set>
#include <stack>
#include <string>
#include <vector>

Go to the source code of this file.

Data Structures

struct  CltStackItem
 

Namespaces

 CodeStorage
 object model that describes the analyzed code on the input
 

Typedefs

typedef std::vector< int > TFieldIdxChain
 

Functions

bool operator== (const struct cl_type &cltA, const struct cl_type &cltB)
 compare given two pieces of static type-info semantically More...
 
bool operator!= (const struct cl_type &cltA, const struct cl_type &cltB)
 compare given two pieces of static type-info semantically More...
 
struct cl_typetargetTypeOfPtr (const struct cl_type *clt)
 return type of the target object that the pointer type can point to More...
 
struct cl_typetargetTypeOfArray (const struct cl_type *clt)
 return type of the target object that the array type can point to More...
 
bool isComposite (const struct cl_type *clt, bool includingArray=true)
 
bool isDataPtr (const struct cl_type *clt)
 
bool isCodePtr (const struct cl_type *clt)
 
bool isLcVar (const cl_operand &op)
 return true if the given operand is a local variable More...
 
bool seekRefAccessor (const struct cl_accessor *ac)
 return true if there is any CL_ACCESSOR_REF in the given chain of accessors More...
 
int intCstFromOperand (const struct cl_operand *op)
 return integral value from the integral constant given as operand More...
 
int varIdFromOperand (const struct cl_operand *op, const char **pName=0)
 return unique ID of the variable/register given as operand More...
 
bool fncNameFromCst (const char **pName, const struct cl_operand *op)
 get name of an external function given as CL_OPERAND_CST, true on success More...
 
bool fncUidFromOperand (int *pUid, const struct cl_operand *op)
 get uid of a function from the given operand if available, true on success More...
 
int offsetByIdxChain (const struct cl_type *, const TFieldIdxChain &)
 
template<class TVisitor >
bool traverseTypeIc (const struct cl_type *clt, TVisitor &visitor, bool digOnlyComposite=false)
 
std::string varToString (const CodeStorage::Storage &stor, const int uid, const struct cl_loc **pLoc=0)
 

Detailed Description

some generic utilities working on top of code_listener/CodeStorage

Definition in file clutil.hh.

Typedef Documentation

typedef std::vector<int > TFieldIdxChain

Definition at line 129 of file clutil.hh.

Function Documentation

bool fncNameFromCst ( const char **  pName,
const struct cl_operand op 
)

get name of an external function given as CL_OPERAND_CST, true on success

bool fncUidFromOperand ( int *  pUid,
const struct cl_operand op 
)

get uid of a function from the given operand if available, true on success

int intCstFromOperand ( const struct cl_operand op)

return integral value from the integral constant given as operand

bool isCodePtr ( const struct cl_type clt)
inline

Definition at line 82 of file clutil.hh.

References CL_TYPE_FNC, CL_TYPE_PTR, cl_type::code, and targetTypeOfPtr().

bool isComposite ( const struct cl_type clt,
bool  includingArray = true 
)
inline

Definition at line 55 of file clutil.hh.

References CL_TYPE_ARRAY, CL_TYPE_STRUCT, CL_TYPE_UNION, and cl_type::code.

Referenced by traverseTypeIc().

bool isDataPtr ( const struct cl_type clt)
inline

Definition at line 73 of file clutil.hh.

References CL_TYPE_FNC, CL_TYPE_PTR, cl_type::code, and targetTypeOfPtr().

bool isLcVar ( const cl_operand op)
inline

return true if the given operand is a local variable

Definition at line 92 of file clutil.hh.

References CL_OPERAND_VAR, CL_SCOPE_GLOBAL, CL_SCOPE_STATIC, cl_type::code, cl_operand::code, and cl_operand::scope.

int offsetByIdxChain ( const struct cl_type ,
const TFieldIdxChain  
)
bool operator!= ( const struct cl_type cltA,
const struct cl_type cltB 
)
inline

compare given two pieces of static type-info semantically

Definition at line 44 of file clutil.hh.

bool operator== ( const struct cl_type cltA,
const struct cl_type cltB 
)

compare given two pieces of static type-info semantically

bool seekRefAccessor ( const struct cl_accessor ac)

return true if there is any CL_ACCESSOR_REF in the given chain of accessors

Note
CL_ACCESSOR_REF accessors can't be chained with each other, as it makes semantically no sense
struct cl_type* targetTypeOfArray ( const struct cl_type clt)

return type of the target object that the array type can point to

struct cl_type* targetTypeOfPtr ( const struct cl_type clt)

return type of the target object that the pointer type can point to

Referenced by isCodePtr(), and isDataPtr().

bool traverseTypeIc ( const struct cl_type clt,
TVisitor &  visitor,
bool  digOnlyComposite = false 
)
int varIdFromOperand ( const struct cl_operand op,
const char **  pName = 0 
)

return unique ID of the variable/register given as operand

std::string varToString ( const CodeStorage::Storage stor,
const int  uid,
const struct cl_loc **  pLoc = 0 
)