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,498 @@
1
+ //===- PTACallGraph.h -- Call graph representation----------------------------//
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
+ * PTACallGraph.h
25
+ *
26
+ * Created on: Nov 7, 2013
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef PTACALLGRAPH_H_
31
+ #define PTACALLGRAPH_H_
32
+
33
+ #include "Graphs/GenericGraph.h"
34
+ #include "SVFIR/SVFValue.h"
35
+ #include "Graphs/ICFG.h"
36
+ #include <set>
37
+
38
+ namespace SVF
39
+ {
40
+
41
+ class CallGraphNode;
42
+ class SVFModule;
43
+ class CallGraph;
44
+
45
+
46
+ /*
47
+ * Call Graph edge representing a calling relation between two functions
48
+ * Multiple calls from function A to B are merged into one call edge
49
+ * Each call edge has a set of direct callsites and a set of indirect callsites
50
+ */
51
+ typedef GenericEdge<CallGraphNode> GenericPTACallGraphEdgeTy;
52
+ class CallGraphEdge : public GenericPTACallGraphEdgeTy
53
+ {
54
+
55
+ public:
56
+ typedef Set<const CallICFGNode*> CallInstSet;
57
+ enum CEDGEK
58
+ {
59
+ CallRetEdge,TDForkEdge,TDJoinEdge,HareParForEdge
60
+ };
61
+
62
+
63
+ private:
64
+ CallInstSet directCalls;
65
+ CallInstSet indirectCalls;
66
+ CallSiteID csId;
67
+ public:
68
+ /// Constructor
69
+ CallGraphEdge(CallGraphNode* s, CallGraphNode* d, CEDGEK kind, CallSiteID cs) :
70
+ GenericPTACallGraphEdgeTy(s, d, makeEdgeFlagWithInvokeID(kind, cs)), csId(cs)
71
+ {
72
+ }
73
+ /// Destructor
74
+ virtual ~CallGraphEdge()
75
+ {
76
+ }
77
+ /// Compute the unique edgeFlag value from edge kind and CallSiteID.
78
+ static inline GEdgeFlag makeEdgeFlagWithInvokeID(GEdgeKind k, CallSiteID cs)
79
+ {
80
+ return (cs << EdgeKindMaskBits) | k;
81
+ }
82
+ /// Get direct and indirect calls
83
+ //@{
84
+ inline CallSiteID getCallSiteID() const
85
+ {
86
+ return csId;
87
+ }
88
+ inline bool isDirectCallEdge() const
89
+ {
90
+ return !directCalls.empty() && indirectCalls.empty();
91
+ }
92
+ inline bool isIndirectCallEdge() const
93
+ {
94
+ return directCalls.empty() && !indirectCalls.empty();
95
+ }
96
+ inline CallInstSet& getDirectCalls()
97
+ {
98
+ return directCalls;
99
+ }
100
+ inline CallInstSet& getIndirectCalls()
101
+ {
102
+ return indirectCalls;
103
+ }
104
+ inline const CallInstSet& getDirectCalls() const
105
+ {
106
+ return directCalls;
107
+ }
108
+ inline const CallInstSet& getIndirectCalls() const
109
+ {
110
+ return indirectCalls;
111
+ }
112
+ //@}
113
+
114
+ /// Add direct and indirect callsite
115
+ //@{
116
+ void addDirectCallSite(const CallICFGNode* call);
117
+
118
+ void addInDirectCallSite(const CallICFGNode* call);
119
+ //@}
120
+
121
+ /// Iterators for direct and indirect callsites
122
+ //@{
123
+ inline CallInstSet::const_iterator directCallsBegin() const
124
+ {
125
+ return directCalls.begin();
126
+ }
127
+ inline CallInstSet::const_iterator directCallsEnd() const
128
+ {
129
+ return directCalls.end();
130
+ }
131
+
132
+ inline CallInstSet::const_iterator indirectCallsBegin() const
133
+ {
134
+ return indirectCalls.begin();
135
+ }
136
+ inline CallInstSet::const_iterator indirectCallsEnd() const
137
+ {
138
+ return indirectCalls.end();
139
+ }
140
+ //@}
141
+
142
+ /// ClassOf
143
+ //@{
144
+ static inline bool classof(const CallGraphEdge*)
145
+ {
146
+ return true;
147
+ }
148
+ static inline bool classof(const GenericPTACallGraphEdgeTy *edge)
149
+ {
150
+ return edge->getEdgeKind() == CallGraphEdge::CallRetEdge ||
151
+ edge->getEdgeKind() == CallGraphEdge::TDForkEdge ||
152
+ edge->getEdgeKind() == CallGraphEdge::TDJoinEdge;
153
+ }
154
+ //@}
155
+
156
+ /// Overloading operator << for dumping ICFG node ID
157
+ //@{
158
+ friend OutStream& operator<< (OutStream &o, const CallGraphEdge&edge)
159
+ {
160
+ o << edge.toString();
161
+ return o;
162
+ }
163
+ //@}
164
+
165
+ virtual const std::string toString() const;
166
+
167
+ typedef GenericNode<CallGraphNode, CallGraphEdge>::GEdgeSetTy CallGraphEdgeSet;
168
+
169
+ };
170
+
171
+ class FunObjVar;
172
+
173
+ /*
174
+ * Call Graph node representing a function
175
+ */
176
+ typedef GenericNode<CallGraphNode, CallGraphEdge> GenericPTACallGraphNodeTy;
177
+ class CallGraphNode : public GenericPTACallGraphNodeTy
178
+ {
179
+ private:
180
+ const FunObjVar* fun;
181
+
182
+ public:
183
+ /// Constructor
184
+ CallGraphNode(NodeID i, const FunObjVar* f) : GenericPTACallGraphNodeTy(i,CallNodeKd), fun(f)
185
+ {
186
+
187
+ }
188
+
189
+ const std::string &getName() const;
190
+
191
+ /// Get function of this call node
192
+ inline const FunObjVar* getFunction() const
193
+ {
194
+ return fun;
195
+ }
196
+
197
+ /// Return TRUE if this function can be reached from main.
198
+ bool isReachableFromProgEntry() const;
199
+
200
+
201
+ /// Overloading operator << for dumping ICFG node ID
202
+ //@{
203
+ friend OutStream& operator<< (OutStream &o, const CallGraphNode&node)
204
+ {
205
+ o << node.toString();
206
+ return o;
207
+ }
208
+ //@}
209
+
210
+ virtual const std::string toString() const;
211
+
212
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
213
+ //@{
214
+ static inline bool classof(const CallGraphNode*)
215
+ {
216
+ return true;
217
+ }
218
+
219
+ static inline bool classof(const GenericICFGNodeTy* node)
220
+ {
221
+ return node->getNodeKind() == CallNodeKd;
222
+ }
223
+
224
+ static inline bool classof(const SVFValue* node)
225
+ {
226
+ return node->getNodeKind() == CallNodeKd;
227
+ }
228
+ //@}
229
+ };
230
+
231
+ /*!
232
+ * Pointer Analysis Call Graph used internally for various pointer analysis
233
+ */
234
+ typedef GenericGraph<CallGraphNode, CallGraphEdge> GenericPTACallGraphTy;
235
+ class CallGraph : public GenericPTACallGraphTy
236
+ {
237
+
238
+ public:
239
+ typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
240
+ typedef Map<const FunObjVar*, CallGraphNode*> FunToCallGraphNodeMap;
241
+ typedef Map<const CallICFGNode*, CallGraphEdgeSet> CallInstToCallGraphEdgesMap;
242
+ typedef std::pair<const CallICFGNode*, const FunObjVar*> CallSitePair;
243
+ typedef Map<CallSitePair, CallSiteID> CallSiteToIdMap;
244
+ typedef Map<CallSiteID, CallSitePair> IdToCallSiteMap;
245
+ typedef Set<const FunObjVar*> FunctionSet;
246
+ typedef OrderedMap<const CallICFGNode*, FunctionSet> CallEdgeMap;
247
+ typedef CallGraphEdgeSet::iterator CallGraphEdgeIter;
248
+ typedef CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter;
249
+
250
+ enum CGEK
251
+ {
252
+ NormCallGraph, ThdCallGraph
253
+ };
254
+
255
+ private:
256
+ /// Indirect call map
257
+ CallEdgeMap indirectCallMap;
258
+
259
+ /// Call site information
260
+ static CallSiteToIdMap csToIdMap; ///< Map a pair of call instruction and callee to a callsite ID
261
+ static IdToCallSiteMap idToCSMap; ///< Map a callsite ID to a pair of call instruction and callee
262
+ static CallSiteID totalCallSiteNum; ///< CallSiteIDs, start from 1;
263
+
264
+ protected:
265
+ FunToCallGraphNodeMap funToCallGraphNodeMap; ///< Call Graph node map
266
+ CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap; ///< Map a call instruction to its corresponding call edges
267
+
268
+ NodeID callGraphNodeNum;
269
+ u32_t numOfResolvedIndCallEdge;
270
+ CGEK kind;
271
+
272
+ /// Clean up memory
273
+ void destroy();
274
+
275
+ protected:
276
+ /// Add CallSiteID
277
+ inline CallSiteID addCallSite(const CallICFGNode* cs, const FunObjVar* callee)
278
+ {
279
+ std::pair<const CallICFGNode*, const FunObjVar*> newCS(std::make_pair(cs, callee));
280
+ CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
281
+ //assert(it == csToIdMap.end() && "cannot add a callsite twice");
282
+ if(it == csToIdMap.end())
283
+ {
284
+ CallSiteID id = totalCallSiteNum++;
285
+ csToIdMap.insert(std::make_pair(newCS, id));
286
+ idToCSMap.insert(std::make_pair(id, newCS));
287
+ return id;
288
+ }
289
+ return it->second;
290
+ }
291
+
292
+ /// Add call graph edge
293
+ inline void addEdge(CallGraphEdge* edge)
294
+ {
295
+ edge->getDstNode()->addIncomingEdge(edge);
296
+ edge->getSrcNode()->addOutgoingEdge(edge);
297
+ }
298
+
299
+ public:
300
+ /// Constructor
301
+ CallGraph(CGEK k = NormCallGraph);
302
+
303
+ /// Copy constructor
304
+ CallGraph(const CallGraph& other);
305
+
306
+ /// Destructor
307
+ virtual ~CallGraph()
308
+ {
309
+ destroy();
310
+ }
311
+
312
+ /// Return type of this callgraph
313
+ inline CGEK getKind() const
314
+ {
315
+ return kind;
316
+ }
317
+
318
+ /// Get callees from an indirect callsite
319
+ //@{
320
+ inline CallEdgeMap& getIndCallMap()
321
+ {
322
+ return indirectCallMap;
323
+ }
324
+ inline bool hasIndCSCallees(const CallICFGNode* cs) const
325
+ {
326
+ return (indirectCallMap.find(cs) != indirectCallMap.end());
327
+ }
328
+ inline const FunctionSet& getIndCSCallees(const CallICFGNode* cs) const
329
+ {
330
+ CallEdgeMap::const_iterator it = indirectCallMap.find(cs);
331
+ assert(it!=indirectCallMap.end() && "not an indirect callsite!");
332
+ return it->second;
333
+ }
334
+ //@}
335
+ inline u32_t getTotalCallSiteNumber() const
336
+ {
337
+ return totalCallSiteNum;
338
+ }
339
+
340
+ inline u32_t getNumOfResolvedIndCallEdge() const
341
+ {
342
+ return numOfResolvedIndCallEdge;
343
+ }
344
+
345
+ inline const CallInstToCallGraphEdgesMap& getCallInstToCallGraphEdgesMap() const
346
+ {
347
+ return callinstToCallGraphEdgesMap;
348
+ }
349
+
350
+ /// Issue a warning if the function which has indirect call sites can not be reached from program entry.
351
+ void verifyCallGraph();
352
+
353
+ /// Add direct call edges
354
+ void addDirectCallGraphEdge(const CallICFGNode* call, const FunObjVar* callerFun, const FunObjVar* calleeFun);
355
+
356
+ void addCallGraphNode(const FunObjVar* fun);
357
+
358
+ /// Get call graph node
359
+ //@{
360
+
361
+ const CallGraphNode* getCallGraphNode(const std::string& name);
362
+
363
+ inline CallGraphNode* getCallGraphNode(NodeID id) const
364
+ {
365
+ return getGNode(id);
366
+ }
367
+ inline CallGraphNode* getCallGraphNode(const FunObjVar* fun) const
368
+ {
369
+ FunToCallGraphNodeMap::const_iterator it = funToCallGraphNodeMap.find(fun);
370
+ assert(it!=funToCallGraphNodeMap.end() && "call graph node not found!!");
371
+ return it->second;
372
+ }
373
+
374
+ //@}
375
+
376
+ /// Get CallSiteID
377
+ //@{
378
+ inline CallSiteID getCallSiteID(const CallICFGNode* cs, const FunObjVar* callee) const
379
+ {
380
+ CallSitePair newCS(std::make_pair(cs, callee));
381
+ CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
382
+ assert(it != csToIdMap.end() && "callsite id not found! This maybe a partially resolved callgraph, please check the indCallEdge limit");
383
+ return it->second;
384
+ }
385
+ inline bool hasCallSiteID(const CallICFGNode* cs, const FunObjVar* callee) const
386
+ {
387
+ CallSitePair newCS(std::make_pair(cs, callee));
388
+ CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
389
+ return it != csToIdMap.end();
390
+ }
391
+ inline const CallSitePair& getCallSitePair(CallSiteID id) const
392
+ {
393
+ IdToCallSiteMap::const_iterator it = idToCSMap.find(id);
394
+ assert(it != idToCSMap.end() && "cannot find call site for this CallSiteID");
395
+ return (it->second);
396
+ }
397
+ inline const CallICFGNode* getCallSite(CallSiteID id) const
398
+ {
399
+ return getCallSitePair(id).first;
400
+ }
401
+ const FunObjVar* getCallerOfCallSite(CallSiteID id) const;
402
+ inline const FunObjVar* getCalleeOfCallSite(CallSiteID id) const
403
+ {
404
+ return getCallSitePair(id).second;
405
+ }
406
+ //@}
407
+ /// Whether we have already created this call graph edge
408
+ CallGraphEdge* hasGraphEdge(CallGraphNode* src, CallGraphNode* dst,
409
+ CallGraphEdge::CEDGEK kind, CallSiteID csId) const;
410
+ /// Get call graph edge via nodes
411
+ CallGraphEdge* getGraphEdge(CallGraphNode* src, CallGraphNode* dst,
412
+ CallGraphEdge::CEDGEK kind, CallSiteID csId);
413
+
414
+ /// Get all callees for a callsite
415
+ inline void getCallees(const CallICFGNode* cs, FunctionSet& callees)
416
+ {
417
+ if(hasCallGraphEdge(cs))
418
+ {
419
+ for (CallGraphEdgeSet::const_iterator it = getCallEdgeBegin(cs), eit =
420
+ getCallEdgeEnd(cs); it != eit; ++it)
421
+ {
422
+ callees.insert((*it)->getDstNode()->getFunction());
423
+ }
424
+ }
425
+ }
426
+
427
+ /// Get call graph edge via call instruction
428
+ //@{
429
+ /// whether this call instruction has a valid call graph edge
430
+ inline bool hasCallGraphEdge(const CallICFGNode* inst) const
431
+ {
432
+ return callinstToCallGraphEdgesMap.find(inst)!=callinstToCallGraphEdgesMap.end();
433
+ }
434
+ inline CallGraphEdgeSet::const_iterator getCallEdgeBegin(const CallICFGNode* inst) const
435
+ {
436
+ CallInstToCallGraphEdgesMap::const_iterator it = callinstToCallGraphEdgesMap.find(inst);
437
+ assert(it!=callinstToCallGraphEdgesMap.end()
438
+ && "call instruction does not have a valid callee");
439
+ return it->second.begin();
440
+ }
441
+ inline CallGraphEdgeSet::const_iterator getCallEdgeEnd(const CallICFGNode* inst) const
442
+ {
443
+ CallInstToCallGraphEdgesMap::const_iterator it = callinstToCallGraphEdgesMap.find(inst);
444
+ assert(it!=callinstToCallGraphEdgesMap.end()
445
+ && "call instruction does not have a valid callee");
446
+ return it->second.end();
447
+ }
448
+ //@}
449
+
450
+
451
+ /// Add indirect call edges
452
+ //@{
453
+ void addIndirectCallGraphEdge(const CallICFGNode* cs,const FunObjVar* callerFun, const FunObjVar* calleeFun);
454
+ //@}
455
+
456
+ /// Get callsites invoking the callee
457
+ //@{
458
+ void getAllCallSitesInvokingCallee(const FunObjVar* callee, CallGraphEdge::CallInstSet& csSet);
459
+ void getDirCallSitesInvokingCallee(const FunObjVar* callee, CallGraphEdge::CallInstSet& csSet);
460
+ void getIndCallSitesInvokingCallee(const FunObjVar* callee, CallGraphEdge::CallInstSet& csSet);
461
+ //@}
462
+
463
+ /// Whether its reachable between two functions
464
+ bool isReachableBetweenFunctions(const FunObjVar* srcFn, const FunObjVar* dstFn) const;
465
+
466
+ /// Dump the graph
467
+ void dump(const std::string& filename);
468
+
469
+ /// View the graph from the debugger
470
+ void view();
471
+ };
472
+
473
+ } // End namespace SVF
474
+
475
+ namespace SVF
476
+ {
477
+ /* !
478
+ * GenericGraphTraits specializations for generic graph algorithms.
479
+ * Provide graph traits for traversing from a constraint node using standard graph traversals.
480
+ */
481
+ template<> struct GenericGraphTraits<SVF::CallGraphNode*> : public GenericGraphTraits<SVF::GenericNode<SVF::CallGraphNode,SVF::CallGraphEdge>* >
482
+ {
483
+ };
484
+
485
+ /// Inverse GenericGraphTraits specializations for call graph node, it is used for inverse traversal.
486
+ template<>
487
+ struct GenericGraphTraits<Inverse<SVF::CallGraphNode*> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::CallGraphNode,SVF::CallGraphEdge>* > >
488
+ {
489
+ };
490
+
491
+ template<> struct GenericGraphTraits<SVF::CallGraph*> : public GenericGraphTraits<SVF::GenericGraph<SVF::CallGraphNode,SVF::CallGraphEdge>* >
492
+ {
493
+ typedef SVF::CallGraphNode*NodeRef;
494
+ };
495
+
496
+ } // End namespace llvm
497
+
498
+ #endif /* PTACALLGRAPH_H_ */