svf-lib 1.0.1375 → 1.0.1376

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 (147) hide show
  1. package/SVF-osx/Release-build/svf-llvm/libSvfLLVM.a +0 -0
  2. package/SVF-osx/svf/include/include/AbstractExecution/AbstractValue.h +79 -0
  3. package/SVF-osx/svf/include/include/AbstractExecution/AddressValue.h +210 -0
  4. package/SVF-osx/svf/include/include/AbstractExecution/ExeState.h +223 -0
  5. package/SVF-osx/svf/include/include/AbstractExecution/IntervalExeState.h +425 -0
  6. package/SVF-osx/svf/include/include/AbstractExecution/IntervalValue.h +868 -0
  7. package/SVF-osx/svf/include/include/AbstractExecution/NumericLiteral.h +406 -0
  8. package/SVF-osx/svf/include/include/AbstractExecution/RelExeState.h +225 -0
  9. package/SVF-osx/svf/include/include/AbstractExecution/RelationSolver.h +68 -0
  10. package/SVF-osx/svf/include/include/AbstractExecution/SVFIR2ItvExeState.h +186 -0
  11. package/SVF-osx/svf/include/include/AbstractExecution/WTO.h +845 -0
  12. package/SVF-osx/svf/include/include/CFL/CFGNormalizer.h +84 -0
  13. package/SVF-osx/svf/include/include/CFL/CFLAlias.h +176 -0
  14. package/SVF-osx/svf/include/include/CFL/CFLBase.h +115 -0
  15. package/SVF-osx/svf/include/include/CFL/CFLData.h +316 -0
  16. package/SVF-osx/svf/include/include/CFL/CFLDataBuilder.h +91 -0
  17. package/SVF-osx/svf/include/include/CFL/CFLGramGraphChecker.h +74 -0
  18. package/SVF-osx/svf/include/include/CFL/CFLGrammar.h +468 -0
  19. package/SVF-osx/svf/include/include/CFL/CFLGrammar.txt +15 -0
  20. package/SVF-osx/svf/include/include/CFL/CFLGraphBuilder.h +193 -0
  21. package/SVF-osx/svf/include/include/CFL/CFLSolver.h +136 -0
  22. package/SVF-osx/svf/include/include/CFL/CFLStat.h +67 -0
  23. package/SVF-osx/svf/include/include/CFL/CFLVF.h +65 -0
  24. package/SVF-osx/svf/include/include/CFL/GrammarBuilder.h +100 -0
  25. package/SVF-osx/svf/include/include/CFL/PEGGrammar.txt +11 -0
  26. package/SVF-osx/svf/include/include/CFL/VFG.txt +7 -0
  27. package/SVF-osx/svf/include/include/DDA/ContextDDA.h +230 -0
  28. package/SVF-osx/svf/include/include/DDA/DDAClient.h +168 -0
  29. package/SVF-osx/svf/include/include/DDA/DDAPass.h +99 -0
  30. package/SVF-osx/svf/include/include/DDA/DDAStat.h +138 -0
  31. package/SVF-osx/svf/include/include/DDA/DDAVFSolver.h +789 -0
  32. package/SVF-osx/svf/include/include/DDA/FlowDDA.h +178 -0
  33. package/SVF-osx/svf/include/include/FastCluster/LICENSE.TXT +13 -0
  34. package/SVF-osx/svf/include/include/FastCluster/fastcluster.h +80 -0
  35. package/SVF-osx/svf/include/include/Graphs/CFLGraph.h +215 -0
  36. package/SVF-osx/svf/include/include/Graphs/CHG.h +351 -0
  37. package/SVF-osx/svf/include/include/Graphs/ConsG.h +408 -0
  38. package/SVF-osx/svf/include/include/Graphs/ConsGEdge.h +353 -0
  39. package/SVF-osx/svf/include/include/Graphs/ConsGNode.h +391 -0
  40. package/SVF-osx/svf/include/include/Graphs/DOTGraphTraits.h +188 -0
  41. package/SVF-osx/svf/include/include/Graphs/GenericGraph.h +620 -0
  42. package/SVF-osx/svf/include/include/Graphs/GraphPrinter.h +111 -0
  43. package/SVF-osx/svf/include/include/Graphs/GraphTraits.h +150 -0
  44. package/SVF-osx/svf/include/include/Graphs/GraphWriter.h +380 -0
  45. package/SVF-osx/svf/include/include/Graphs/ICFG.h +331 -0
  46. package/SVF-osx/svf/include/include/Graphs/ICFGEdge.h +264 -0
  47. package/SVF-osx/svf/include/include/Graphs/ICFGNode.h +523 -0
  48. package/SVF-osx/svf/include/include/Graphs/ICFGStat.h +164 -0
  49. package/SVF-osx/svf/include/include/Graphs/IRGraph.h +243 -0
  50. package/SVF-osx/svf/include/include/Graphs/PTACallGraph.h +471 -0
  51. package/SVF-osx/svf/include/include/Graphs/SVFG.h +490 -0
  52. package/SVF-osx/svf/include/include/Graphs/SVFGEdge.h +237 -0
  53. package/SVF-osx/svf/include/include/Graphs/SVFGNode.h +513 -0
  54. package/SVF-osx/svf/include/include/Graphs/SVFGOPT.h +362 -0
  55. package/SVF-osx/svf/include/include/Graphs/SVFGStat.h +273 -0
  56. package/SVF-osx/svf/include/include/Graphs/ThreadCallGraph.h +422 -0
  57. package/SVF-osx/svf/include/include/Graphs/VFG.h +664 -0
  58. package/SVF-osx/svf/include/include/Graphs/VFGEdge.h +295 -0
  59. package/SVF-osx/svf/include/include/Graphs/VFGNode.h +1197 -0
  60. package/SVF-osx/svf/include/include/MSSA/MSSAMuChi.h +722 -0
  61. package/SVF-osx/svf/include/include/MSSA/MemPartition.h +169 -0
  62. package/SVF-osx/svf/include/include/MSSA/MemRegion.h +491 -0
  63. package/SVF-osx/svf/include/include/MSSA/MemSSA.h +452 -0
  64. package/SVF-osx/svf/include/include/MSSA/SVFGBuilder.h +98 -0
  65. package/SVF-osx/svf/include/include/MTA/FSMPTA.h +270 -0
  66. package/SVF-osx/svf/include/include/MTA/LockAnalysis.h +517 -0
  67. package/SVF-osx/svf/include/include/MTA/MHP.h +565 -0
  68. package/SVF-osx/svf/include/include/MTA/MTA.h +101 -0
  69. package/SVF-osx/svf/include/include/MTA/MTAResultValidator.h +448 -0
  70. package/SVF-osx/svf/include/include/MTA/MTAStat.h +74 -0
  71. package/SVF-osx/svf/include/include/MTA/PCG.h +229 -0
  72. package/SVF-osx/svf/include/include/MTA/TCT.h +599 -0
  73. package/SVF-osx/svf/include/include/MemoryModel/AbstractPointsToDS.h +316 -0
  74. package/SVF-osx/svf/include/include/MemoryModel/ConditionalPT.h +878 -0
  75. package/SVF-osx/svf/include/include/MemoryModel/LocationSet.h +148 -0
  76. package/SVF-osx/svf/include/include/MemoryModel/MutablePointsToDS.h +1025 -0
  77. package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToCache.h +463 -0
  78. package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToDS.h +955 -0
  79. package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysis.h +452 -0
  80. package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysisImpl.h +590 -0
  81. package/SVF-osx/svf/include/include/MemoryModel/PointsTo.h +255 -0
  82. package/SVF-osx/svf/include/include/MemoryModel/SVFLoop.h +164 -0
  83. package/SVF-osx/svf/include/include/SABER/DoubleFreeChecker.h +76 -0
  84. package/SVF-osx/svf/include/include/SABER/FileChecker.h +82 -0
  85. package/SVF-osx/svf/include/include/SABER/LeakChecker.h +124 -0
  86. package/SVF-osx/svf/include/include/SABER/ProgSlice.h +313 -0
  87. package/SVF-osx/svf/include/include/SABER/SaberCheckerAPI.h +166 -0
  88. package/SVF-osx/svf/include/include/SABER/SaberCondAllocator.h +310 -0
  89. package/SVF-osx/svf/include/include/SABER/SaberSVFGBuilder.h +104 -0
  90. package/SVF-osx/svf/include/include/SABER/SrcSnkDDA.h +321 -0
  91. package/SVF-osx/svf/include/include/SABER/SrcSnkSolver.h +186 -0
  92. package/SVF-osx/svf/include/include/SVFIR/PAGBuilderFromFile.h +80 -0
  93. package/SVF-osx/svf/include/include/SVFIR/SVFIR.h +659 -0
  94. package/SVF-osx/svf/include/include/SVFIR/SVFModule.h +233 -0
  95. package/SVF-osx/svf/include/include/SVFIR/SVFStatements.h +1136 -0
  96. package/SVF-osx/svf/include/include/SVFIR/SVFType.h +527 -0
  97. package/SVF-osx/svf/include/include/SVFIR/SVFValue.h +1120 -0
  98. package/SVF-osx/svf/include/include/SVFIR/SVFVariables.h +721 -0
  99. package/SVF-osx/svf/include/include/SVFIR/SymbolTableInfo.h +597 -0
  100. package/SVF-osx/svf/include/include/Util/Annotator.h +180 -0
  101. package/SVF-osx/svf/include/include/Util/BitVector.h +55 -0
  102. package/SVF-osx/svf/include/include/Util/CallGraphBuilder.h +74 -0
  103. package/SVF-osx/svf/include/include/Util/Casting.h +426 -0
  104. package/SVF-osx/svf/include/include/Util/CommandLine.h +530 -0
  105. package/SVF-osx/svf/include/include/Util/CoreBitVector.h +214 -0
  106. package/SVF-osx/svf/include/include/Util/CppUtil.h +81 -0
  107. package/SVF-osx/svf/include/include/Util/CxtStmt.h +501 -0
  108. package/SVF-osx/svf/include/include/Util/DPItem.h +618 -0
  109. package/SVF-osx/svf/include/include/Util/ExtAPI.h +339 -0
  110. package/SVF-osx/svf/include/include/Util/ExtAPI.json +5707 -0
  111. package/SVF-osx/svf/include/include/Util/GraphReachSolver.h +186 -0
  112. package/SVF-osx/svf/include/include/Util/NodeIDAllocator.h +194 -0
  113. package/SVF-osx/svf/include/include/Util/Options.h +266 -0
  114. package/SVF-osx/svf/include/include/Util/PTAStat.h +65 -0
  115. package/SVF-osx/svf/include/include/Util/SCC.h +354 -0
  116. package/SVF-osx/svf/include/include/Util/SVFStat.h +100 -0
  117. package/SVF-osx/svf/include/include/Util/SVFUtil.h +660 -0
  118. package/SVF-osx/svf/include/include/Util/SparseBitVector.h +1202 -0
  119. package/SVF-osx/svf/include/include/Util/ThreadAPI.h +330 -0
  120. package/SVF-osx/svf/include/include/Util/WorkList.h +317 -0
  121. package/SVF-osx/svf/include/include/Util/Z3Expr.h +318 -0
  122. package/SVF-osx/svf/include/include/Util/cJSON.h +300 -0
  123. package/SVF-osx/svf/include/include/Util/iterator.h +407 -0
  124. package/SVF-osx/svf/include/include/Util/iterator_range.h +76 -0
  125. package/SVF-osx/svf/include/include/WPA/Andersen.h +416 -0
  126. package/SVF-osx/svf/include/include/WPA/AndersenPWC.h +160 -0
  127. package/SVF-osx/svf/include/include/WPA/CSC.h +95 -0
  128. package/SVF-osx/svf/include/include/WPA/FlowSensitive.h +317 -0
  129. package/SVF-osx/svf/include/include/WPA/Steensgaard.h +126 -0
  130. package/SVF-osx/svf/include/include/WPA/TypeAnalysis.h +83 -0
  131. package/SVF-osx/svf/include/include/WPA/VersionedFlowSensitive.h +287 -0
  132. package/SVF-osx/svf/include/include/WPA/WPAFSSolver.h +254 -0
  133. package/SVF-osx/svf/include/include/WPA/WPAPass.h +119 -0
  134. package/SVF-osx/svf/include/include/WPA/WPASolver.h +205 -0
  135. package/SVF-osx/svf/include/include/WPA/WPAStat.h +222 -0
  136. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BasicTypes.h +250 -0
  137. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BreakConstantExpr.h +94 -0
  138. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/CHGBuilder.h +73 -0
  139. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/DCHG.h +484 -0
  140. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
  141. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/ICFGBuilder.h +106 -0
  142. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMLoopAnalysis.h +61 -0
  143. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMModule.h +360 -0
  144. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMUtil.h +466 -0
  145. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SVFIRBuilder.h +417 -0
  146. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SymbolTableBuilder.h +110 -0
  147. package/package.json +1 -1
@@ -0,0 +1,313 @@
1
+ //===- ProgSlice.h -- Program slicing based on SVF----------------------------//
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
+ * ProgSlice.h
25
+ *
26
+ * Created on: Apr 1, 2014
27
+ * Author: Yulei Sui
28
+ *
29
+ * The implementation is based on
30
+ * (1) Yulei Sui, Ding Ye, and Jingling Xue. "Static Memory Leak Detection Using Full-Sparse Value-Flow Analysis".
31
+ * 2012 International Symposium on Software Testing and Analysis (ISSTA'12)
32
+ *
33
+ * (2) Yulei Sui, Ding Ye, and Jingling Xue. "Detecting Memory Leaks Statically with Full-Sparse Value-Flow Analysis".
34
+ * IEEE Transactions on Software Engineering (TSE'14)
35
+ */
36
+
37
+ #ifndef PROGSLICE_H_
38
+ #define PROGSLICE_H_
39
+
40
+ #include "SABER/SaberCondAllocator.h"
41
+ #include "Util/WorkList.h"
42
+ #include "Graphs/SVFG.h"
43
+ #include "Util/DPItem.h"
44
+
45
+ namespace SVF
46
+ {
47
+
48
+ class ProgSlice
49
+ {
50
+
51
+ public:
52
+ typedef Set<const SVFGNode*> SVFGNodeSet;
53
+ typedef SVFGNodeSet::const_iterator SVFGNodeSetIter;
54
+ typedef SaberCondAllocator::Condition Condition;
55
+ typedef Map<const SVFGNode*, Condition> SVFGNodeToCondMap; ///< map a SVFGNode to its condition during value-flow guard computation
56
+
57
+ typedef FIFOWorkList<const SVFGNode*> VFWorkList; ///< worklist for value-flow guard computation
58
+ typedef FIFOWorkList<const SVFBasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
59
+
60
+ /// Constructor
61
+ ProgSlice(const SVFGNode* src, SaberCondAllocator* pa, const SVFG* graph):
62
+ root(src), partialReachable(false), fullReachable(false), reachGlob(false),
63
+ pathAllocator(pa), _curSVFGNode(nullptr), finalCond(pa->getFalseCond()), svfg(graph)
64
+ {
65
+ }
66
+
67
+ /// Destructor
68
+ virtual ~ProgSlice()
69
+ {
70
+ destroy();
71
+ }
72
+
73
+ inline u32_t getForwardSliceSize() const
74
+ {
75
+ return forwardslice.size();
76
+ }
77
+ inline u32_t getBackwardSliceSize() const
78
+ {
79
+ return backwardslice.size();
80
+ }
81
+ /// Forward and backward slice operations
82
+ //@{
83
+ inline void addToForwardSlice(const SVFGNode* node)
84
+ {
85
+ forwardslice.insert(node);
86
+ }
87
+ inline void addToBackwardSlice(const SVFGNode* node)
88
+ {
89
+ backwardslice.insert(node);
90
+ }
91
+ inline bool inForwardSlice(const SVFGNode* node)
92
+ {
93
+ return forwardslice.find(node)!=forwardslice.end();
94
+ }
95
+ inline bool inBackwardSlice(const SVFGNode* node)
96
+ {
97
+ return backwardslice.find(node)!=backwardslice.end();
98
+ }
99
+ inline SVFGNodeSetIter forwardSliceBegin() const
100
+ {
101
+ return forwardslice.begin();
102
+ }
103
+ inline SVFGNodeSetIter forwardSliceEnd() const
104
+ {
105
+ return forwardslice.end();
106
+ }
107
+ inline SVFGNodeSetIter backwardSliceBegin() const
108
+ {
109
+ return backwardslice.begin();
110
+ }
111
+ inline SVFGNodeSetIter backwardSliceEnd() const
112
+ {
113
+ return backwardslice.end();
114
+ }
115
+ //@}
116
+
117
+ /// root and sink operations
118
+ //@{
119
+ inline const SVFGNode* getSource() const
120
+ {
121
+ return root;
122
+ }
123
+ inline void addToSinks(const SVFGNode* node)
124
+ {
125
+ sinks.insert(node);
126
+ }
127
+ inline const SVFGNodeSet& getSinks() const
128
+ {
129
+ return sinks;
130
+ }
131
+ inline SVFGNodeSetIter sinksBegin() const
132
+ {
133
+ return sinks.begin();
134
+ }
135
+ inline SVFGNodeSetIter sinksEnd() const
136
+ {
137
+ return sinks.end();
138
+ }
139
+ inline void setPartialReachable()
140
+ {
141
+ partialReachable = true;
142
+ }
143
+ inline void setAllReachable()
144
+ {
145
+ fullReachable = true;
146
+ }
147
+ inline bool setReachGlobal()
148
+ {
149
+ return reachGlob = true;
150
+ }
151
+ inline bool isPartialReachable() const
152
+ {
153
+ return partialReachable || reachGlob;
154
+ }
155
+ inline bool isAllReachable() const
156
+ {
157
+ return fullReachable || reachGlob;
158
+ }
159
+ inline bool isReachGlobal() const
160
+ {
161
+ return reachGlob;
162
+ }
163
+ //@}
164
+
165
+ /// Guarded reachability solve
166
+ bool AllPathReachableSolve();
167
+ bool isSatisfiableForAll();
168
+ bool isSatisfiableForPairs();
169
+
170
+ /// Get callsite ID and get returnsiteID from SVFGEdge
171
+ //@{
172
+ const CallICFGNode* getCallSite(const SVFGEdge* edge) const;
173
+ const CallICFGNode* getRetSite(const SVFGEdge* edge) const;
174
+ //@}
175
+
176
+ /// Condition operations
177
+ //@{
178
+ inline Condition condAnd(const Condition &lhs, const Condition &rhs)
179
+ {
180
+ return pathAllocator->condAnd(lhs,rhs);
181
+ }
182
+ inline Condition condOr(const Condition &lhs, const Condition &rhs)
183
+ {
184
+ return pathAllocator->condOr(lhs,rhs);
185
+ }
186
+ inline Condition condNeg(const Condition &cond)
187
+ {
188
+ return pathAllocator->condNeg(cond);
189
+ }
190
+ inline Condition getTrueCond() const
191
+ {
192
+ return pathAllocator->getTrueCond();
193
+ }
194
+ inline Condition getFalseCond() const
195
+ {
196
+ return pathAllocator->getFalseCond();
197
+ }
198
+ inline std::string dumpCond(const Condition& cond) const
199
+ {
200
+ return pathAllocator->dumpCond(cond);
201
+ }
202
+ /// Evaluate final condition
203
+ std::string evalFinalCond() const;
204
+ //@}
205
+
206
+ protected:
207
+ inline const SVFG* getSVFG() const
208
+ {
209
+ return svfg;
210
+ }
211
+
212
+ /// Release memory
213
+ void destroy();
214
+ /// Clear Control flow conditions before each VF computation
215
+ inline void clearCFCond()
216
+ {
217
+ /// TODO: how to clean z3 memory
218
+ pathAllocator->clearCFCond();
219
+ }
220
+
221
+ /// Get/set VF (value-flow) and CF (control-flow) conditions
222
+ //@{
223
+ inline Condition getVFCond(const SVFGNode* node) const
224
+ {
225
+ SVFGNodeToCondMap::const_iterator it = svfgNodeToCondMap.find(node);
226
+ if(it==svfgNodeToCondMap.end())
227
+ {
228
+ return getFalseCond();
229
+ }
230
+ return it->second;
231
+ }
232
+ inline bool setVFCond(const SVFGNode* node, const Condition &cond)
233
+ {
234
+ SVFGNodeToCondMap::iterator it = svfgNodeToCondMap.find(node);
235
+ // until a fixed-point is reached (condition is not changed)
236
+ if(it!=svfgNodeToCondMap.end() && isEquivalentBranchCond(it->second, cond))
237
+ return false;
238
+
239
+ svfgNodeToCondMap[node] = cond;
240
+ return true;
241
+ }
242
+ //@}
243
+
244
+ /// Compute guards for value-flows
245
+ //@{
246
+ inline Condition ComputeIntraVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst)
247
+ {
248
+ return pathAllocator->ComputeIntraVFGGuard(src,dst);
249
+ }
250
+ inline Condition ComputeInterCallVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* callBB)
251
+ {
252
+ return pathAllocator->ComputeInterCallVFGGuard(src,dst,callBB);
253
+ }
254
+ inline Condition ComputeInterRetVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* retBB)
255
+ {
256
+ return pathAllocator->ComputeInterRetVFGGuard(src,dst,retBB);
257
+ }
258
+ //@}
259
+
260
+ inline bool isEquivalentBranchCond(const Condition &lhs, const Condition &rhs) const
261
+ {
262
+ return pathAllocator->isEquivalentBranchCond(lhs, rhs);
263
+ };
264
+
265
+ /// Return the basic block where a SVFGNode resides in
266
+ /// a SVFGNode may not in a basic block if it is not a program statement
267
+ /// (e.g. PAGEdge is an global assignment or NullPtrSVFGNode)
268
+ inline const SVFBasicBlock* getSVFGNodeBB(const SVFGNode* node) const
269
+ {
270
+ const ICFGNode* icfgNode = node->getICFGNode();
271
+ if(SVFUtil::isa<NullPtrSVFGNode>(node) == false)
272
+ {
273
+ return icfgNode->getBB();
274
+ }
275
+ return nullptr;
276
+ }
277
+
278
+ /// Get/set current SVFG node
279
+ //@{
280
+ inline const SVFGNode* getCurSVFGNode() const
281
+ {
282
+ return _curSVFGNode;
283
+ }
284
+ inline void setCurSVFGNode(const SVFGNode* node)
285
+ {
286
+ _curSVFGNode = node;
287
+ pathAllocator->setCurEvalSVFGNode(node);
288
+ }
289
+ //@}
290
+ /// Set final condition after all path reachability analysis
291
+ inline void setFinalCond(const Condition &cond)
292
+ {
293
+ finalCond = cond;
294
+ }
295
+
296
+ private:
297
+ SVFGNodeSet forwardslice; ///< the forward slice
298
+ SVFGNodeSet backwardslice; ///< the backward slice
299
+ SVFGNodeSet sinks; ///< a set of sink nodes
300
+ const SVFGNode* root; ///< root node on the slice
301
+ SVFGNodeToCondMap svfgNodeToCondMap; ///< map a SVFGNode to its path condition starting from root
302
+ bool partialReachable; ///< reachable from some paths
303
+ bool fullReachable; ///< reachable from all paths
304
+ bool reachGlob; ///< Whether slice reach a global
305
+ SaberCondAllocator* pathAllocator; ///< path condition allocator
306
+ const SVFGNode* _curSVFGNode; ///< current svfg node during guard computation
307
+ Condition finalCond; ///< final condition
308
+ const SVFG* svfg; ///< SVFG
309
+ };
310
+
311
+ } // End namespace SVF
312
+
313
+ #endif /* PROGSLICE_H_ */
@@ -0,0 +1,166 @@
1
+ //===- SaberCheckerAPI.h -- API for checkers in Saber-------------------------//
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
+ * SaberCheckerAPI.h
25
+ *
26
+ * Created on: Apr 23, 2014
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef SABERCHECKERAPI_H_
31
+ #define SABERCHECKERAPI_H_
32
+
33
+ #include "Util/SVFUtil.h"
34
+ #include "Graphs/ICFGNode.h"
35
+
36
+ namespace SVF
37
+ {
38
+
39
+ /*
40
+ * Saber Checker API class contains interfaces for various bug checking
41
+ * memory leak detection e.g., alloc free
42
+ * incorrect file operation detection, e.g., fopen, fclose
43
+ */
44
+ class SaberCheckerAPI
45
+ {
46
+
47
+ public:
48
+ enum CHECKER_TYPE
49
+ {
50
+ CK_DUMMY = 0, /// dummy type
51
+ CK_ALLOC, /// memory allocation
52
+ CK_FREE, /// memory deallocation
53
+ CK_FOPEN, /// File open
54
+ CK_FCLOSE /// File close
55
+ };
56
+
57
+ typedef Map<std::string, CHECKER_TYPE> TDAPIMap;
58
+
59
+ private:
60
+ /// API map, from a string to threadAPI type
61
+ TDAPIMap tdAPIMap;
62
+
63
+ /// Constructor
64
+ SaberCheckerAPI ()
65
+ {
66
+ init();
67
+ }
68
+
69
+ /// Initialize the map
70
+ void init();
71
+
72
+ /// Static reference
73
+ static SaberCheckerAPI* ckAPI;
74
+
75
+ /// Get the function type of a function
76
+ inline CHECKER_TYPE getType(const SVFFunction* F) const
77
+ {
78
+ if(F)
79
+ {
80
+ TDAPIMap::const_iterator it= tdAPIMap.find(F->getName());
81
+ if(it != tdAPIMap.end())
82
+ return it->second;
83
+ }
84
+ return CK_DUMMY;
85
+ }
86
+
87
+ public:
88
+ /// Return a static reference
89
+ static SaberCheckerAPI* getCheckerAPI()
90
+ {
91
+ if(ckAPI == nullptr)
92
+ {
93
+ ckAPI = new SaberCheckerAPI();
94
+ }
95
+ return ckAPI;
96
+ }
97
+
98
+ /// Return true if this call is a memory allocation
99
+ //@{
100
+ inline bool isMemAlloc(const SVFFunction* fun) const
101
+ {
102
+ return getType(fun) == CK_ALLOC;
103
+ }
104
+ inline bool isMemAlloc(const SVFInstruction* inst) const
105
+ {
106
+ return getType(SVFUtil::getCallee(inst)) == CK_ALLOC;
107
+ }
108
+ inline bool isMemAlloc(const CallICFGNode* cs) const
109
+ {
110
+ return isMemAlloc(cs->getCallSite());
111
+ }
112
+ //@}
113
+
114
+ /// Return true if this call is a memory deallocation
115
+ //@{
116
+ inline bool isMemDealloc(const SVFFunction* fun) const
117
+ {
118
+ return getType(fun) == CK_FREE;
119
+ }
120
+ inline bool isMemDealloc(const SVFInstruction *inst) const
121
+ {
122
+ return getType(SVFUtil::getCallee(inst)) == CK_FREE;
123
+ }
124
+ inline bool isMemDealloc(const CallICFGNode* cs) const
125
+ {
126
+ return isMemDealloc(cs->getCallSite());
127
+ }
128
+ //@}
129
+
130
+ /// Return true if this call is a file open
131
+ //@{
132
+ inline bool isFOpen(const SVFFunction* fun) const
133
+ {
134
+ return getType(fun) == CK_FOPEN;
135
+ }
136
+ inline bool isFOpen(const SVFInstruction* inst) const
137
+ {
138
+ return getType(SVFUtil::getCallee(inst)) == CK_FOPEN;
139
+ }
140
+ inline bool isFOpen(const CallICFGNode* cs) const
141
+ {
142
+ return isFOpen(cs->getCallSite());
143
+ }
144
+ //@}
145
+
146
+ /// Return true if this call is a file close
147
+ //@{
148
+ inline bool isFClose(const SVFFunction* fun) const
149
+ {
150
+ return getType(fun) == CK_FCLOSE;
151
+ }
152
+ inline bool isFClose(const SVFInstruction* inst) const
153
+ {
154
+ return getType(SVFUtil::getCallee(inst)) == CK_FCLOSE;
155
+ }
156
+ inline bool isFClose(const CallICFGNode* cs) const
157
+ {
158
+ return isFClose(cs->getCallSite());
159
+ }
160
+ //@}
161
+
162
+ };
163
+
164
+ } // End namespace SVF
165
+
166
+ #endif /* SABERCHECKERAPI_H_ */