svf-lib 1.0.1818 → 1.0.1820

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.
Files changed (117) hide show
  1. package/SVF-linux/Release-build/svf/libSvfCore.a +0 -0
  2. package/SVF-linux/svf/include/AbstractExecution/CFBasicBlockGWTO.h +83 -0
  3. package/SVF-linux/svf/include/AbstractExecution/ICFGWTO.h +78 -0
  4. package/SVF-linux/svf/include/DDA/DDAPass.h +2 -2
  5. package/SVF-linux/svf/include/DDA/DDAVFSolver.h +2 -2
  6. package/SVF-linux/svf/include/Graphs/SCC.h +354 -0
  7. package/SVF-linux/svf/include/Graphs/SVFGStat.h +1 -1
  8. package/SVF-linux/svf/include/Graphs/WTO.h +859 -0
  9. package/SVF-linux/svf/include/MSSA/MemRegion.h +3 -3
  10. package/SVF-linux/svf/include/MTA/TCT.h +2 -2
  11. package/SVF-linux/svf/include/MemoryModel/PointerAnalysis.h +5 -5
  12. package/SVF-linux/svf/include/WPA/CSC.h +3 -3
  13. package/SVF-osx/Release-build/svf/libSvfCore.a +0 -0
  14. package/SVF-osx/Release-build/svf-llvm/libSvfLLVM.a +0 -0
  15. package/SVF-osx/svf/include/AbstractExecution/BoundedZ3Expr.h +0 -2
  16. package/SVF-osx/svf/include/AbstractExecution/ConsExeState.h +0 -8
  17. package/SVF-osx/svf/include/AbstractExecution/ExeState.h +0 -8
  18. package/SVF-osx/svf/include/AbstractExecution/IntervalExeState.h +0 -7
  19. package/SVF-osx/svf/include/AbstractExecution/IntervalValue.h +0 -3
  20. package/SVF-osx/svf/include/AbstractExecution/NumericLiteral.h +0 -2
  21. package/SVF-osx/svf/include/AbstractExecution/RelExeState.h +0 -1
  22. package/SVF-osx/svf/include/AbstractExecution/RelationSolver.h +0 -1
  23. package/SVF-osx/svf/include/AbstractExecution/SVFIR2ConsExeState.h +0 -1
  24. package/SVF-osx/svf/include/AbstractExecution/SVFIR2ItvExeState.h +0 -4
  25. package/SVF-osx/svf/include/AbstractExecution/SingleAbsValue.h +0 -2
  26. package/SVF-osx/svf/include/AbstractExecution/SymState.h +0 -4
  27. package/SVF-osx/svf/include/AbstractExecution/WTO.h +0 -5
  28. package/SVF-osx/svf/include/CFL/CFGrammar.h +0 -4
  29. package/SVF-osx/svf/include/CFL/CFLAlias.h +0 -1
  30. package/SVF-osx/svf/include/CFL/CFLGraphBuilder.h +0 -1
  31. package/SVF-osx/svf/include/CFL/CFLStat.h +0 -1
  32. package/SVF-osx/svf/include/CFL/CFLVF.h +0 -1
  33. package/SVF-osx/svf/include/DDA/ContextDDA.h +0 -1
  34. package/SVF-osx/svf/include/DDA/DDAClient.h +0 -5
  35. package/SVF-osx/svf/include/DDA/DDAPass.h +0 -1
  36. package/SVF-osx/svf/include/FastCluster/fastcluster.h +0 -1
  37. package/SVF-osx/svf/include/Graphs/CDG.h +0 -3
  38. package/SVF-osx/svf/include/Graphs/CFBasicBlockG.h +0 -3
  39. package/SVF-osx/svf/include/Graphs/CFLGraph.h +0 -1
  40. package/SVF-osx/svf/include/Graphs/CHG.h +2 -4
  41. package/SVF-osx/svf/include/Graphs/ConsGEdge.h +0 -5
  42. package/SVF-osx/svf/include/Graphs/ConsGNode.h +0 -1
  43. package/SVF-osx/svf/include/Graphs/DOTGraphTraits.h +0 -1
  44. package/SVF-osx/svf/include/Graphs/GenericGraph.h +0 -1
  45. package/SVF-osx/svf/include/Graphs/GraphPrinter.h +0 -3
  46. package/SVF-osx/svf/include/Graphs/GraphTraits.h +2 -2
  47. package/SVF-osx/svf/include/Graphs/ICFG.h +0 -1
  48. package/SVF-osx/svf/include/Graphs/ICFGNode.h +0 -3
  49. package/SVF-osx/svf/include/Graphs/ICFGStat.h +0 -2
  50. package/SVF-osx/svf/include/Graphs/IRGraph.h +0 -1
  51. package/SVF-osx/svf/include/Graphs/PTACallGraph.h +0 -3
  52. package/SVF-osx/svf/include/Graphs/SVFG.h +0 -2
  53. package/SVF-osx/svf/include/Graphs/SVFGEdge.h +0 -1
  54. package/SVF-osx/svf/include/Graphs/SVFGNode.h +0 -7
  55. package/SVF-osx/svf/include/Graphs/SVFGOPT.h +0 -3
  56. package/SVF-osx/svf/include/Graphs/SVFGStat.h +0 -2
  57. package/SVF-osx/svf/include/Graphs/ThreadCallGraph.h +0 -3
  58. package/SVF-osx/svf/include/Graphs/VFG.h +0 -2
  59. package/SVF-osx/svf/include/Graphs/VFGEdge.h +0 -3
  60. package/SVF-osx/svf/include/Graphs/VFGNode.h +0 -8
  61. package/SVF-osx/svf/include/MSSA/MSSAMuChi.h +0 -4
  62. package/SVF-osx/svf/include/MSSA/MemPartition.h +0 -1
  63. package/SVF-osx/svf/include/MSSA/MemRegion.h +0 -1
  64. package/SVF-osx/svf/include/MSSA/MemSSA.h +0 -1
  65. package/SVF-osx/svf/include/MTA/FSMPTA.h +0 -6
  66. package/SVF-osx/svf/include/MTA/LockAnalysis.h +0 -5
  67. package/SVF-osx/svf/include/MTA/MHP.h +0 -3
  68. package/SVF-osx/svf/include/MTA/MTA.h +0 -1
  69. package/SVF-osx/svf/include/MTA/MTAResultValidator.h +0 -2
  70. package/SVF-osx/svf/include/MTA/TCT.h +0 -1
  71. package/SVF-osx/svf/include/MemoryModel/AbstractPointsToDS.h +0 -2
  72. package/SVF-osx/svf/include/MemoryModel/AccessPath.h +0 -5
  73. package/SVF-osx/svf/include/MemoryModel/ConditionalPT.h +0 -5
  74. package/SVF-osx/svf/include/MemoryModel/PersistentPointsToDS.h +0 -1
  75. package/SVF-osx/svf/include/MemoryModel/PointerAnalysis.h +0 -10
  76. package/SVF-osx/svf/include/MemoryModel/PointerAnalysisImpl.h +0 -1
  77. package/SVF-osx/svf/include/MemoryModel/PointsTo.h +0 -1
  78. package/SVF-osx/svf/include/SABER/DoubleFreeChecker.h +0 -1
  79. package/SVF-osx/svf/include/SABER/ProgSlice.h +0 -1
  80. package/SVF-osx/svf/include/SABER/SaberCondAllocator.h +0 -4
  81. package/SVF-osx/svf/include/SABER/SaberSVFGBuilder.h +0 -1
  82. package/SVF-osx/svf/include/SVFIR/SVFIR.h +0 -2
  83. package/SVF-osx/svf/include/SVFIR/SVFStatements.h +0 -2
  84. package/SVF-osx/svf/include/SVFIR/SVFType.h +0 -2
  85. package/SVF-osx/svf/include/SVFIR/SVFValue.h +0 -3
  86. package/SVF-osx/svf/include/SVFIR/SVFVariables.h +0 -5
  87. package/SVF-osx/svf/include/SVFIR/SymbolTableInfo.h +0 -5
  88. package/SVF-osx/svf/include/Util/CDGBuilder.h +0 -8
  89. package/SVF-osx/svf/include/Util/CallGraphBuilder.h +0 -2
  90. package/SVF-osx/svf/include/Util/Casting.h +1 -2
  91. package/SVF-osx/svf/include/Util/CommandLine.h +0 -1
  92. package/SVF-osx/svf/include/Util/CxtStmt.h +0 -4
  93. package/SVF-osx/svf/include/Util/DPItem.h +0 -2
  94. package/SVF-osx/svf/include/Util/NodeIDAllocator.h +2 -2
  95. package/SVF-osx/svf/include/Util/PTAStat.h +0 -1
  96. package/SVF-osx/svf/include/Util/SCC.h +0 -2
  97. package/SVF-osx/svf/include/Util/SVFBugReport.h +0 -1
  98. package/SVF-osx/svf/include/Util/SVFStat.h +3 -1
  99. package/SVF-osx/svf/include/Util/SVFUtil.h +0 -1
  100. package/SVF-osx/svf/include/Util/ThreadAPI.h +0 -1
  101. package/SVF-osx/svf/include/Util/WorkList.h +0 -1
  102. package/SVF-osx/svf/include/Util/Z3Expr.h +0 -4
  103. package/SVF-osx/svf/include/Util/iterator.h +2 -2
  104. package/SVF-osx/svf/include/WPA/Andersen.h +0 -6
  105. package/SVF-osx/svf/include/WPA/AndersenPWC.h +0 -3
  106. package/SVF-osx/svf/include/WPA/WPAFSSolver.h +0 -5
  107. package/SVF-osx/svf/include/WPA/WPAPass.h +0 -2
  108. package/SVF-osx/svf/include/WPA/WPASolver.h +0 -2
  109. package/SVF-osx/svf/include/WPA/WPAStat.h +0 -1
  110. package/SVF-osx/svf-llvm/include/SVF-LLVM/BreakConstantExpr.h +0 -1
  111. package/SVF-osx/svf-llvm/include/SVF-LLVM/DCHG.h +0 -1
  112. package/SVF-osx/svf-llvm/include/SVF-LLVM/GEPTypeBridgeIterator.h +0 -3
  113. package/SVF-osx/svf-llvm/include/SVF-LLVM/LLVMModule.h +0 -1
  114. package/SVF-osx/svf-llvm/include/SVF-LLVM/LLVMUtil.h +0 -1
  115. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +0 -1
  116. package/SVF-osx/svf-llvm/include/SVF-LLVM/SymbolTableBuilder.h +0 -1
  117. package/package.json +1 -1
@@ -0,0 +1,83 @@
1
+ //===- CFBasicBlockGWTO.h -- WTO for CFBasicBlockGraph----------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * CFBasicBlockGWTO.h
25
+ *
26
+ * The implementation is based on F. Bourdoncle's paper:
27
+ * "Efficient chaotic iteration strategies with widenings", Formal
28
+ * Methods in Programming and Their Applications, 1993, pages 128-141.
29
+ *
30
+ * Created on: Jan 22, 2024
31
+ * Author: Xiao Cheng
32
+ *
33
+ */
34
+ #ifndef SVF_CFBASICBLOCKGWTO_H
35
+ #define SVF_CFBASICBLOCKGWTO_H
36
+ #include "Graphs/CFBasicBlockG.h"
37
+ #include "Graphs/WTO.h"
38
+
39
+ namespace SVF
40
+ {
41
+ typedef WTOComponent<CFBasicBlockGraph> CFBasicBlockGWTOComp;
42
+ typedef WTONode<CFBasicBlockGraph> CFBasicBlockGWTONode;
43
+ typedef WTOCycle<CFBasicBlockGraph> CFBasicBlockGWTOCycle;
44
+
45
+ class CFBasicBlockGWTO : public WTO<CFBasicBlockGraph>
46
+ {
47
+ public:
48
+ typedef WTO<CFBasicBlockGraph> Base;
49
+ typedef WTOComponentVisitor<CFBasicBlockGraph>::WTONodeT
50
+ CFBasicBlockGWTONode;
51
+
52
+ explicit CFBasicBlockGWTO(CFBasicBlockGraph* graph,
53
+ const CFBasicBlockNode* node)
54
+ : Base(graph, node)
55
+ {
56
+ }
57
+
58
+ inline void forEachSuccessor(
59
+ const CFBasicBlockNode* node,
60
+ std::function<void(const CFBasicBlockNode*)> func) const override
61
+ {
62
+ if (const auto* callNode =
63
+ SVFUtil::dyn_cast<CallICFGNode>(node->getICFGNodes().front()))
64
+ {
65
+ const CFBasicBlockNode* succ = _graph->getCFBasicBlockNode(
66
+ callNode->getRetICFGNode()->getId());
67
+ func(succ);
68
+ }
69
+ else
70
+ {
71
+ for (const auto& e : node->getOutEdges())
72
+ {
73
+ if (e->getICFGEdge() &&
74
+ (!e->getICFGEdge()->isIntraCFGEdge() ||
75
+ node->getFunction() != e->getDstNode()->getFunction()))
76
+ continue;
77
+ func(e->getDstNode());
78
+ }
79
+ }
80
+ }
81
+ };
82
+ } // namespace SVF
83
+ #endif // SVF_CFBASICBLOCKGWTO_H
@@ -0,0 +1,78 @@
1
+ //===--------------- ICFGWTO.h -- WTO for ICFG----------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * ICFGWTO.h
25
+ *
26
+ * The implementation is based on F. Bourdoncle's paper:
27
+ * "Efficient chaotic iteration strategies with widenings", Formal
28
+ * Methods in Programming and Their Applications, 1993, pages 128-141.
29
+ *
30
+ * Created on: Jan 22, 2024
31
+ * Author: Xiao Cheng
32
+ *
33
+ */
34
+ #ifndef SVF_ICFGWTO_H
35
+ #define SVF_ICFGWTO_H
36
+
37
+ #include "Graphs/ICFG.h"
38
+ #include "Graphs/WTO.h"
39
+
40
+ namespace SVF
41
+ {
42
+
43
+ typedef WTOComponent<ICFG> ICFGWTOComp;
44
+ typedef WTONode<ICFG> ICFGWTONode;
45
+ typedef WTOCycle<ICFG> ICFGWTOCycle;
46
+
47
+ class ICFGWTO : public WTO<ICFG>
48
+ {
49
+ public:
50
+ typedef WTO<ICFG> Base;
51
+ typedef WTOComponentVisitor<ICFG>::WTONodeT ICFGWTONode;
52
+
53
+ explicit ICFGWTO(ICFG* graph, const ICFGNode* node) : Base(graph, node) {}
54
+
55
+ inline void forEachSuccessor(
56
+ const ICFGNode* node,
57
+ std::function<void(const ICFGNode*)> func) const override
58
+ {
59
+ if (const auto* callNode = SVFUtil::dyn_cast<CallICFGNode>(node))
60
+ {
61
+ const ICFGNode* succ = callNode->getRetICFGNode();
62
+ func(succ);
63
+ }
64
+ else
65
+ {
66
+ for (const auto& e : node->getOutEdges())
67
+ {
68
+ if (!e->isIntraCFGEdge() ||
69
+ node->getFun() != e->getDstNode()->getFun())
70
+ continue;
71
+ func(e->getDstNode());
72
+ }
73
+ }
74
+ }
75
+ };
76
+ } // namespace SVF
77
+
78
+ #endif // SVF_ICFGWTO_H
@@ -32,9 +32,9 @@
32
32
  #ifndef DDAPASS_H_
33
33
  #define DDAPASS_H_
34
34
 
35
- #include "MemoryModel/PointerAnalysisImpl.h"
36
35
  #include "DDA/DDAClient.h"
37
- #include "Util/SCC.h"
36
+ #include "Graphs/SCC.h"
37
+ #include "MemoryModel/PointerAnalysisImpl.h"
38
38
 
39
39
  namespace SVF
40
40
  {
@@ -31,10 +31,10 @@
31
31
  #define VALUEFLOWDDA_H_
32
32
 
33
33
  #include "DDA/DDAStat.h"
34
+ #include "Graphs/SCC.h"
34
35
  #include "MSSA/SVFGBuilder.h"
35
- #include "WPA/Andersen.h"
36
- #include "Util/SCC.h"
37
36
  #include "MemoryModel/PointsTo.h"
37
+ #include "WPA/Andersen.h"
38
38
  #include <algorithm>
39
39
 
40
40
  namespace SVF
@@ -0,0 +1,354 @@
1
+ //===- SCC.h -- SCC detection algorithm---------------------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2017> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU Affero General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU Affero General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU Affero General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * SCC.h
25
+ *
26
+ * Esko Nuutila and Eljas Soisalon-Soininen, "On finding the
27
+ * strongly connected components in a directed graph".
28
+ * Inf. Process. Letters, 49(1):9-14, 1994.
29
+ *
30
+ * The implementation is derived from the pseudo code in the following paper:
31
+ * Pereira and Berlin, "Wave Propagation and Deep Propagation for Pointer Analysis",
32
+ * CGO 2009, 126-135, 2009.
33
+ *
34
+ * And influenced by implementation from Open64 compiler
35
+ *
36
+ * Created on: Jul 12, 2013
37
+ * Author: yusui
38
+ */
39
+
40
+ #ifndef SCC_H_
41
+ #define SCC_H_
42
+
43
+ #include "SVFIR/SVFValue.h" // for NodeBS
44
+ #include <limits.h>
45
+ #include <stack>
46
+ #include <map>
47
+
48
+ namespace SVF
49
+ {
50
+
51
+ class GNodeSCCInfo;
52
+
53
+ template<class GraphType>
54
+ class SCCDetection
55
+ {
56
+
57
+ private:
58
+ ///Define the GTraits and node iterator for printing
59
+ typedef SVF::GenericGraphTraits<GraphType> GTraits;
60
+ typedef typename GTraits::NodeRef GNODE;
61
+ typedef typename GTraits::nodes_iterator node_iterator;
62
+ typedef typename GTraits::ChildIteratorType child_iterator;
63
+ typedef unsigned NodeID ;
64
+
65
+ public:
66
+ typedef std::stack<NodeID> GNodeStack;
67
+
68
+ class GNodeSCCInfo
69
+ {
70
+ public:
71
+ GNodeSCCInfo() : _visited(false), _inSCC(false), _rep(UINT_MAX) {}
72
+
73
+ inline bool visited(void) const
74
+ {
75
+ return _visited;
76
+ }
77
+ inline void visited(bool v)
78
+ {
79
+ _visited = v;
80
+ }
81
+ inline bool inSCC(void) const
82
+ {
83
+ return _inSCC;
84
+ }
85
+ inline void inSCC(bool v)
86
+ {
87
+ _inSCC = v;
88
+ }
89
+ inline NodeID rep(void)const
90
+ {
91
+ return _rep;
92
+ }
93
+ inline void rep(NodeID n)
94
+ {
95
+ _rep = n;
96
+ }
97
+ inline void addSubNodes(NodeID n)
98
+ {
99
+ _subNodes.set(n);
100
+ }
101
+ inline NodeBS& subNodes()
102
+ {
103
+ return _subNodes;
104
+ }
105
+ inline const NodeBS& subNodes() const
106
+ {
107
+ return _subNodes;
108
+ }
109
+ private:
110
+ bool _visited;
111
+ bool _inSCC;
112
+ NodeID _rep;
113
+ NodeBS _subNodes; /// nodes in the scc represented by this node
114
+ };
115
+
116
+ typedef Map<NodeID,GNodeSCCInfo > GNODESCCInfoMap;
117
+ typedef Map<NodeID, NodeID> NodeToNodeMap;
118
+
119
+ SCCDetection(const GraphType &GT)
120
+ : _graph(GT),
121
+ _I(0)
122
+ {}
123
+
124
+
125
+ // Return a handle to the stack of nodes in topological
126
+ // order. This will be used to seed the initial solution
127
+ // and improve efficiency.
128
+ inline GNodeStack &topoNodeStack()
129
+ {
130
+ return _T;
131
+ }
132
+
133
+ const inline GNODESCCInfoMap &GNodeSCCInfo() const
134
+ {
135
+ return _NodeSCCAuxInfo;
136
+ }
137
+
138
+ /// get the rep node if not found return itself
139
+ inline NodeID repNode(NodeID n) const
140
+ {
141
+ typename GNODESCCInfoMap::const_iterator it = _NodeSCCAuxInfo.find(n);
142
+ assert(it!=_NodeSCCAuxInfo.end() && "scc rep not found");
143
+ NodeID rep = it->second.rep();
144
+ return rep!= UINT_MAX ? rep : n ;
145
+ }
146
+
147
+
148
+ /// whether the node is in a cycle
149
+ inline bool isInCycle(NodeID n) const
150
+ {
151
+ NodeID rep = repNode(n);
152
+ // multi-node cycle
153
+ if (subNodes(rep).count() > 1)
154
+ {
155
+ return true;
156
+ }
157
+ // self-cycle
158
+ else
159
+ {
160
+ child_iterator EI = GTraits::direct_child_begin(Node(rep));
161
+ child_iterator EE = GTraits::direct_child_end(Node(rep));
162
+ for (; EI != EE; ++EI)
163
+ {
164
+ NodeID w = Node_Index(*EI);
165
+ if(w==rep)
166
+ return true;
167
+ }
168
+ return false;
169
+ }
170
+ }
171
+
172
+ /// get all subnodes in one scc, if size is empty insert itself into the set
173
+ inline const NodeBS& subNodes(NodeID n) const
174
+ {
175
+ typename GNODESCCInfoMap::const_iterator it = _NodeSCCAuxInfo.find(n);
176
+ assert(it!=_NodeSCCAuxInfo.end() && "scc rep not found");
177
+ return it->second.subNodes();
178
+ }
179
+
180
+ /// get all repNodeID
181
+ inline const NodeBS &getRepNodes() const
182
+ {
183
+ return repNodes;
184
+ }
185
+
186
+ const inline GraphType & graph()
187
+ {
188
+ return _graph;
189
+ }
190
+ private:
191
+
192
+ GNODESCCInfoMap _NodeSCCAuxInfo;
193
+
194
+ const GraphType & _graph;
195
+ NodeID _I;
196
+ NodeToNodeMap _D;
197
+ GNodeStack _SS;
198
+ GNodeStack _T;
199
+ NodeBS repNodes;
200
+
201
+ inline bool visited(NodeID n)
202
+ {
203
+ return _NodeSCCAuxInfo[n].visited();
204
+ }
205
+ inline bool inSCC(NodeID n)
206
+ {
207
+ return _NodeSCCAuxInfo[n].inSCC();
208
+ }
209
+
210
+ inline void setVisited(NodeID n,bool v)
211
+ {
212
+ _NodeSCCAuxInfo[n].visited(v);
213
+ }
214
+ inline void setInSCC(NodeID n,bool v)
215
+ {
216
+ _NodeSCCAuxInfo[n].inSCC(v);
217
+ }
218
+ inline void rep(NodeID n, NodeID r)
219
+ {
220
+ _NodeSCCAuxInfo[n].rep(r);
221
+ _NodeSCCAuxInfo[r].addSubNodes(n);
222
+ if (n != r)
223
+ {
224
+ _NodeSCCAuxInfo[n].subNodes().clear();
225
+ repNodes.reset(n);
226
+ repNodes.set(r);
227
+ }
228
+ }
229
+
230
+ inline NodeID rep(NodeID n)
231
+ {
232
+ return _NodeSCCAuxInfo[n].rep();
233
+ }
234
+ inline bool isInSCC(NodeID n)
235
+ {
236
+ return _NodeSCCAuxInfo[n].inSCC();
237
+ }
238
+
239
+ inline GNODE Node(NodeID id) const
240
+ {
241
+ return GTraits::getNode(_graph, id);
242
+ }
243
+
244
+ inline NodeID Node_Index(GNODE node) const
245
+ {
246
+ return GTraits::getNodeID(node);
247
+ }
248
+
249
+ void visit(NodeID v)
250
+ {
251
+ // SVFUtil::outs() << "visit GNODE: " << Node_Index(v)<< "\n";
252
+ _I += 1;
253
+ _D[v] = _I;
254
+ this->rep(v,v);
255
+ this->setVisited(v,true);
256
+
257
+ child_iterator EI = GTraits::direct_child_begin(Node(v));
258
+ child_iterator EE = GTraits::direct_child_end(Node(v));
259
+
260
+ for (; EI != EE; ++EI)
261
+ {
262
+ NodeID w = Node_Index(*EI);
263
+
264
+ if (!this->visited(w))
265
+ visit(w);
266
+ if (!this->inSCC(w))
267
+ {
268
+ NodeID rep;
269
+ rep = _D[this->rep(v)] < _D[this->rep(w)] ?
270
+ this->rep(v) : this->rep(w);
271
+ this->rep(v,rep);
272
+ }
273
+ }
274
+ if (this->rep(v) == v)
275
+ {
276
+ this->setInSCC(v,true);
277
+ while (!_SS.empty())
278
+ {
279
+ NodeID w = _SS.top();
280
+ if (_D[w] <= _D[v])
281
+ break;
282
+ else
283
+ {
284
+ _SS.pop();
285
+ this->setInSCC(w,true);
286
+ this->rep(w,v);
287
+ }
288
+ }
289
+ _T.push(v);
290
+ }
291
+ else
292
+ _SS.push(v);
293
+ }
294
+
295
+ void clear()
296
+ {
297
+ _NodeSCCAuxInfo.clear();
298
+ _I = 0;
299
+ _D.clear();
300
+ repNodes.clear();
301
+ while(!_SS.empty())
302
+ _SS.pop();
303
+ while(!_T.empty())
304
+ _T.pop();
305
+ }
306
+ public:
307
+
308
+ void find(void)
309
+ {
310
+ // Visit each unvisited root node. A root node is defined
311
+ // to be a node that has no incoming copy/skew edges
312
+ clear();
313
+ node_iterator I = GTraits::nodes_begin(_graph);
314
+ node_iterator E = GTraits::nodes_end(_graph);
315
+ for (; I != E; ++I)
316
+ {
317
+ NodeID node = Node_Index(*I);
318
+ if (!this->visited(node))
319
+ {
320
+ // We skip any nodes that have a representative other than
321
+ // themselves. Such nodes occur as a result of merging
322
+ // nodes either through unifying an ACC or other node
323
+ // merging optimizations. Any such node should have no
324
+ // outgoing edges and therefore should no longer be a member
325
+ // of an SCC.
326
+ if (this->rep(node) == UINT_MAX || this->rep(node) == node)
327
+ visit(node);
328
+ else
329
+ this->visited(node);
330
+ }
331
+ }
332
+ }
333
+
334
+ void find(NodeSet &candidates)
335
+ {
336
+ // This function is reloaded to only visit candidate NODES
337
+ clear();
338
+ for (NodeID node : candidates)
339
+ {
340
+ if (!this->visited(node))
341
+ {
342
+ if (this->rep(node) == UINT_MAX || this->rep(node) == node)
343
+ visit(node);
344
+ else
345
+ this->visited(node);
346
+ }
347
+ }
348
+ }
349
+
350
+ };
351
+
352
+ } // End namespace SVF
353
+
354
+ #endif /* SCC_H_ */
@@ -37,8 +37,8 @@
37
37
  #define SVFGSTAT_H_
38
38
 
39
39
  #include "Graphs/SVFG.h"
40
+ #include "SCC.h"
40
41
  #include "Util/PTAStat.h"
41
- #include "Util/SCC.h"
42
42
 
43
43
  namespace SVF
44
44
  {