ROSE 0.11.145.192
defsAndUsesTraversal.h
1#pragma once
2
3// DQ (10/5/2014): This is more strict now that we include rose_config.h in the sage3basic.h.
4// #include "rose.h"
5// rose.h and sage3basic.h should not be included in librose header files. [Robb P. Matzke 2014-10-15]
6// #include "sage3basic.h"
7
8#include "staticSingleAssignment.h"
9
10namespace ssa_private
11{
12
15 {
16 private:
18 SgVarRefExp* currentVar;
19
21 std::vector<SgNode*> uses;
22
23 public:
24
26 ChildUses() : currentVar(NULL)
27 {
28 }
29
30 ChildUses(SgNode* useNode, SgVarRefExp* var)
31 {
32 uses.push_back(useNode);
33 currentVar = var;
34 }
35
40 ChildUses(const std::vector<SgNode*>& useTree, SgVarRefExp* var = NULL)
41 {
42 if (useTree.size() > 0)
43 uses.assign(useTree.begin(), useTree.end());
44 currentVar = var;
45 }
46
51 std::vector<SgNode*>& getUses()
52 {
53 return uses;
54 }
55
60 void setUses(const std::vector<SgNode*>& newUses)
61 {
62 uses.assign(newUses.begin(), newUses.end());
63 }
64
65 SgVarRefExp* getCurrentVar() const
66 {
67 return currentVar;
68 }
69 };
70
75 {
77
80 const bool treatPointersAsStructs;
81
82 public:
83
86 DefsAndUsesTraversal(StaticSingleAssignment* ssa, bool treatPointersAsStructs = true) : ssa(ssa),
87 treatPointersAsStructs(treatPointersAsStructs)
88 {
89 }
90
99 virtual ChildUses evaluateSynthesizedAttribute(SgNode* node, SynthesizedAttributesList attrs);
100
101 private:
102
104 void addUsesToNode(SgNode* node, std::vector<SgNode*> uses);
105
107 void addDefForVarAtNode(SgVarRefExp* currentVar, SgNode* defNode);
108 };
109
110} //namespace ssa_private
111
Attribute Evaluator for synthesized attributes.
This class represents the base class for all IR nodes within Sage III.
This class represents the variable refernece in expressions.
Static single assignment analysis.
Attribute that describes the variables used by a given expression.
ChildUses()
Create the attribute with no refs.
std::vector< SgNode * > & getUses()
Get the uses for this node and below.
ChildUses(const std::vector< SgNode * > &useTree, SgVarRefExp *var=NULL)
Create the attribute with the def and list of uses.
void setUses(const std::vector< SgNode * > &newUses)
Set the uses for this node and below.
This class collects all the defs and uses associated with each node in the traversed CFG.
virtual ChildUses evaluateSynthesizedAttribute(SgNode *node, SynthesizedAttributesList attrs)
Called to evaluate the synthesized attribute on every node.
DefsAndUsesTraversal(StaticSingleAssignment *ssa, bool treatPointersAsStructs=true)