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,452 @@
1
+ //===- PointerAnalysis.h -- Base class of pointer analyses--------------------//
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
+ * PointerAnalysis.h
25
+ *
26
+ * Created on: Nov 12, 2013
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef POINTERANALYSIS_H_
31
+ #define POINTERANALYSIS_H_
32
+
33
+ #include <unistd.h>
34
+ #include <signal.h>
35
+
36
+ #include "SVFIR/SVFIR.h"
37
+ #include "MemoryModel/ConditionalPT.h"
38
+ #include "MemoryModel/AbstractPointsToDS.h"
39
+ #include "MemoryModel/MutablePointsToDS.h"
40
+ #include "MemoryModel/PersistentPointsToDS.h"
41
+ #include "Graphs/PTACallGraph.h"
42
+ #include "Graphs/CHG.h"
43
+ #include "Util/SCC.h"
44
+ #include "MemoryModel/PointsTo.h"
45
+
46
+ namespace SVF
47
+ {
48
+
49
+ class CommonCHGraph;
50
+
51
+ class TypeSystem;
52
+ class SVFModule;
53
+ class ICFG;
54
+ class PTAStat;
55
+ /*
56
+ * Pointer Analysis Base Class
57
+ */
58
+ class PointerAnalysis
59
+ {
60
+
61
+ public:
62
+ /// Pointer analysis type list
63
+ enum PTATY
64
+ {
65
+ // Whole program analysis
66
+ Andersen_BASE, ///< Base Andersen PTA
67
+ Andersen_WPA, ///< Andersen PTA
68
+ AndersenSCD_WPA, ///< Selective cycle detection andersen-style WPA
69
+ AndersenSFR_WPA, ///< Stride-based field representation
70
+ AndersenWaveDiff_WPA, ///< Diff wave propagation andersen-style WPA
71
+ Steensgaard_WPA, ///< Steensgaard PTA
72
+ CSCallString_WPA, ///< Call string based context sensitive WPA
73
+ CSSummary_WPA, ///< Summary based context sensitive WPA
74
+ FSDATAFLOW_WPA, ///< Traditional Dataflow-based flow sensitive WPA
75
+ FSSPARSE_WPA, ///< Sparse flow sensitive WPA
76
+ VFS_WPA, ///< Versioned sparse flow-sensitive WPA
77
+ FSCS_WPA, ///< Flow-, context- sensitive WPA
78
+ CFLFICI_WPA, ///< Flow-, context-, insensitive CFL-reachability-based analysis
79
+ CFLFSCI_WPA, ///< Flow-insensitive, context-sensitive CFL-reachability-based analysis
80
+ CFLFSCS_WPA, ///< Flow-, context-, CFL-reachability-based analysis
81
+ TypeCPP_WPA, ///< Type-based analysis for C++
82
+
83
+ // Demand driven analysis
84
+ FieldS_DDA, ///< Field sensitive DDA
85
+ FlowS_DDA, ///< Flow sensitive DDA
86
+ PathS_DDA, ///< Guarded value-flow DDA
87
+ Cxt_DDA, ///< context sensitive DDA
88
+
89
+
90
+ Default_PTA ///< default pta without any analysis
91
+ };
92
+
93
+ /// Implementation type: BVDataPTAImpl or CondPTAImpl.
94
+ enum PTAImplTy
95
+ {
96
+ BaseImpl, ///< Represents PointerAnalaysis.
97
+ BVDataImpl, ///< Represents BVDataPTAImpl.
98
+ CondImpl, ///< Represents CondPTAImpl.
99
+ };
100
+
101
+ /// Indirect call edges type, map a callsite to a set of callees
102
+ //@{
103
+ typedef Set<const CallICFGNode*> CallSiteSet;
104
+ typedef SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap;
105
+ typedef Set<const SVFFunction*> FunctionSet;
106
+ typedef OrderedMap<const CallICFGNode*, FunctionSet> CallEdgeMap;
107
+ typedef SCCDetection<PTACallGraph*> CallGraphSCC;
108
+ typedef Set<const SVFGlobalValue*> VTableSet;
109
+ typedef Set<const SVFFunction*> VFunSet;
110
+ //@}
111
+
112
+ static const std::string aliasTestMayAlias;
113
+ static const std::string aliasTestMayAliasMangled;
114
+ static const std::string aliasTestNoAlias;
115
+ static const std::string aliasTestNoAliasMangled;
116
+ static const std::string aliasTestPartialAlias;
117
+ static const std::string aliasTestPartialAliasMangled;
118
+ static const std::string aliasTestMustAlias;
119
+ static const std::string aliasTestMustAliasMangled;
120
+ static const std::string aliasTestFailMayAlias;
121
+ static const std::string aliasTestFailMayAliasMangled;
122
+ static const std::string aliasTestFailNoAlias;
123
+ static const std::string aliasTestFailNoAliasMangled;
124
+
125
+ private:
126
+ /// Release the memory
127
+ void destroy();
128
+
129
+ protected:
130
+
131
+ /// User input flags
132
+ //@{
133
+ /// Flag for printing the statistic results
134
+ bool print_stat;
135
+ /// Flag for validating points-to/alias results
136
+ bool alias_validation;
137
+ /// Flag for iteration budget for on-the-fly statistics
138
+ u32_t OnTheFlyIterBudgetForStat;
139
+ //@}
140
+
141
+ /// SVFIR
142
+ static SVFIR* pag;
143
+ /// Module
144
+ SVFModule* svfMod;
145
+ /// Pointer analysis Type
146
+ PTATY ptaTy;
147
+ /// PTA implementation type.
148
+ PTAImplTy ptaImplTy;
149
+ /// Statistics
150
+ PTAStat* stat;
151
+ /// Call graph used for pointer analysis
152
+ PTACallGraph* ptaCallGraph;
153
+ /// SCC for CallGraph
154
+ CallGraphSCC* callGraphSCC;
155
+ /// Interprocedural control-flow graph
156
+ ICFG* icfg;
157
+ /// CHGraph
158
+ CommonCHGraph *chgraph;
159
+ /// TypeSystem
160
+ TypeSystem *typeSystem;
161
+
162
+ public:
163
+ /// Get ICFG
164
+ inline ICFG* getICFG() const
165
+ {
166
+ return pag->getICFG();
167
+ }
168
+ /// Return number of resolved indirect call edges
169
+ inline u32_t getNumOfResolvedIndCallEdge() const
170
+ {
171
+ return getPTACallGraph()->getNumOfResolvedIndCallEdge();
172
+ }
173
+ /// Return call graph
174
+ inline PTACallGraph* getPTACallGraph() const
175
+ {
176
+ return ptaCallGraph;
177
+ }
178
+ /// Return call graph SCC
179
+ inline CallGraphSCC* getCallGraphSCC() const
180
+ {
181
+ return callGraphSCC;
182
+ }
183
+
184
+ /// Constructor
185
+ PointerAnalysis(SVFIR* pag, PTATY ty = Default_PTA, bool alias_check = true);
186
+
187
+ /// Type of pointer analysis
188
+ inline PTATY getAnalysisTy() const
189
+ {
190
+ return ptaTy;
191
+ }
192
+
193
+ /// Return implementation type of the pointer analysis.
194
+ inline PTAImplTy getImplTy() const
195
+ {
196
+ return ptaImplTy;
197
+ }
198
+
199
+ /// Get/set SVFIR
200
+ ///@{
201
+ inline SVFIR* getPAG() const
202
+ {
203
+ return pag;
204
+ }
205
+ //@}
206
+
207
+ /// Get PTA stat
208
+ inline PTAStat* getStat() const
209
+ {
210
+ return stat;
211
+ }
212
+ /// Module
213
+ inline SVFModule* getModule() const
214
+ {
215
+ return svfMod;
216
+ }
217
+ /// Get all Valid Pointers for resolution
218
+ inline OrderedNodeSet& getAllValidPtrs()
219
+ {
220
+ return pag->getAllValidPtrs();
221
+ }
222
+
223
+ /// Destructor
224
+ virtual ~PointerAnalysis();
225
+
226
+ /// Initialization of a pointer analysis, including building symbol table and SVFIR etc.
227
+ virtual void initialize();
228
+
229
+ /// Finalization of a pointer analysis, including checking alias correctness
230
+ virtual void finalize();
231
+
232
+ /// Start Analysis here (main part of pointer analysis). It needs to be implemented in child class
233
+ virtual void analyze() = 0;
234
+
235
+ /// Compute points-to results on-demand, overridden by derived classes
236
+ virtual void computeDDAPts(NodeID) {}
237
+
238
+ /// Interface exposed to users of our pointer analysis, given Value infos
239
+ virtual AliasResult alias(const SVFValue* V1,
240
+ const SVFValue* V2) = 0;
241
+
242
+ /// Interface exposed to users of our pointer analysis, given PAGNodeID
243
+ virtual AliasResult alias(NodeID node1, NodeID node2) = 0;
244
+
245
+ /// Get points-to targets of a pointer. It needs to be implemented in child class
246
+ virtual const PointsTo& getPts(NodeID ptr) = 0;
247
+
248
+ /// Given an object, get all the nodes having whose pointsto contains the object.
249
+ /// Similar to getPts, this also needs to be implemented in child classes.
250
+ virtual const NodeSet& getRevPts(NodeID nodeId) = 0;
251
+
252
+ /// Print targets of a function pointer
253
+ void printIndCSTargets(const CallICFGNode* cs, const FunctionSet& targets);
254
+
255
+ // Debug purpose
256
+ //@{
257
+ virtual void dumpTopLevelPtsTo() {}
258
+ virtual void dumpAllPts() {}
259
+ virtual void dumpCPts() {}
260
+ virtual void dumpPts(NodeID ptr, const PointsTo& pts);
261
+ void printIndCSTargets();
262
+ void dumpAllTypes();
263
+ //@}
264
+
265
+ protected:
266
+ /// Return all indirect callsites
267
+ inline const CallSiteToFunPtrMap& getIndirectCallsites() const
268
+ {
269
+ return pag->getIndirectCallsites();
270
+ }
271
+ /// Return function pointer PAGNode at a callsite cs
272
+ inline NodeID getFunPtr(const CallICFGNode* cs) const
273
+ {
274
+ return pag->getFunPtr(cs);
275
+ }
276
+ /// Alias check functions to verify correctness of pointer analysis
277
+ //@{
278
+ virtual void validateTests();
279
+ virtual void validateSuccessTests(std::string fun);
280
+ virtual void validateExpectedFailureTests(std::string fun);
281
+ //@}
282
+
283
+ /// Reset all object node as field-sensitive.
284
+ void resetObjFieldSensitive();
285
+
286
+ public:
287
+ /// Dump the statistics
288
+ void dumpStat();
289
+
290
+ /// Determine whether a points-to contains a black hole or constant node
291
+ //@{
292
+ inline bool containBlackHoleNode(const PointsTo& pts)
293
+ {
294
+ return pts.test(pag->getBlackHoleNode());
295
+ }
296
+ inline bool containConstantNode(const PointsTo& pts)
297
+ {
298
+ return pts.test(pag->getConstantNode());
299
+ }
300
+ virtual inline bool isBlkObjOrConstantObj(NodeID ptd) const
301
+ {
302
+ return pag->isBlkObjOrConstantObj(ptd);
303
+ }
304
+ inline bool isNonPointerObj(NodeID ptd) const
305
+ {
306
+ return pag->isNonPointerObj(ptd);
307
+ }
308
+ //@}
309
+
310
+ /// Whether this object is heap or array
311
+ //@{
312
+ inline bool isHeapMemObj(NodeID id) const
313
+ {
314
+ const MemObj* mem = pag->getObject(id);
315
+ assert(mem && "memory object is null??");
316
+ return mem->isHeap();
317
+ }
318
+
319
+ inline bool isArrayMemObj(NodeID id) const
320
+ {
321
+ const MemObj* mem = pag->getObject(id);
322
+ assert(mem && "memory object is null??");
323
+ return mem->isArray();
324
+ }
325
+ //@}
326
+
327
+ /// For field-sensitivity
328
+ ///@{
329
+ inline bool isFIObjNode(NodeID id) const
330
+ {
331
+ return (SVFUtil::isa<FIObjVar>(pag->getGNode(id)));
332
+ }
333
+ inline NodeID getBaseObjVar(NodeID id)
334
+ {
335
+ return pag->getBaseObjVar(id);
336
+ }
337
+ inline NodeID getFIObjVar(NodeID id)
338
+ {
339
+ return pag->getFIObjVar(id);
340
+ }
341
+ inline NodeID getGepObjVar(NodeID id, const LocationSet& ls)
342
+ {
343
+ return pag->getGepObjVar(id,ls);
344
+ }
345
+ virtual inline const NodeBS& getAllFieldsObjVars(NodeID id)
346
+ {
347
+ return pag->getAllFieldsObjVars(id);
348
+ }
349
+ inline void setObjFieldInsensitive(NodeID id)
350
+ {
351
+ MemObj* mem = const_cast<MemObj*>(pag->getBaseObj(id));
352
+ mem->setFieldInsensitive();
353
+ }
354
+ inline bool isFieldInsensitive(NodeID id) const
355
+ {
356
+ const MemObj* mem = pag->getBaseObj(id);
357
+ return mem->isFieldInsensitive();
358
+ }
359
+ ///@}
360
+
361
+ /// Whether print statistics
362
+ inline bool printStat()
363
+ {
364
+ return print_stat;
365
+ }
366
+
367
+ /// Whether print statistics
368
+ inline void disablePrintStat()
369
+ {
370
+ print_stat = false;
371
+ }
372
+
373
+ /// Get callees from an indirect callsite
374
+ //@{
375
+ inline CallEdgeMap& getIndCallMap()
376
+ {
377
+ return getPTACallGraph()->getIndCallMap();
378
+ }
379
+ inline bool hasIndCSCallees(const CallICFGNode* cs) const
380
+ {
381
+ return getPTACallGraph()->hasIndCSCallees(cs);
382
+ }
383
+ inline const FunctionSet& getIndCSCallees(const CallICFGNode* cs) const
384
+ {
385
+ return getPTACallGraph()->getIndCSCallees(cs);
386
+ }
387
+ //@}
388
+
389
+ /// Resolve indirect call edges
390
+ virtual void resolveIndCalls(const CallICFGNode* cs, const PointsTo& target, CallEdgeMap& newEdges);
391
+ /// Match arguments for callsite at caller and callee
392
+ bool matchArgs(const CallICFGNode* cs, const SVFFunction* callee);
393
+
394
+ /// CallGraph SCC related methods
395
+ //@{
396
+ /// CallGraph SCC detection
397
+ inline void callGraphSCCDetection()
398
+ {
399
+ if(callGraphSCC==nullptr)
400
+ callGraphSCC = new CallGraphSCC(ptaCallGraph);
401
+
402
+ callGraphSCC->find();
403
+ }
404
+ /// Get SCC rep node of a SVFG node.
405
+ inline NodeID getCallGraphSCCRepNode(NodeID id) const
406
+ {
407
+ return callGraphSCC->repNode(id);
408
+ }
409
+ /// Return TRUE if this edge is inside a CallGraph SCC, i.e., src node and dst node are in the same SCC on the SVFG.
410
+ inline bool inSameCallGraphSCC(const SVFFunction* fun1,const SVFFunction* fun2)
411
+ {
412
+ const PTACallGraphNode* src = ptaCallGraph->getCallGraphNode(fun1);
413
+ const PTACallGraphNode* dst = ptaCallGraph->getCallGraphNode(fun2);
414
+ return (getCallGraphSCCRepNode(src->getId()) == getCallGraphSCCRepNode(dst->getId()));
415
+ }
416
+ inline bool isInRecursion(const SVFFunction* fun) const
417
+ {
418
+ return callGraphSCC->isInCycle(ptaCallGraph->getCallGraphNode(fun)->getId());
419
+ }
420
+ /// Whether a local variable is in function recursions
421
+ bool isLocalVarInRecursiveFun(NodeID id) const;
422
+ //@}
423
+
424
+ /// Return PTA name
425
+ virtual const std::string PTAName() const
426
+ {
427
+ return "Pointer Analysis";
428
+ }
429
+
430
+ /// get CHGraph
431
+ CommonCHGraph *getCHGraph() const
432
+ {
433
+ return chgraph;
434
+ }
435
+
436
+ void getVFnsFromCHA(const CallICFGNode* cs, VFunSet &vfns);
437
+ void getVFnsFromPts(const CallICFGNode* cs, const PointsTo &target, VFunSet &vfns);
438
+ void connectVCallToVFns(const CallICFGNode* cs, const VFunSet &vfns, CallEdgeMap& newEdges);
439
+ virtual void resolveCPPIndCalls(const CallICFGNode* cs,
440
+ const PointsTo& target,
441
+ CallEdgeMap& newEdges);
442
+
443
+ /// get TypeSystem
444
+ const TypeSystem *getTypeSystem() const
445
+ {
446
+ return typeSystem;
447
+ }
448
+ };
449
+
450
+ } // End namespace SVF
451
+
452
+ #endif /* POINTERANALYSIS_H_ */