1 #include <featureTests.h>
2 #ifdef ROSE_ENABLE_SOURCE_ANALYSIS
4 #ifndef _VARIABLESTATETRANSFER_H
5 #define _VARIABLESTATETRANSFER_H
8 #include "latticeFull.h"
9 #include "liveDeadVarAnalysis.h"
13 template <
class LatticeType>
18 void updateModified(
bool latModified) { modified = latModified || modified; }
25 return sgn ? getLattice(SgExpr2Var(sgn)) : NULL;
27 LatticeType *getLattice(
varID var) {
28 return dynamic_cast<LatticeType *
>(prodLat->getVarLattice(var));
35 resLat = getLattice(sgn);
37 if(isSgCompoundAssignOp(sgn)) {
38 if(resLat==NULL && arg1Lat != NULL)
43 return (arg1Lat && arg2Lat && resLat);
46 bool getLattices(
const SgUnaryOp *sgn, LatticeType* &arg1Lat, LatticeType* &arg2Lat, LatticeType* &resLat) {
48 resLat = getLattice(sgn);
51 if(isSgMinusMinusOp(sgn) || isSgPlusPlusOp(sgn)) {
52 arg2Lat =
new LatticeType(1);
57 return (arg1Lat && arg2Lat && resLat);
67 const std::vector<Lattice*>& lattices = prodLat->getLattices();
68 for(std::vector<Lattice*>::const_iterator it = lattices.begin(); it!=lattices.end(); it++)
69 (dynamic_cast<LatticeType *>(*it))->
initialize();
74 LatticeType *lhsLat, *rhsLat, *resLat;
78 if(resLat) Dbg::dbg <<
"resLat=\n "<<resLat->str(
" ")<<
"\n";
79 if(lhsLat) Dbg::dbg <<
"lhsLat=\n "<<lhsLat->str(
" ")<<
"\n";
80 if(rhsLat) Dbg::dbg <<
"rhsLat=\n "<<rhsLat->str(
" ")<<
"\n";
85 { resLat->copy(rhsLat); modified =
true; }
87 { lhsLat->copy(rhsLat); modified =
true; }
92 LatticeType* asgnLat = getLattice(sgn->
get_operand());
93 LatticeType* resLat = getLattice(sgn);
96 if(asgnLat) Dbg::dbg <<
"asgnLat= "<<asgnLat->str(
" ")<<
"\n";
97 if(resLat) Dbg::dbg <<
"resLat= "<<resLat->str(
" ")<<
"\n";
101 if(resLat) { resLat->copy(asgnLat); modified =
true; }
109 LatticeType *res = getLattice(sgn);
111 if (inits.size() > 0) {
112 res->copy(getLattice(inits[0]));
114 for (
size_t i = 1; i < inits.size(); ++i)
115 res->meetUpdate(getLattice(inits[i]));
129 LatticeType* varLat = getLattice(initName);
132 LatticeType* initLat = getLattice(initName->get_initializer());
135 varLat->copy(initLat);
142 LatticeType *lhs, *rhs, *res;
146 res->meetUpdate(rhs);
152 LatticeType *lhs, *rhs, *res;
155 updateModified(lhs->meetUpdate(rhs));
165 LatticeType *lhsLat, *rhsLat, *resLat;
169 resLat->copy(rhsLat);
179 *resLat = getLattice(sgn);
183 resLat->copy(condLat);
184 resLat->meetUpdate(trueLat);
185 resLat->meetUpdate(falseLat);
198 LatticeType *res = getLattice(sgn);
SgExprListExp * get_initializers() const
Returns the rhs.
This class represents the notion of a binary operator. It is derived from a SgExpression because oper...
This class represents the notion of a unary operator. It is derived from a SgExpression because opera...
This class represents the rhs of a variable declaration which includes an optional assignment (e...
SgExpression * get_operand() const
Returns the rhs.
This class represents the notion of a declared variable.
This class represents the concept of a C trinary conditional expression (e.g. "test ...
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes, since similar to statement, expressions have a concrete location within the user's source code.
Apply an analysis A's transfer function at a particular AST node type.
SgExpression * get_true_exp() const
Access function for p_true_exp.
SgExpression * get_false_exp() const
Access function for p_false_exp.
ROSE_DLL_API void initialize()
Initialize diagnostics-related global variables.
SgExpression * get_rhs_operand() const
returns SgExpression pointer to the rhs operand associated with this binary operator.
SgExpression * get_conditional_exp() const
Access function for p_conditional_exp.
bool getLattices(const SgBinaryOp *sgn, LatticeType *&arg1Lat, LatticeType *&arg2Lat, LatticeType *&resLat)
create three lattices from a binary operation: lhs, rhs, and result lattices
SgExpression * get_lhs_operand() const
returns SgExpression pointer to the lhs operand associated with this binary operator.
This class represents the call of a class constructor to initialize a variable. For example "Foo foo;...
This class was part of CC++ support from a long time ago.
SgExpression * get_operand() const
returns SgExpression pointer to the operand associated with this unary operator.