ROSE  0.9.9.109
dataflowCfgFilter.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 namespace ssa_private
9 {
10 
15  {
16 
22  bool operator() (CFGNode cfgn) const
23  {
24  SgNode *node = cfgn.getNode();
25 
26  switch (node->variantT())
27  {
28  //For function calls, we only keep the last node. The function is actually called after all its parameters
29  //are evaluated.
30  case V_SgFunctionCallExp:
31  return (cfgn == node->cfgForEnd());
32 
33  //For basic blocks and other "container" nodes, keep the node that appears before the contents are executed
34  case V_SgBasicBlock:
35  case V_SgExprStatement:
36  case V_SgCommaOpExp:
37  return (cfgn == node->cfgForBeginning());
38 
39  //Keep the last index for initialized names. This way the def of the variable doesn't propagate to its assign
40  //initializer.
41  case V_SgInitializedName:
42  return (cfgn == node->cfgForEnd());
43 
44  case V_SgTryStmt:
45  return (cfgn == node->cfgForBeginning());
46 
47  //We only want the middle appearance of the teritatry operator - after its conditional expression
48  //and before the true and false bodies. This makes it behave as an if statement for data flow
49  //purposes
50  case V_SgConditionalExp:
51  return (cfgn.getIndex() == 1);
52 
53  //Make these binary operators appear after their operands, because they are evaluated after their operands
54  case V_SgAndOp:
55  case V_SgOrOp:
56  return (cfgn == node->cfgForEnd());
57 
58  default:
59  return cfgn.isInteresting();
60  }
61  }
62  };
63 }
VirtualCFG::CFGNode cfgForEnd()
Returns the CFG node for just after this AST node.
Filter which determines which CFG nodes appear in the CFg used to propagate reaching definitions...
virtual VariantT variantT() const
returns new style SageIII enum values
This class represents the base class for all IR nodes within Sage III.
Definition: Cxx_Grammar.h:8322
VirtualCFG::CFGNode cfgForBeginning()
Returns the CFG node for just before this AST node.
bool operator()(CFGNode cfgn) const
Determines if the provided CFG node should be traversed during DefUse.