svf-lib 1.0.2418 → 1.0.2420

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,7 +45,8 @@ typedef WTOComponent<ICFG> ICFGWTOComp;
45
45
  typedef WTONode<ICFG> ICFGSingletonWTO;
46
46
  typedef WTOCycle<ICFG> ICFGCycleWTO;
47
47
 
48
- // Added for IWTO
48
+ /// Interprocedural Weak Topological Order
49
+ /// Each IWTO has an entry ICFGNode within an function-level SCC boundary. Here scc is one or more functions.
49
50
  class ICFGWTO : public WTO<ICFG>
50
51
  {
51
52
  public:
@@ -53,10 +54,11 @@ public:
53
54
  typedef WTOComponentVisitor<ICFG>::WTONodeT ICFGWTONode;
54
55
  Set<const FunObjVar*> scc;
55
56
 
56
- explicit ICFGWTO(ICFG* graph,const ICFGNode* node, Set<const FunObjVar*> funcScc = {}) :
57
- Base(graph, node), scc(funcScc)
57
+ // 1st argument is the SCC's entry ICFGNode and 2nd argument is the function(s) in this SCC.
58
+ explicit ICFGWTO(const ICFGNode* node, Set<const FunObjVar*> funcScc = {}) :
59
+ Base(node), scc(funcScc)
58
60
  {
59
- if (scc.empty()) // if empty funcScc, default use the function of the node
61
+ if (scc.empty()) // if funcScc is empty, the scc is the function itself
60
62
  scc.insert(node->getFun());
61
63
  }
62
64
 
@@ -554,13 +554,12 @@ protected:
554
554
  NodeRefToCycleDepthNumber _nodeToCDN;
555
555
  CycleDepthNumber _num;
556
556
  Stack _stack;
557
- GraphT* _graph;
558
557
  const NodeT* _entry;
559
558
 
560
559
  public:
561
560
 
562
561
  /// Compute the weak topological order of the given graph
563
- explicit WTO(GraphT* graph, const NodeT* entry) : _num(0), _graph(graph), _entry(entry)
562
+ explicit WTO(const NodeT* entry) : _num(0), _entry(entry)
564
563
  {
565
564
  }
566
565
 
Binary file
Binary file
Binary file
Binary file
@@ -45,75 +45,43 @@ typedef WTOComponent<ICFG> ICFGWTOComp;
45
45
  typedef WTONode<ICFG> ICFGSingletonWTO;
46
46
  typedef WTOCycle<ICFG> ICFGCycleWTO;
47
47
 
48
+ // Added for IWTO
48
49
  class ICFGWTO : public WTO<ICFG>
49
50
  {
50
51
  public:
51
52
  typedef WTO<ICFG> Base;
52
53
  typedef WTOComponentVisitor<ICFG>::WTONodeT ICFGWTONode;
54
+ Set<const FunObjVar*> scc;
53
55
 
54
- explicit ICFGWTO(ICFG* graph, const ICFGNode* node) : Base(graph, node) {}
55
-
56
- virtual ~ICFGWTO()
56
+ explicit ICFGWTO(ICFG* graph,const ICFGNode* node, Set<const FunObjVar*> funcScc = {}) :
57
+ Base(graph, node), scc(funcScc)
57
58
  {
59
+ if (scc.empty()) // if empty funcScc, default use the function of the node
60
+ scc.insert(node->getFun());
58
61
  }
59
62
 
60
- inline void forEachSuccessor(
61
- const ICFGNode* node,
62
- std::function<void(const ICFGNode*)> func) const override
63
+ virtual ~ICFGWTO()
63
64
  {
64
- if (const auto* callNode = SVFUtil::dyn_cast<CallICFGNode>(node))
65
- {
66
- const ICFGNode* succ = callNode->getRetICFGNode();
67
- func(succ);
68
- }
69
- else
70
- {
71
- for (const auto& e : node->getOutEdges())
72
- {
73
- if (!e->isIntraCFGEdge() ||
74
- node->getFun() != e->getDstNode()->getFun())
75
- continue;
76
- func(e->getDstNode());
77
- }
78
- }
79
65
  }
80
- };
81
-
82
- // Added for IWTO
83
- class ICFGIWTO : public ICFGWTO
84
- {
85
- public:
86
- typedef ICFGWTO Base;
87
- typedef WTOComponentVisitor<ICFG>::WTONodeT ICFGWTONode;
88
- NodeBS &funcPar;
89
- CallGraph *cg;
90
-
91
- explicit ICFGIWTO(ICFG* graph, const ICFGNode* node, NodeBS & funcPar, CallGraph* cg) :
92
- Base(graph, node), funcPar(funcPar), cg(cg) {}
93
66
 
94
- virtual ~ICFGIWTO()
67
+ inline virtual std::vector<const ICFGNode*> getSuccessors(const ICFGNode* node) override
95
68
  {
96
- }
69
+ std::vector<const ICFGNode*> successors;
97
70
 
98
- inline void forEachSuccessor(
99
- const ICFGNode* node,
100
- std::function<void(const ICFGNode*)> func) const override
101
- {
102
71
  if (const auto* callNode = SVFUtil::dyn_cast<CallICFGNode>(node))
103
72
  {
104
73
 
105
74
  for (const auto &e : callNode->getOutEdges())
106
75
  {
107
76
  ICFGNode *calleeEntryICFGNode = e->getDstNode();
108
- CallGraphNode * calleeCGNode = cg->getCallGraphNode(calleeEntryICFGNode->getFun());
77
+ const ICFGNode *succ = nullptr;
109
78
 
110
- const ICFGNode* succ = nullptr;
111
- if (funcPar.test(calleeCGNode->getId()))
79
+ if (scc.find(calleeEntryICFGNode->getFun()) != scc.end()) // caller & callee in the same SCC
112
80
  succ = calleeEntryICFGNode;
113
81
  else
114
- succ = callNode->getRetICFGNode();
82
+ succ = callNode->getRetICFGNode(); // caller & callee in different SCC
115
83
 
116
- func(succ);
84
+ successors.push_back(succ);
117
85
  }
118
86
  }
119
87
  else
@@ -121,12 +89,13 @@ public:
121
89
  for (const auto& e : node->getOutEdges())
122
90
  {
123
91
  ICFGNode *succ = e->getDstNode();
124
- CallGraphNode *succCGNode = cg->getCallGraphNode(succ->getFun());
125
- if (!funcPar.test(succCGNode->getId()))
92
+ if (scc.find(succ->getFun()) == scc.end()) // if not in the same SCC, skip
126
93
  continue;
127
- func(succ);
94
+ successors.push_back(succ);
128
95
  }
129
96
  }
97
+
98
+ return successors;
130
99
  }
131
100
  };
132
101
 
@@ -720,13 +720,15 @@ protected:
720
720
  }; // end class WTOCycleDepthBuilder
721
721
 
722
722
  protected:
723
-
724
- inline virtual void forEachSuccessor(const NodeT* node, std::function<void(const NodeT*)> func) const
723
+ /// Return the successors of node
724
+ inline virtual std::vector<const NodeT *> getSuccessors(const NodeT* node)
725
725
  {
726
+ std::vector<const NodeT *> succssors;
726
727
  for (const auto& e : node->getOutEdges())
727
728
  {
728
- func(e->getDstNode());
729
+ succssors.push_back(e->getDstNode());
729
730
  }
731
+ return succssors;
730
732
  }
731
733
 
732
734
  protected:
@@ -788,13 +790,14 @@ protected:
788
790
  virtual const WTOCycleT* component(const NodeT* node)
789
791
  {
790
792
  WTOComponentRefList partition;
791
- forEachSuccessor(node, [&](const NodeT* succ)
793
+
794
+ for (auto succ: getSuccessors(node))
792
795
  {
793
796
  if (getCDN(succ) == 0)
794
797
  {
795
798
  visit(succ, partition);
796
799
  }
797
- });
800
+ }
798
801
  const WTONodeT* head = newNode(node);
799
802
  const WTOCycleT* ptr = newCycle(head, partition);
800
803
  headRefToCycle.emplace(node, ptr);
@@ -816,7 +819,8 @@ protected:
816
819
  head = _num;
817
820
  setCDN(node, head);
818
821
  loop = false;
819
- forEachSuccessor(node, [&](const NodeT* succ)
822
+
823
+ for (auto succ: getSuccessors(node))
820
824
  {
821
825
  CycleDepthNumber succ_dfn = getCDN(succ);
822
826
  if (succ_dfn == CycleDepthNumber(0))
@@ -832,7 +836,7 @@ protected:
832
836
  head = min;
833
837
  loop = true;
834
838
  }
835
- });
839
+ }
836
840
 
837
841
  if (head == getCDN(node))
838
842
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.2418",
3
+ "version": "1.0.2420",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {