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,310 @@
1
+ //===- SaberCondAllocator.h -- Path condition manipulation---------------------//
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
+ * PathAllocator.h
25
+ *
26
+ * Created on: Apr 3, 2014
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef PATHALLOCATOR_H_
31
+ #define PATHALLOCATOR_H_
32
+
33
+ #include "SVFIR/SVFModule.h"
34
+ #include "SVFIR/SVFValue.h"
35
+ #include "Util/WorkList.h"
36
+ #include "Graphs/SVFG.h"
37
+ #include "Util/Z3Expr.h"
38
+
39
+
40
+ namespace SVF
41
+ {
42
+
43
+ /**
44
+ * SaberCondAllocator allocates conditions for each basic block of a certain CFG.
45
+ */
46
+ class SaberCondAllocator
47
+ {
48
+
49
+ public:
50
+
51
+ typedef Z3Expr Condition; /// z3 condition
52
+ typedef Map<u32_t, const SVFInstruction *> IndexToTermInstMap; /// id to instruction map for z3
53
+ typedef Map<u32_t,Condition> CondPosMap; ///< map a branch to its Condition
54
+ typedef Map<const SVFBasicBlock*, CondPosMap > BBCondMap; /// map bb to a Condition
55
+ typedef Set<const SVFBasicBlock*> BasicBlockSet;
56
+ typedef Map<const SVFFunction*, BasicBlockSet> FunToExitBBsMap; ///< map a function to all its basic blocks calling program exit
57
+ typedef Map<const SVFBasicBlock*, Condition> BBToCondMap; ///< map a basic block to its condition during control-flow guard computation
58
+ typedef FIFOWorkList<const SVFBasicBlock*> CFWorkList; ///< worklist for control-flow guard computation
59
+
60
+
61
+ /// Constructor
62
+ SaberCondAllocator();
63
+
64
+ /// Destructor
65
+ virtual ~SaberCondAllocator()
66
+ {
67
+ }
68
+ /// Statistics
69
+ //@{
70
+ inline std::string getMemUsage()
71
+ {
72
+ u32_t vmrss, vmsize;
73
+ if (SVFUtil::getMemoryUsageKB(&vmrss, &vmsize))
74
+ return std::to_string(vmsize) + "KB";
75
+ else
76
+ return "cannot read memory usage";
77
+ }
78
+ inline u32_t getCondNum()
79
+ {
80
+ return totalCondNum;
81
+ }
82
+ //@}
83
+
84
+ /// Condition operations
85
+ //@{
86
+ inline Condition condAnd(const Condition& lhs, const Condition& rhs)
87
+ {
88
+ return Condition::AND(lhs,rhs);
89
+ }
90
+ inline Condition condOr(const Condition& lhs, const Condition& rhs)
91
+ {
92
+ return Condition::OR(lhs,rhs);
93
+ }
94
+ inline Condition condNeg(const Condition& cond)
95
+ {
96
+ return Condition::NEG(cond);
97
+ }
98
+ inline Condition getTrueCond() const
99
+ {
100
+ return Condition::getTrueCond();
101
+ }
102
+ inline Condition getFalseCond() const
103
+ {
104
+ return Condition::getFalseCond();
105
+ }
106
+ /// Iterator every element of the condition
107
+ inline NodeBS exactCondElem(const Condition& cond)
108
+ {
109
+ NodeBS elems;
110
+ extractSubConds(cond, elems);
111
+ return elems;
112
+ }
113
+
114
+ inline std::string dumpCond(const Condition& cond) const
115
+ {
116
+ return Condition::dumpStr(cond);
117
+ }
118
+
119
+ /// Allocate a new condition
120
+ Condition newCond(const SVFInstruction* inst);
121
+
122
+ /// Perform path allocation
123
+ void allocate(const SVFModule* module);
124
+
125
+ /// Get/Set instruction based on Z3 expression id
126
+ //{@
127
+ inline const SVFInstruction* getCondInst(u32_t id) const
128
+ {
129
+ IndexToTermInstMap::const_iterator it = idToTermInstMap.find(id);
130
+ assert(it != idToTermInstMap.end() && "this should be a fresh condition");
131
+ return it->second;
132
+ }
133
+
134
+ inline void setCondInst(const Condition &condition, const SVFInstruction* inst)
135
+ {
136
+ assert(idToTermInstMap.find(condition.id()) == idToTermInstMap.end() && "this should be a fresh condition");
137
+ idToTermInstMap[condition.id()] = inst;
138
+ }
139
+ //@}
140
+
141
+ bool isNegCond(u32_t id) const
142
+ {
143
+ return negConds.test(id);
144
+ }
145
+
146
+ inline bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
147
+ {
148
+ const SVFFunction* keyFunc = bbKey->getParent();
149
+ const SVFFunction* valueFunc = bbValue->getParent();
150
+ bool funcEq = (keyFunc == valueFunc);
151
+ (void)funcEq; // Suppress warning of unused variable under release build
152
+ assert(funcEq && "two basicblocks should be in the same function!");
153
+ return keyFunc->postDominate(bbKey,bbValue);
154
+ }
155
+
156
+ inline bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const
157
+ {
158
+ const SVFFunction* keyFunc = bbKey->getParent();
159
+ const SVFFunction* valueFunc = bbValue->getParent();
160
+ bool funcEq = (keyFunc == valueFunc);
161
+ (void)funcEq; // Suppress warning of unused variable under release build
162
+ assert(funcEq && "two basicblocks should be in the same function!");
163
+ return keyFunc->dominate(bbKey,bbValue);
164
+ }
165
+
166
+ /// Guard Computation for a value-flow (between two basic blocks)
167
+ //@{
168
+ virtual Condition ComputeIntraVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst);
169
+ virtual Condition ComputeInterCallVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* callBB);
170
+ virtual Condition ComputeInterRetVFGGuard(const SVFBasicBlock* src, const SVFBasicBlock* dst, const SVFBasicBlock* retBB);
171
+
172
+ /// Get complement condition (from B1 to B0) according to a complementBB (BB2) at a phi
173
+ /// e.g., B0: dstBB; B1:incomingBB; B2:complementBB
174
+ virtual Condition getPHIComplementCond(const SVFBasicBlock* BB1, const SVFBasicBlock* BB2, const SVFBasicBlock* BB0);
175
+
176
+ inline void clearCFCond()
177
+ {
178
+ bbToCondMap.clear();
179
+ }
180
+ /// Set current value for branch condition evaluation
181
+ inline void setCurEvalSVFGNode(const SVFGNode* node)
182
+ {
183
+ curEvalSVFGNode = node;
184
+ }
185
+ /// Get current value for branch condition evaluation
186
+ inline const SVFGNode* getCurEvalSVFGNode() const
187
+ {
188
+ return curEvalSVFGNode;
189
+ }
190
+ //@}
191
+
192
+ /// Print out the path condition information
193
+ void printPathCond();
194
+
195
+ /// whether condition is satisfiable
196
+ bool isSatisfiable(const Condition& condition);
197
+
198
+ /// whether condition is satisfiable for all possible boolean guards
199
+ inline bool isAllPathReachable(Condition& condition)
200
+ {
201
+ return isEquivalentBranchCond(condition, Condition::getTrueCond());
202
+ }
203
+
204
+ /// Whether lhs and rhs are equivalent branch conditions
205
+ bool isEquivalentBranchCond(const Condition &lhs, const Condition &rhs) const;
206
+
207
+ inline ICFG* getICFG() const
208
+ {
209
+ return PAG::getPAG()->getICFG();
210
+ }
211
+
212
+ /// Get/Set control-flow conditions
213
+ //@{
214
+ inline bool setCFCond(const SVFBasicBlock* bb, const Condition& cond)
215
+ {
216
+ BBToCondMap::iterator it = bbToCondMap.find(bb);
217
+ // until a fixed-point is reached (condition is not changed)
218
+ if(it!=bbToCondMap.end() && isEquivalentBranchCond(it->second, cond))
219
+ return false;
220
+
221
+ bbToCondMap[bb] = cond;
222
+ return true;
223
+ }
224
+ inline Condition getCFCond(const SVFBasicBlock* bb) const
225
+ {
226
+ BBToCondMap::const_iterator it = bbToCondMap.find(bb);
227
+ if(it==bbToCondMap.end())
228
+ {
229
+ return getFalseCond();
230
+ }
231
+ return it->second;
232
+ }
233
+ //@}
234
+
235
+
236
+ /// mark neg Z3 expression
237
+ inline void setNegCondInst(const Condition &condition, const SVFInstruction* inst)
238
+ {
239
+ setCondInst(condition, inst);
240
+ negConds.set(condition.id());
241
+ }
242
+ private:
243
+
244
+ /// Allocate path condition for every basic block
245
+ virtual void allocateForBB(const SVFBasicBlock& bb);
246
+
247
+ /// Get/Set a branch condition, and its terminator instruction
248
+ //@{
249
+ /// Set branch condition
250
+ void setBranchCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ, const Condition& cond);
251
+ /// Get branch condition
252
+ Condition getBranchCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ) const;
253
+ ///Get a condition, evaluate the value for conditions if necessary (e.g., testNull like express)
254
+ Condition getEvalBrCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ);
255
+ //@}
256
+ /// Evaluate branch conditions
257
+ //@{
258
+ /// Evaluate the branch condtion
259
+ Condition evaluateBranchCond(const SVFBasicBlock* bb, const SVFBasicBlock* succ) ;
260
+ /// Evaluate loop exit branch
261
+ Condition evaluateLoopExitBranch(const SVFBasicBlock* bb, const SVFBasicBlock* succ);
262
+ /// Return branch condition after evaluating test null like expression
263
+ Condition evaluateTestNullLikeExpr(const BranchStmt* branchStmt, const SVFBasicBlock* succ);
264
+ /// Return condition when there is a branch calls program exit
265
+ Condition evaluateProgExit(const BranchStmt* branchStmt, const SVFBasicBlock* succ);
266
+ /// Collect basic block contains program exit function call
267
+ void collectBBCallingProgExit(const SVFBasicBlock& bb);
268
+ bool isBBCallsProgExit(const SVFBasicBlock* bb);
269
+ //@}
270
+
271
+ /// Evaluate test null/not null like expressions
272
+ //@{
273
+ /// Return true if the predicate of this compare instruction is equal
274
+ bool isEQCmp(const CmpStmt* cmp) const;
275
+ /// Return true if the predicate of this compare instruction is not equal
276
+ bool isNECmp(const CmpStmt* cmp) const;
277
+ /// Return true if this is a test null expression
278
+ bool isTestNullExpr(const SVFValue* test) const;
279
+ /// Return true if this is a test not null expression
280
+ bool isTestNotNullExpr(const SVFValue* test) const;
281
+ /// Return true if two values on the predicate are what we want
282
+ bool isTestContainsNullAndTheValue(const CmpStmt* cmp) const;
283
+ //@}
284
+
285
+ /// Release memory
286
+ void destroy()
287
+ {
288
+
289
+ }
290
+
291
+ /// extract subexpression from a Z3 expression
292
+ void extractSubConds(const Condition &condition, NodeBS &support) const;
293
+
294
+
295
+ FunToExitBBsMap funToExitBBsMap; ///< map a function to all its basic blocks calling program exit
296
+ BBToCondMap bbToCondMap; ///< map a basic block to its path condition starting from root
297
+ const SVFGNode* curEvalSVFGNode{}; ///< current llvm value to evaluate branch condition when computing guards
298
+ IndexToTermInstMap idToTermInstMap; ///key: z3 expression id, value: instruction
299
+ NodeBS negConds; ///bit vector for distinguish neg
300
+ std::vector<Condition> conditionVec; /// vector storing z3expression
301
+ static u32_t totalCondNum; /// a counter for fresh condition
302
+
303
+ protected:
304
+ BBCondMap bbConds; ///< map basic block to its successors/predecessors branch conditions
305
+
306
+ };
307
+
308
+ } // End namespace SVF
309
+
310
+ #endif /* PATHALLOCATOR_H_ */
@@ -0,0 +1,104 @@
1
+ //===- SaberSVFGBuilder.h -- Building SVFG for 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
+ * SaberSVFGBuilder.h
25
+ *
26
+ * Created on: May 1, 2014
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef SABERSVFGBUILDER_H_
31
+ #define SABERSVFGBUILDER_H_
32
+
33
+ #include "MSSA/SVFGBuilder.h"
34
+ #include "SVFIR/SVFValue.h"
35
+ #include "Util/WorkList.h"
36
+
37
+ namespace SVF
38
+ {
39
+
40
+ class SaberSVFGBuilder : public SVFGBuilder
41
+ {
42
+
43
+ public:
44
+ typedef Set<const SVFGNode*> SVFGNodeSet;
45
+ typedef Map<NodeID, PointsTo> NodeToPTSSMap;
46
+ typedef FIFOWorkList<NodeID> WorkList;
47
+
48
+ /// Constructor
49
+ SaberSVFGBuilder(): SVFGBuilder(true) {}
50
+
51
+ /// Destructor
52
+ virtual ~SaberSVFGBuilder() {}
53
+
54
+ inline bool isGlobalSVFGNode(const SVFGNode* node) const
55
+ {
56
+ return globSVFGNodes.find(node)!=globSVFGNodes.end();
57
+ }
58
+
59
+ /// Add ActualParmVFGNode
60
+ inline void addActualParmVFGNode(const PAGNode* pagNode, const CallICFGNode* cs)
61
+ {
62
+ svfg->addActualParmVFGNode(pagNode, cs);
63
+ }
64
+
65
+ protected:
66
+ /// Re-write create SVFG method
67
+ virtual void buildSVFG();
68
+
69
+ /// Return TRUE if this is a strong update STORE statement.
70
+ bool isStrongUpdate(const SVFGNode* node, NodeID& singleton, BVDataPTAImpl* pta);
71
+
72
+ private:
73
+ /// Remove direct value-flow edge to a dereference point for Saber source-sink memory error detection
74
+ /// for example, given two statements: p = alloc; q = *p, the direct SVFG edge between them is deleted
75
+ /// Because those edges only stand for values used at the dereference points but they can not pass the value to other definitions
76
+ void rmDerefDirSVFGEdges(BVDataPTAImpl* pta);
77
+
78
+ /// Remove Incoming Edge for strong-update (SU) store instruction
79
+ /// Because the SU node does not receive indirect value
80
+ void rmIncomingEdgeForSUStore(BVDataPTAImpl* pta);
81
+
82
+ /// Add actual parameter SVFGNode for 1st argument of a deallocation like external function
83
+ /// In order to path sensitive leak detection
84
+ virtual void AddExtActualParmSVFGNodes(PTACallGraph* callgraph);
85
+
86
+ /// Collect memory pointed global pointers,
87
+ /// note that this collection is recursively performed, for example gp-->obj-->obj'
88
+ /// obj and obj' are both considered global memory
89
+ void collectGlobals(BVDataPTAImpl* pta);
90
+
91
+ /// Whether points-to of a PAGNode points-to global variable
92
+ bool accessGlobal(BVDataPTAImpl* pta,const PAGNode* pagNode);
93
+
94
+ /// Collect objects along points-to chains
95
+ PointsTo& CollectPtsChain(BVDataPTAImpl* pta,NodeID id, NodeToPTSSMap& cachedPtsMap);
96
+
97
+ PointsTo globs;
98
+ /// Store all global SVFG nodes
99
+ SVFGNodeSet globSVFGNodes;
100
+ };
101
+
102
+ } // End namespace SVF
103
+
104
+ #endif /* SABERSVFGBUILDER_H_ */