svf-lib 1.0.2237 → 1.0.2239

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 (165) hide show
  1. package/SVF-linux-aarch64/Release-build/bin/ae +0 -0
  2. package/SVF-linux-aarch64/Release-build/bin/cfl +0 -0
  3. package/SVF-linux-aarch64/Release-build/bin/dvf +0 -0
  4. package/SVF-linux-aarch64/Release-build/bin/llvm2svf +0 -0
  5. package/SVF-linux-aarch64/Release-build/bin/mta +0 -0
  6. package/SVF-linux-aarch64/Release-build/bin/saber +0 -0
  7. package/SVF-linux-aarch64/Release-build/bin/svf-ex +0 -0
  8. package/SVF-linux-aarch64/Release-build/bin/wpa +0 -0
  9. package/SVF-linux-aarch64/Release-build/include/AE/Core/AbstractState.h +406 -0
  10. package/SVF-linux-aarch64/Release-build/include/AE/Core/AbstractValue.h +157 -0
  11. package/SVF-linux-aarch64/Release-build/include/AE/Core/AddressValue.h +232 -0
  12. package/SVF-linux-aarch64/Release-build/include/AE/Core/ICFGWTO.h +82 -0
  13. package/SVF-linux-aarch64/Release-build/include/AE/Core/IntervalValue.h +1055 -0
  14. package/SVF-linux-aarch64/Release-build/include/AE/Core/NumericValue.h +1292 -0
  15. package/SVF-linux-aarch64/Release-build/include/AE/Core/RelExeState.h +226 -0
  16. package/SVF-linux-aarch64/Release-build/include/AE/Core/RelationSolver.h +91 -0
  17. package/SVF-linux-aarch64/Release-build/include/AE/Svfexe/AEDetector.h +323 -0
  18. package/SVF-linux-aarch64/Release-build/include/AE/Svfexe/AbsExtAPI.h +140 -0
  19. package/SVF-linux-aarch64/Release-build/include/AE/Svfexe/AbstractInterpretation.h +350 -0
  20. package/SVF-linux-aarch64/Release-build/include/CFL/CFGNormalizer.h +84 -0
  21. package/SVF-linux-aarch64/Release-build/include/CFL/CFGrammar.h +468 -0
  22. package/SVF-linux-aarch64/Release-build/include/CFL/CFLAlias.h +168 -0
  23. package/SVF-linux-aarch64/Release-build/include/CFL/CFLBase.h +118 -0
  24. package/SVF-linux-aarch64/Release-build/include/CFL/CFLGramGraphChecker.h +74 -0
  25. package/SVF-linux-aarch64/Release-build/include/CFL/CFLGraphBuilder.h +166 -0
  26. package/SVF-linux-aarch64/Release-build/include/CFL/CFLSVFGBuilder.h +58 -0
  27. package/SVF-linux-aarch64/Release-build/include/CFL/CFLSolver.h +374 -0
  28. package/SVF-linux-aarch64/Release-build/include/CFL/CFLStat.h +67 -0
  29. package/SVF-linux-aarch64/Release-build/include/CFL/CFLVF.h +68 -0
  30. package/SVF-linux-aarch64/Release-build/include/CFL/GrammarBuilder.h +100 -0
  31. package/SVF-linux-aarch64/Release-build/include/CFL/grammar/PAGGrammar.txt +15 -0
  32. package/SVF-linux-aarch64/Release-build/include/CFL/grammar/PEGGrammar.txt +11 -0
  33. package/SVF-linux-aarch64/Release-build/include/CFL/grammar/VFGGrammar.txt +7 -0
  34. package/SVF-linux-aarch64/Release-build/include/DDA/ContextDDA.h +230 -0
  35. package/SVF-linux-aarch64/Release-build/include/DDA/DDAClient.h +163 -0
  36. package/SVF-linux-aarch64/Release-build/include/DDA/DDAPass.h +102 -0
  37. package/SVF-linux-aarch64/Release-build/include/DDA/DDAStat.h +121 -0
  38. package/SVF-linux-aarch64/Release-build/include/DDA/DDAVFSolver.h +794 -0
  39. package/SVF-linux-aarch64/Release-build/include/DDA/FlowDDA.h +178 -0
  40. package/SVF-linux-aarch64/Release-build/include/FastCluster/LICENSE.TXT +13 -0
  41. package/SVF-linux-aarch64/Release-build/include/FastCluster/fastcluster.h +80 -0
  42. package/SVF-linux-aarch64/Release-build/include/Graphs/BasicBlockG.h +318 -0
  43. package/SVF-linux-aarch64/Release-build/include/Graphs/CDG.h +482 -0
  44. package/SVF-linux-aarch64/Release-build/include/Graphs/CFLGraph.h +232 -0
  45. package/SVF-linux-aarch64/Release-build/include/Graphs/CHG.h +369 -0
  46. package/SVF-linux-aarch64/Release-build/include/Graphs/CallGraph.h +498 -0
  47. package/SVF-linux-aarch64/Release-build/include/Graphs/ConsG.h +402 -0
  48. package/SVF-linux-aarch64/Release-build/include/Graphs/ConsGEdge.h +355 -0
  49. package/SVF-linux-aarch64/Release-build/include/Graphs/ConsGNode.h +418 -0
  50. package/SVF-linux-aarch64/Release-build/include/Graphs/DOTGraphTraits.h +188 -0
  51. package/SVF-linux-aarch64/Release-build/include/Graphs/GenericGraph.h +628 -0
  52. package/SVF-linux-aarch64/Release-build/include/Graphs/GraphPrinter.h +111 -0
  53. package/SVF-linux-aarch64/Release-build/include/Graphs/GraphTraits.h +150 -0
  54. package/SVF-linux-aarch64/Release-build/include/Graphs/GraphWriter.h +380 -0
  55. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFG.h +331 -0
  56. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFGEdge.h +281 -0
  57. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFGNode.h +669 -0
  58. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFGStat.h +164 -0
  59. package/SVF-linux-aarch64/Release-build/include/Graphs/IRGraph.h +398 -0
  60. package/SVF-linux-aarch64/Release-build/include/Graphs/SCC.h +375 -0
  61. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFG.h +491 -0
  62. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGEdge.h +237 -0
  63. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGNode.h +501 -0
  64. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGOPT.h +363 -0
  65. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGStat.h +273 -0
  66. package/SVF-linux-aarch64/Release-build/include/Graphs/ThreadCallGraph.h +400 -0
  67. package/SVF-linux-aarch64/Release-build/include/Graphs/VFG.h +664 -0
  68. package/SVF-linux-aarch64/Release-build/include/Graphs/VFGEdge.h +295 -0
  69. package/SVF-linux-aarch64/Release-build/include/Graphs/VFGNode.h +1266 -0
  70. package/SVF-linux-aarch64/Release-build/include/Graphs/WTO.h +872 -0
  71. package/SVF-linux-aarch64/Release-build/include/MSSA/MSSAMuChi.h +722 -0
  72. package/SVF-linux-aarch64/Release-build/include/MSSA/MemPartition.h +169 -0
  73. package/SVF-linux-aarch64/Release-build/include/MSSA/MemRegion.h +489 -0
  74. package/SVF-linux-aarch64/Release-build/include/MSSA/MemSSA.h +452 -0
  75. package/SVF-linux-aarch64/Release-build/include/MSSA/SVFGBuilder.h +98 -0
  76. package/SVF-linux-aarch64/Release-build/include/MTA/LockAnalysis.h +533 -0
  77. package/SVF-linux-aarch64/Release-build/include/MTA/MHP.h +546 -0
  78. package/SVF-linux-aarch64/Release-build/include/MTA/MTA.h +98 -0
  79. package/SVF-linux-aarch64/Release-build/include/MTA/MTAStat.h +73 -0
  80. package/SVF-linux-aarch64/Release-build/include/MTA/TCT.h +620 -0
  81. package/SVF-linux-aarch64/Release-build/include/MemoryModel/AbstractPointsToDS.h +316 -0
  82. package/SVF-linux-aarch64/Release-build/include/MemoryModel/AccessPath.h +194 -0
  83. package/SVF-linux-aarch64/Release-build/include/MemoryModel/ConditionalPT.h +878 -0
  84. package/SVF-linux-aarch64/Release-build/include/MemoryModel/MutablePointsToDS.h +1025 -0
  85. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PersistentPointsToCache.h +463 -0
  86. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PersistentPointsToDS.h +955 -0
  87. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PointerAnalysis.h +429 -0
  88. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PointerAnalysisImpl.h +602 -0
  89. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PointsTo.h +255 -0
  90. package/SVF-linux-aarch64/Release-build/include/MemoryModel/SVFLoop.h +167 -0
  91. package/SVF-linux-aarch64/Release-build/include/SABER/DoubleFreeChecker.h +76 -0
  92. package/SVF-linux-aarch64/Release-build/include/SABER/FileChecker.h +80 -0
  93. package/SVF-linux-aarch64/Release-build/include/SABER/LeakChecker.h +122 -0
  94. package/SVF-linux-aarch64/Release-build/include/SABER/ProgSlice.h +327 -0
  95. package/SVF-linux-aarch64/Release-build/include/SABER/SaberCheckerAPI.h +151 -0
  96. package/SVF-linux-aarch64/Release-build/include/SABER/SaberCondAllocator.h +317 -0
  97. package/SVF-linux-aarch64/Release-build/include/SABER/SaberSVFGBuilder.h +114 -0
  98. package/SVF-linux-aarch64/Release-build/include/SABER/SrcSnkDDA.h +327 -0
  99. package/SVF-linux-aarch64/Release-build/include/SABER/SrcSnkSolver.h +186 -0
  100. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/BasicTypes.h +280 -0
  101. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/BreakConstantExpr.h +94 -0
  102. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/CHGBuilder.h +78 -0
  103. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/CppUtil.h +184 -0
  104. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/DCHG.h +477 -0
  105. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
  106. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/ICFGBuilder.h +160 -0
  107. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/LLVMLoopAnalysis.h +60 -0
  108. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/LLVMModule.h +594 -0
  109. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/LLVMUtil.h +438 -0
  110. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/ObjTypeInference.h +130 -0
  111. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFIRBuilder.h +520 -0
  112. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFLLVMValue.h +387 -0
  113. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFModule.h +186 -0
  114. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SymbolTableBuilder.h +132 -0
  115. package/SVF-linux-aarch64/Release-build/include/SVFIR/ObjTypeInfo.h +224 -0
  116. package/SVF-linux-aarch64/Release-build/include/SVFIR/PAGBuilderFromFile.h +80 -0
  117. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFIR.h +856 -0
  118. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFStatements.h +1328 -0
  119. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFType.h +578 -0
  120. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFValue.h +338 -0
  121. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFVariables.h +2204 -0
  122. package/SVF-linux-aarch64/Release-build/include/Util/Annotator.h +180 -0
  123. package/SVF-linux-aarch64/Release-build/include/Util/BitVector.h +55 -0
  124. package/SVF-linux-aarch64/Release-build/include/Util/CDGBuilder.h +107 -0
  125. package/SVF-linux-aarch64/Release-build/include/Util/CallGraphBuilder.h +62 -0
  126. package/SVF-linux-aarch64/Release-build/include/Util/Casting.h +426 -0
  127. package/SVF-linux-aarch64/Release-build/include/Util/CommandLine.h +530 -0
  128. package/SVF-linux-aarch64/Release-build/include/Util/CoreBitVector.h +214 -0
  129. package/SVF-linux-aarch64/Release-build/include/Util/CxtStmt.h +502 -0
  130. package/SVF-linux-aarch64/Release-build/include/Util/DPItem.h +618 -0
  131. package/SVF-linux-aarch64/Release-build/include/Util/ExtAPI.h +117 -0
  132. package/SVF-linux-aarch64/Release-build/include/Util/GeneralType.h +127 -0
  133. package/SVF-linux-aarch64/Release-build/include/Util/GraphReachSolver.h +186 -0
  134. package/SVF-linux-aarch64/Release-build/include/Util/NodeIDAllocator.h +203 -0
  135. package/SVF-linux-aarch64/Release-build/include/Util/Options.h +272 -0
  136. package/SVF-linux-aarch64/Release-build/include/Util/PTAStat.h +83 -0
  137. package/SVF-linux-aarch64/Release-build/include/Util/SVFBugReport.h +427 -0
  138. package/SVF-linux-aarch64/Release-build/include/Util/SVFLoopAndDomInfo.h +169 -0
  139. package/SVF-linux-aarch64/Release-build/include/Util/SVFStat.h +103 -0
  140. package/SVF-linux-aarch64/Release-build/include/Util/SVFUtil.h +478 -0
  141. package/SVF-linux-aarch64/Release-build/include/Util/SparseBitVector.h +1252 -0
  142. package/SVF-linux-aarch64/Release-build/include/Util/ThreadAPI.h +189 -0
  143. package/SVF-linux-aarch64/Release-build/include/Util/WorkList.h +317 -0
  144. package/SVF-linux-aarch64/Release-build/include/Util/Z3Expr.h +325 -0
  145. package/SVF-linux-aarch64/Release-build/include/Util/cJSON.h +300 -0
  146. package/SVF-linux-aarch64/Release-build/include/Util/config.h +26 -0
  147. package/SVF-linux-aarch64/Release-build/include/Util/iterator.h +407 -0
  148. package/SVF-linux-aarch64/Release-build/include/Util/iterator_range.h +76 -0
  149. package/SVF-linux-aarch64/Release-build/include/WPA/Andersen.h +435 -0
  150. package/SVF-linux-aarch64/Release-build/include/WPA/AndersenPWC.h +160 -0
  151. package/SVF-linux-aarch64/Release-build/include/WPA/CSC.h +95 -0
  152. package/SVF-linux-aarch64/Release-build/include/WPA/FlowSensitive.h +323 -0
  153. package/SVF-linux-aarch64/Release-build/include/WPA/Steensgaard.h +131 -0
  154. package/SVF-linux-aarch64/Release-build/include/WPA/TypeAnalysis.h +90 -0
  155. package/SVF-linux-aarch64/Release-build/include/WPA/VersionedFlowSensitive.h +295 -0
  156. package/SVF-linux-aarch64/Release-build/include/WPA/WPAFSSolver.h +246 -0
  157. package/SVF-linux-aarch64/Release-build/include/WPA/WPAPass.h +116 -0
  158. package/SVF-linux-aarch64/Release-build/include/WPA/WPASolver.h +205 -0
  159. package/SVF-linux-aarch64/Release-build/include/WPA/WPAStat.h +222 -0
  160. package/SVF-linux-aarch64/Release-build/lib/cmake/SVF/SVFConfig.cmake +58 -0
  161. package/SVF-linux-aarch64/Release-build/lib/cmake/SVF/SVFConfigVersion.cmake +43 -0
  162. package/SVF-linux-aarch64/Release-build/lib/extapi.bc +2449 -0
  163. package/SVF-linux-aarch64/Release-build/lib/libSvfCore.so +0 -0
  164. package/SVF-linux-aarch64/Release-build/lib/libSvfLLVM.so.16 +0 -0
  165. package/package.json +1 -1
@@ -0,0 +1,189 @@
1
+ //===- ThreadAPI.h -- API for threads-----------------------------------------//
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
+ * ThreadAPI.h
25
+ *
26
+ * Created on: Jan 21, 2014
27
+ * Author: Yulei Sui, dye
28
+ */
29
+
30
+ #ifndef THREADAPI_H_
31
+ #define THREADAPI_H_
32
+
33
+ #include "SVFIR/SVFValue.h"
34
+
35
+ namespace SVF
36
+ {
37
+
38
+ class SVFModule;
39
+ class ICFGNode;
40
+ class CallICFGNode;
41
+ class SVFVar;
42
+ class ValVar;
43
+ class ObjVar;
44
+ class FunObjVar;
45
+
46
+ /*
47
+ * ThreadAPI class contains interfaces for pthread programs
48
+ */
49
+ class ThreadAPI
50
+ {
51
+
52
+ public:
53
+ enum TD_TYPE
54
+ {
55
+ TD_DUMMY = 0, /// dummy type
56
+ TD_FORK, /// create a new thread
57
+ TD_JOIN, /// wait for a thread to join
58
+ TD_DETACH, /// detach a thread directly instead wait for it to join
59
+ TD_ACQUIRE, /// acquire a lock
60
+ TD_TRY_ACQUIRE, /// try to acquire a lock
61
+ TD_RELEASE, /// release a lock
62
+ TD_EXIT, /// exit/kill a thread
63
+ TD_CANCEL, /// cancel a thread by another
64
+ TD_COND_WAIT, /// wait a condition
65
+ TD_COND_SIGNAL, /// signal a condition
66
+ TD_COND_BROADCAST, /// broadcast a condition
67
+ TD_MUTEX_INI, /// initial a mutex variable
68
+ TD_MUTEX_DESTROY, /// initial a mutex variable
69
+ TD_CONDVAR_INI, /// initial a mutex variable
70
+ TD_CONDVAR_DESTROY, /// initial a mutex variable
71
+ TD_BAR_INIT, /// Barrier init
72
+ TD_BAR_WAIT, /// Barrier wait
73
+ HARE_PAR_FOR
74
+ };
75
+
76
+ typedef Map<std::string, TD_TYPE> TDAPIMap;
77
+
78
+ private:
79
+ /// API map, from a string to threadAPI type
80
+ TDAPIMap tdAPIMap;
81
+
82
+ /// Constructor
83
+ ThreadAPI ()
84
+ {
85
+ init();
86
+ }
87
+
88
+ /// Initialize the map
89
+ void init();
90
+
91
+ /// Static reference
92
+ static ThreadAPI* tdAPI;
93
+
94
+ /// Get the function type if it is a threadAPI function
95
+ TD_TYPE getType(const FunObjVar* F) const;
96
+
97
+ public:
98
+ /// Return a static reference
99
+ static ThreadAPI* getThreadAPI()
100
+ {
101
+ if(tdAPI == nullptr)
102
+ {
103
+ tdAPI = new ThreadAPI();
104
+ }
105
+ return tdAPI;
106
+ }
107
+
108
+ static void destroy()
109
+ {
110
+ if(tdAPI != nullptr)
111
+ {
112
+ delete tdAPI;
113
+ tdAPI = nullptr;
114
+ }
115
+ }
116
+
117
+ /// Return arguments/attributes of pthread_create / hare_parallel_for
118
+ //@{
119
+ /// Return the first argument of the call,
120
+ /// Note that, it is the pthread_t pointer
121
+ const ValVar* getForkedThread(const CallICFGNode *inst) const;
122
+ /// Return the third argument of the call,
123
+ /// Note that, it could be function type or a void* pointer
124
+ const ValVar* getForkedFun(const CallICFGNode *inst) const;
125
+
126
+ /// Return the forth argument of the call,
127
+ /// Note that, it is the sole argument of start routine ( a void* pointer )
128
+ const ValVar* getActualParmAtForkSite(const CallICFGNode *inst) const;
129
+
130
+ /// Return the formal parm of forked function (the first arg in pthread)
131
+ const SVFVar* getFormalParmOfForkedFun(const FunObjVar* F) const;
132
+ //@}
133
+
134
+
135
+
136
+ /// Return true if this call create a new thread
137
+ //@{
138
+ bool isTDFork(const CallICFGNode *inst) const;
139
+ //@}
140
+
141
+ /// Return true if this call wait for a worker thread
142
+ //@{
143
+ bool isTDJoin(const CallICFGNode *inst) const;
144
+ //@}
145
+
146
+ /// Return arguments/attributes of pthread_join
147
+ //@{
148
+ /// Return the first argument of the call,
149
+ /// Note that, it is the pthread_t pointer
150
+ const SVFVar* getJoinedThread(const CallICFGNode *inst) const;
151
+ /// Return the send argument of the call,
152
+ /// Note that, it is the pthread_t pointer
153
+ const SVFVar* getRetParmAtJoinedSite(const CallICFGNode *inst) const;
154
+ //@}
155
+
156
+
157
+ /// Return true if this call exits/terminate a thread
158
+ //@{
159
+ bool isTDExit(const CallICFGNode *inst) const;
160
+ //@}
161
+
162
+ /// Return true if this call acquire a lock
163
+ //@{
164
+ bool isTDAcquire(const CallICFGNode* inst) const;
165
+ //@}
166
+
167
+ /// Return true if this call release a lock
168
+ //@{
169
+ bool isTDRelease(const CallICFGNode *inst) const;
170
+ //@}
171
+
172
+ /// Return lock value
173
+ //@{
174
+ /// First argument of pthread_mutex_lock/pthread_mutex_unlock
175
+ const SVFVar* getLockVal(const ICFGNode *inst) const;
176
+ //@}
177
+
178
+ /// Return true if this call waits for a barrier
179
+ //@{
180
+ bool isTDBarWait(const CallICFGNode *inst) const;
181
+ //@}
182
+
183
+ void performAPIStat();
184
+ void statInit(Map<std::string, u32_t>& tdAPIStatMap);
185
+ };
186
+
187
+ } // End namespace SVF
188
+
189
+ #endif /* THREADAPI_H_ */
@@ -0,0 +1,317 @@
1
+ //===- WorkList.h -- Internal worklist used in SVF---------------------------//
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
+ * @file: WorkList.h
25
+ * @author: yesen
26
+ * @date: 06/12/2013
27
+ * @version: 1.0
28
+ *
29
+ * @section LICENSE
30
+ *
31
+ * @section DESCRIPTION
32
+ *
33
+ */
34
+
35
+
36
+ #ifndef WORKLIST_H_
37
+ #define WORKLIST_H_
38
+
39
+ #include "SVFIR/SVFValue.h"
40
+
41
+ #include <assert.h>
42
+ #include <cstdlib>
43
+ #include <vector>
44
+ #include <deque>
45
+ #include <set>
46
+
47
+ namespace SVF
48
+ {
49
+
50
+ /**
51
+ * Worklist with "first come first go" order.
52
+ * New nodes pushed at back and popped from front.
53
+ * Elements in the list are unique as they're recorded by Set.
54
+ */
55
+ template<class Data>
56
+ class List
57
+ {
58
+ class ListNode
59
+ {
60
+ public:
61
+ ListNode(const Data &d)
62
+ {
63
+ data = d;
64
+ next = nullptr;
65
+ }
66
+
67
+ ~ListNode() {}
68
+
69
+ Data data;
70
+ ListNode *next;
71
+ };
72
+
73
+ typedef Set<Data> DataSet;
74
+ typedef ListNode Node;
75
+
76
+ public:
77
+ List()
78
+ {
79
+ head = nullptr;
80
+ tail = nullptr;
81
+ }
82
+
83
+ ~List() {}
84
+
85
+ inline bool empty() const
86
+ {
87
+ return (head == nullptr);
88
+ }
89
+
90
+ inline bool find(const Data &data) const
91
+ {
92
+ return nodeSet.find(data) != nodeSet.end();
93
+ }
94
+
95
+ void push(const Data &data)
96
+ {
97
+ if (nodeSet.find(data) == nodeSet.end())
98
+ {
99
+ Node *new_node = new Node(data);
100
+ if (head == nullptr)
101
+ head = new_node;// the list is empty
102
+ else
103
+ tail->next = new_node;
104
+ tail = new_node;
105
+ }
106
+ }
107
+
108
+ Data pop()
109
+ {
110
+ assert(head != nullptr && "list is empty");
111
+ /// get node from list head
112
+ Node *head_node = head;
113
+
114
+ /// change list head to the next node
115
+ head = head->next;
116
+ if (head == nullptr)
117
+ tail = nullptr; /// the last node is popped.
118
+
119
+ Data data = head_node->data;
120
+ nodeSet.erase(data);
121
+ delete head_node;
122
+ return data;
123
+ }
124
+
125
+ private:
126
+ DataSet nodeSet;
127
+ Node *head;
128
+ Node *tail;
129
+ };
130
+
131
+ /**
132
+ * Worklist with "first in first out" order.
133
+ * New nodes will be pushed at back and popped from front.
134
+ * Elements in the list are unique as they're recorded by Set.
135
+ */
136
+ template<class Data>
137
+ class FIFOWorkList
138
+ {
139
+ typedef Set<Data> DataSet;
140
+ typedef std::deque<Data> DataDeque;
141
+ public:
142
+ FIFOWorkList() {}
143
+
144
+ ~FIFOWorkList() {}
145
+
146
+ inline bool empty() const
147
+ {
148
+ return data_list.empty();
149
+ }
150
+
151
+ inline u32_t size() const
152
+ {
153
+ assert(data_list.size() == data_set.size() && "list and set must be the same size!");
154
+ return data_list.size();
155
+ }
156
+
157
+ inline bool find(const Data &data) const
158
+ {
159
+ return data_set.find(data) != data_set.end();
160
+ }
161
+
162
+ /**
163
+ * Push a data into the work list.
164
+ */
165
+ inline bool push(const Data &data)
166
+ {
167
+ if (!find(data))
168
+ {
169
+ data_list.push_back(data);
170
+ data_set.insert(data);
171
+ return true;
172
+ }
173
+ else
174
+ return false;
175
+ }
176
+
177
+ /**
178
+ * Remove a data from the END of work list, no return value
179
+ */
180
+ inline void removeFront()
181
+ {
182
+ assert(!empty() && "work list is empty");
183
+ data_set.erase(front());
184
+ data_list.pop_front();
185
+ }
186
+
187
+ /**
188
+ * Get reference of top data from the END of work list.
189
+ */
190
+ inline Data &front()
191
+ {
192
+ assert(!empty() && "work list is empty");
193
+ Data &data = data_list.front();
194
+ return data;
195
+ }
196
+
197
+ /**
198
+ * Pop a data from the END of work list.
199
+ */
200
+ inline Data pop()
201
+ {
202
+ assert(!empty() && "work list is empty");
203
+ Data data = data_list.front();
204
+ data_list.pop_front();
205
+ data_set.erase(data);
206
+ return data;
207
+ }
208
+
209
+ /*!
210
+ * Clear all the data
211
+ */
212
+ inline void clear()
213
+ {
214
+ data_list.clear();
215
+ data_set.clear();
216
+ }
217
+
218
+ private:
219
+ DataSet data_set; ///< store all data in the work list.
220
+ DataDeque data_list; ///< work list using std::vector.
221
+ };
222
+
223
+ /**
224
+ * Worklist with "first in last out" order.
225
+ * New nodes will be pushed at back and popped from back.
226
+ * Elements in the list are unique as they're recorded by Set.
227
+ */
228
+ template<class Data>
229
+ class FILOWorkList
230
+ {
231
+ typedef Set<Data> DataSet;
232
+ typedef std::vector<Data> DataVector;
233
+ public:
234
+ FILOWorkList() {}
235
+
236
+ ~FILOWorkList() {}
237
+
238
+ inline bool empty() const
239
+ {
240
+ return data_list.empty();
241
+ }
242
+
243
+ inline u32_t size() const
244
+ {
245
+ assert(data_list.size() == data_set.size() && "list and set must be the same size!");
246
+ return data_list.size();
247
+ }
248
+
249
+ inline bool find(const Data &data) const
250
+ {
251
+ return data_set.find(data) != data_set.end();;
252
+ }
253
+
254
+ /**
255
+ * Push a data into the work list.
256
+ */
257
+ inline bool push(const Data &data)
258
+ {
259
+ if (!find(data))
260
+ {
261
+ data_list.push_back(data);
262
+ data_set.insert(data);
263
+ return true;
264
+ }
265
+ else
266
+ return false;
267
+ }
268
+
269
+ /**
270
+ * Pop a data from the END of work list.
271
+ */
272
+ inline Data pop()
273
+ {
274
+ assert(!empty() && "work list is empty");
275
+ Data data = data_list.back();
276
+ data_list.pop_back();
277
+ data_set.erase(data);
278
+ return data;
279
+ }
280
+
281
+ /**
282
+ * Remove a data from the END of work list, no return value
283
+ */
284
+ inline void removeBack()
285
+ {
286
+ assert(!empty() && "work list is empty");
287
+ data_set.erase(back());
288
+ data_list.pop_back();
289
+ }
290
+
291
+ /**
292
+ * Get reference of top data from the END of work list.
293
+ */
294
+ inline Data &back()
295
+ {
296
+ assert(!empty() && "work list is empty");
297
+ Data &data = data_list.back();
298
+ return data;
299
+ }
300
+
301
+ /*!
302
+ * Clear all the data
303
+ */
304
+ inline void clear()
305
+ {
306
+ data_list.clear();
307
+ data_set.clear();
308
+ }
309
+
310
+ private:
311
+ DataSet data_set; ///< store all data in the work list.
312
+ DataVector data_list; ///< work list using std::vector.
313
+ };
314
+
315
+ } // End namespace SVF
316
+
317
+ #endif /* WORKLIST_H_ */