47 enum EdgeConditionKind
56 eckForallIndicesInRange,
57 eckForallIndicesNotInRange,
58 eckComputedGotoCaseLabel,
61 eckArithmeticIfGreater,
87 std::string
id()
const;
106 bool operator<(
const CFGNode& o)
const {
return node < o.node || (node == o.node && index < o.index);}
125 std::string
id()
const;
148 bool operator<(
const CFGEdge& o)
const {
return src < o.src || (src == o.src && tgt < o.tgt);}
158 std::vector<CFGEdge> edges;
165 assert (!a.edges.empty());
166 assert (!b.edges.empty());
167 assert (a.edges.back().target() == b.edges.front().source());
168 edges.insert(edges.end(),b.edges.begin(),b.edges.end());
176 std::string toString()
const;
177 std::string toStringForDebugging()
const;
178 std::string id()
const;
180 CFGNode source()
const {assert (!edges.empty());
return edges.front().source();}
182 CFGNode target()
const {assert (!edges.empty());
return edges.back().target();}
184 EdgeConditionKind condition()
const {
185 for (
unsigned int i = 0; i < edges.size(); ++i) {
186 EdgeConditionKind kind = edges[i].condition();
187 if (kind != eckUnconditional)
return kind;
189 return eckUnconditional;
193 for (
unsigned int i = 0; i < edges.size(); ++i) {
195 if (label != NULL)
return label;
200 for (
unsigned int i = 0; i < edges.size(); ++i) {
202 if (base != NULL)
return base;
206 std::vector<SgInitializedName*> scopesBeingExited()
const {
207 std::vector<SgInitializedName*> result;
208 for (
unsigned int i = 0; i < edges.size(); ++i) {
209 std::vector<SgInitializedName*> s_i = edges[i].scopesBeingExited();
210 result.insert(result.end(), s_i.begin(), s_i.end());
214 std::vector<SgInitializedName*> scopesBeingEntered()
const {
215 std::vector<SgInitializedName*> result;
216 for (
unsigned int i = 0; i < edges.size(); ++i) {
217 std::vector<SgInitializedName*> s_i = edges[i].scopesBeingEntered();
218 result.insert(result.end(), s_i.begin(), s_i.end());
222 bool operator==(
const CFGPath& o)
const {
return edges == o.edges;}
223 bool operator!=(
const CFGPath& o)
const {
return edges != o.edges;}
227 if (edges.size() != o.edges.size()) {
228 return edges.size() < o.edges.size();
230 for (
unsigned int i = 0; i < edges.size(); ++i) {
231 if (edges[i] != o.edges[i]) {
232 return edges[i] < o.edges[i];
246 inline CFGPath mergePaths(
const CFGPath& hd,
const CFGPath& tl) {
248 return CFGPath(hd, tl);
252 inline CFGPath mergePathsReversed(
const CFGPath& tl,
const CFGPath& hd) {
253 return mergePaths(hd, tl);
258 inline CFGNode cfgBeginningOfConstruct(
SgNode* c) {
259 return CFGNode(c, 0);
264 unsigned int cfgIndexForEndWrapper(
SgNode* n);
269 inline CFGNode cfgEndOfConstruct(
SgNode* c) {
270 return CFGNode(c, cfgIndexForEndWrapper(c));
274 inline CFGNode makeCfg(
SgNode* start) {
275 return cfgBeginningOfConstruct(start);
279 class InterestingEdge;
286 std::string toString()
const {
return n.
toString();}
288 std::string id()
const {
return n.
id();}
290 const CFGNode& toNode()
const {
return n; }
291 unsigned int getIndex()
const {
return n.
getIndex();}
292 std::vector<InterestingEdge> outEdges()
const;
293 std::vector<InterestingEdge> inEdges()
const;
294 bool isInteresting()
const {
return true;}
296 bool operator!=(
const InterestingNode& o)
const {
return !(*
this == o);}
305 std::string toString()
const {
return p.toString();}
306 std::string toStringForDebugging()
const {
return p.toStringForDebugging();}
307 std::string id()
const {
return p.id();}
310 EdgeConditionKind condition()
const {
return p.condition();}
312 SgExpression* conditionBasedOn()
const {
return p.conditionBasedOn();}
313 std::vector<SgInitializedName*> scopesBeingExited()
const {
return p.scopesBeingExited();}
314 std::vector<SgInitializedName*> scopesBeingEntered()
const {
return p.scopesBeingEntered();}
326 CFGNode getCFGTargetOfFortranLabelSymbol(
SgLabelSymbol* sym);
331 template <
class Node1T,
class Node2T,
class EdgeT>
332 void makeEdge(Node1T from, Node2T to, std::vector<EdgeT>& result);
336#define SGFUNCTIONCALLEXP_INTERPROCEDURAL_INDEX 2
337#define SGCONSTRUCTORINITIALIZER_INTERPROCEDURAL_INDEX 1
338#define SGFUNCTIONDEFINITION_INTERPROCEDURAL_INDEX 2
340#define SGFUNCTIONCALLEXP_INTERPROCEDURAL_INDEX 2
341#define SGCONSTRUCTORINITIALIZER_INTERPROCEDURAL_INDEX 1
342#define SGFUNCTIONDEFINITION_INTERPROCEDURAL_INDEX 2
345template <
class NodeT1,
class NodeT2,
class EdgeT>
346void makeEdge(NodeT1 from, NodeT2 to, std::vector<EdgeT>& result);
This class represents the notion of an expression. Expressions are derived from SgLocatedNodes,...
This class represents the notion of a declared variable.
This class represents the base class for all IR nodes within Sage III.
This class represents the notion of a statement.
ROSE_DLL_API friend SgStatement * isSgStatement(SgNode *s)
Casts pointer from base class to derived class.
A control flow edge connecting two CFG nodes, with an edge condition to indicate edge types.
SgExpression * caseLabel() const
The label of the case represented by an eckCaseLabel edge.
SgExpression * conditionBasedOn() const
The test or case key that is tested as a condition of this control flow edge.
CFGEdge()
Default constructor. Used for compatibility with containers.
std::string toString() const
Pretty string for Dot node labels, etc.
std::string id() const
ID to use for Dot, etc.
CFGNode source() const
The source (beginning) CFG node.
std::vector< SgInitializedName * > scopesBeingEntered() const
Variables coming into scope across this edge (not extensively tested)
bool operator==(const CFGEdge &o) const
Compare equality of edges.
std::string toStringForDebugging() const
String for debugging graphs.
bool operator<(const CFGEdge &o) const
operator<() has an arbitrary ordering, but allows these objects to be used with std::set and std::map
EdgeConditionKind condition() const
The control flow condition that enables this edge.
unsigned int computedGotoCaseIndex() const
The expression of the computed goto represented by the eckArithmeticIf* conditions.
bool operator!=(const CFGEdge &o) const
Compare disequality of edges.
CFGEdge(CFGNode src, CFGNode tgt)
Constructor.
std::vector< SgInitializedName * > scopesBeingExited() const
Variables going out of scope across this edge (not extensively tested)
CFGNode target() const
The target (ending) CFG node.
A node in the control flow graph.
bool operator==(const CFGNode &o) const
Equality operator.
SgNode * getNode() const
The underlying AST node.
std::string toString() const
Pretty string for Dot node labels, etc.
bool operator<(const CFGNode &o) const
Less-than operator.
bool isInteresting() const
Test whether this node satisfies a (fairly arbitrary) standard for "interestingness".
std::vector< CFGEdge > inEdges() const
Incoming control flow edges to this node.
unsigned int getIndex() const
An identifying index within the AST node given by getNode()
std::vector< CFGEdge > outEdges() const
Outgoing control flow edges from this node.
std::string id() const
ID to use for Dot, etc.
std::string toStringForDebugging() const
String for debugging graphs.
bool operator!=(const CFGNode &o) const
Disequality operator.
const std::vector< CFGEdge > & getEdges() const
Returns the edges in the path, starting at the source and ending at the target.
bool operator<(const CFGPath &o) const
An arbitrary order, so we can use this in std::set and std::map.