1 #include <featureTests.h>
2 #ifdef ROSE_ENABLE_SOURCE_ANALYSIS
7 #include "genericDataflowCommon.h"
23 extern std::map<SgFunctionDefinition*, std::set<varID> > allVars;
24 extern std::map<SgFunctionDefinition*, std::set<varID> > activeVars;
44 virtual std::string str()
const = 0;
46 virtual bool operator == (
const variable &that)
const = 0;
47 virtual bool operator < (
const variable &that)
const = 0;
56 virtual bool isGlobal()
const=0;
65 std::vector<SgInitializedName *> components;
67 std::map<std::string, void*> annotations;
74 varID(std::string name)
91 bool ret = init(name);
110 bool init(
const varID& that);
123 void operator = (
const variable &that);
127 bool collectDotComponents(
const SgDotExp* dotExp);
139 SgExpression* toSgExpression_rec(std::vector<SgInitializedName *>::const_iterator rest)
const;
143 static bool isValidVarExp(
const SgNode* exp);
155 bool addAnnotation(
const std::string& aName,
void* annot);
159 bool remAnnotation(
const std::string& aName);
163 bool remAllAnnotations();
170 bool swapAnnotations(
const std::string& fromAnnotName,
void* fromAnnotVal,
171 const std::string& toAnnotName,
void* toAnnotVal);
174 void* getAnnotation(
const std::string& aName)
const;
177 bool hasAnnotation(
const std::string& aName)
const;
180 bool hasAnyAnnotation(
const std::set<std::string>& aNames)
const;
183 bool hasAllAnnotations(
const std::set<std::string>& aNames)
const;
186 int numAnnotations()
const;
189 const std::map<std::string, void*>& getAnnotations()
const;
196 bool equal(
const varID& two)
const;
197 bool lessThan(
const varID& two)
const;
199 bool operator == (
const variable &that)
const;
200 bool operator != (
const varID &that)
const;
201 bool operator < (
const variable &that)
const;
202 bool operator > (
const varID &that)
const;
203 bool operator <= (
const varID &that)
const;
204 bool operator >= (
const varID &that)
const;
213 std::string str()
const;
214 std::string str(
bool noAnnot)
const;
219 std::string str_linenum()
const;
224 std::string str_ptr()
const;
231 bool isArrayType()
const;
234 bool isCompilerGenerated()
const;
237 bool isGlobal()
const;
247 static long globalMaxID;
258 std::ostream &operator<<(std::ostream &stream,
varID v);
259 std::ostream &operator<<(std::ostream &stream,
const std::set<varID>::iterator& v);
279 typedef std::set<varID, std::less<varID> > varIDSet;
280 typedef std::map<varID, varIDSet *> m_varID2setPtr;
281 typedef std::map<varID, quad> m_varID2quad;
282 typedef std::map<varID, std::string> m_varID2str;
283 typedef std::map<varID, bool> m_varID2bool;
284 typedef std::pair<varID, varID> varIDpair;
285 typedef std::list<varID> varIDlist;
286 typedef std::map<varID, m_varID2quad> m_varID2varID2quad;
289 typedef std::set<quad, std::less<quad> > setQuad;
290 typedef std::map<quad, setQuad *> m_quad2setPtr;
309 void addPredefinedVars(varIDSet &vars);
312 bool existsVariable(
varID x, m_varID2str &vars2Name );
315 bool existsVariable(
SgVarRefExp *x, m_varID2str &vars2Name );
318 bool isTypeConsidered(
SgNode * exp);
336 varIDSet getVarRefsInSubtree(
SgNode* root);
340 varIDSet getReadVarRefsInSubtree(
SgNode* root);
344 varIDSet getWriteVarRefsInSubtree(
SgNode* root);
348 varIDSet getArrayVarRefsInSubtree(
SgNode* root);
354 std::list<SgExpression*>* indexExprs;
361 std::string str()
const;
363 bool operator == (
const variable &that_arg)
const;
365 bool operator < (
const variable &that)
const;
375 const varID& getArrayVar();
378 std::list<SgExpression*>* getIndexExprs();
386 SgPntrArrRefExp* toSgExpression_rec(std::list<SgExpression*>::reverse_iterator itIndexes)
const;
390 bool isGlobal()
const;
395 std::set<arrayElt> getArrayRefsInSubtree(
SgNode* root);