svf-tools 1.0.1004 → 1.0.1006
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.
- package/package.json +1 -1
- package/svf/include/AE/Svfexe/AbstractInterpretation.h +1 -1
- package/svf/include/DDA/DDAVFSolver.h +5 -5
- package/svf/include/Graphs/CallGraph.h +25 -256
- package/svf/include/Graphs/ICFG.h +2 -2
- package/svf/include/Graphs/PTACallGraph.h +494 -0
- package/svf/include/Graphs/ThreadCallGraph.h +27 -27
- package/svf/include/Graphs/VFG.h +5 -5
- package/svf/include/MSSA/MemRegion.h +4 -4
- package/svf/include/MTA/LockAnalysis.h +1 -1
- package/svf/include/MTA/MHP.h +2 -2
- package/svf/include/MTA/TCT.h +6 -6
- package/svf/include/MemoryModel/PointerAnalysis.h +9 -9
- package/svf/include/SABER/SaberSVFGBuilder.h +1 -1
- package/svf/include/SABER/SrcSnkDDA.h +2 -2
- package/svf/include/SVFIR/SVFIR.h +1 -0
- package/svf/include/Util/CallGraphBuilder.h +5 -1
- package/svf/lib/DDA/DDAClient.cpp +2 -2
- package/svf/lib/Graphs/CallGraph.cpp +20 -251
- package/svf/lib/Graphs/ICFG.cpp +8 -8
- package/svf/lib/Graphs/PTACallGraph.cpp +418 -0
- package/svf/lib/Graphs/SVFG.cpp +4 -4
- package/svf/lib/Graphs/SVFGReadWrite.cpp +4 -4
- package/svf/lib/Graphs/SVFGStat.cpp +1 -1
- package/svf/lib/Graphs/ThreadCallGraph.cpp +11 -11
- package/svf/lib/Graphs/VFG.cpp +1 -1
- package/svf/lib/MSSA/MemRegion.cpp +7 -6
- package/svf/lib/MSSA/MemSSA.cpp +1 -0
- package/svf/lib/MSSA/SVFGBuilder.cpp +2 -0
- package/svf/lib/MTA/LockAnalysis.cpp +18 -18
- package/svf/lib/MTA/MHP.cpp +19 -19
- package/svf/lib/MTA/TCT.cpp +25 -24
- package/svf/lib/MemoryModel/PointerAnalysis.cpp +3 -3
- package/svf/lib/SABER/LeakChecker.cpp +4 -4
- package/svf/lib/SABER/SaberCondAllocator.cpp +1 -0
- package/svf/lib/SABER/SaberSVFGBuilder.cpp +3 -3
- package/svf/lib/SVFIR/SVFIR.cpp +1 -0
- package/svf/lib/Util/CallGraphBuilder.cpp +8 -0
- package/svf/lib/Util/PTAStat.cpp +12 -12
- package/svf/lib/Util/SVFStat.cpp +1 -0
- package/svf/lib/Util/SVFUtil.cpp +1 -0
- package/svf/lib/Util/ThreadAPI.cpp +1 -1
- package/svf/lib/WPA/VersionedFlowSensitive.cpp +1 -1
- package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +1 -1
- package/svf-llvm/lib/LLVMModule.cpp +1 -1
- package/svf-llvm/lib/LLVMUtil.cpp +1 -1
- package/svf-llvm/lib/SVFIRBuilder.cpp +5 -5
- package/svf-llvm/tools/AE/ae.cpp +1 -1
- package/svf-llvm/tools/Example/svf-ex.cpp +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1006",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -49,8 +49,8 @@ class DDAVFSolver
|
|
|
49
49
|
friend class DDAStat;
|
|
50
50
|
public:
|
|
51
51
|
typedef SCCDetection<SVFG*> SVFGSCC;
|
|
52
|
-
typedef SCCDetection<
|
|
53
|
-
typedef
|
|
52
|
+
typedef SCCDetection<PTACallGraph*> CallGraphSCC;
|
|
53
|
+
typedef PTACallGraphEdge::CallInstSet CallInstSet;
|
|
54
54
|
typedef SVFIR::CallSiteSet CallSiteSet;
|
|
55
55
|
typedef OrderedSet<DPIm> DPTItemSet;
|
|
56
56
|
typedef OrderedMap<DPIm, CPtSet> DPImToCPtSetMap;
|
|
@@ -624,7 +624,7 @@ protected:
|
|
|
624
624
|
return (getSVFGSCCRepNode(edge->getSrcID()) == getSVFGSCCRepNode(edge->getDstID()));
|
|
625
625
|
}
|
|
626
626
|
/// Set callgraph
|
|
627
|
-
inline void setCallGraph (
|
|
627
|
+
inline void setCallGraph (PTACallGraph* cg)
|
|
628
628
|
{
|
|
629
629
|
_callGraph = cg;
|
|
630
630
|
}
|
|
@@ -775,8 +775,8 @@ protected:
|
|
|
775
775
|
SVFG* _svfg; ///< SVFG
|
|
776
776
|
AndersenWaveDiff* _ander; ///< Andersen's analysis
|
|
777
777
|
NodeBS candidateQueries; ///< candidate pointers;
|
|
778
|
-
|
|
779
|
-
CallGraphSCC* _callGraphSCC; ///< SCC for
|
|
778
|
+
PTACallGraph* _callGraph; ///< PTACallGraph
|
|
779
|
+
CallGraphSCC* _callGraphSCC; ///< SCC for PTACallGraph
|
|
780
780
|
SVFGSCC* _svfgSCC; ///< SCC for SVFG
|
|
781
781
|
DPTItemSet backwardVisited; ///< visited map during backward traversing
|
|
782
782
|
DPImToCPtSetMap dpmToTLCPtSetMap; ///< points-to caching map for top-level vars
|
|
@@ -53,68 +53,23 @@ class CallGraphEdge : public GenericCallGraphEdgeTy
|
|
|
53
53
|
|
|
54
54
|
public:
|
|
55
55
|
typedef Set<const CallICFGNode*> CallInstSet;
|
|
56
|
-
enum CEDGEK
|
|
57
|
-
{
|
|
58
|
-
CallRetEdge,TDForkEdge,TDJoinEdge,HareParForEdge
|
|
59
|
-
};
|
|
60
|
-
|
|
61
56
|
|
|
62
57
|
private:
|
|
63
58
|
CallInstSet directCalls;
|
|
64
|
-
CallInstSet indirectCalls;
|
|
65
|
-
CallSiteID csId;
|
|
66
59
|
public:
|
|
67
60
|
/// Constructor
|
|
68
|
-
CallGraphEdge(CallGraphNode* s, CallGraphNode* d,
|
|
69
|
-
GenericCallGraphEdgeTy(s, d,
|
|
61
|
+
CallGraphEdge(CallGraphNode* s, CallGraphNode* d, const CallICFGNode* icfgNode) :
|
|
62
|
+
GenericCallGraphEdgeTy(s, d, icfgNode->getId())
|
|
70
63
|
{
|
|
71
64
|
}
|
|
72
65
|
/// Destructor
|
|
73
66
|
virtual ~CallGraphEdge()
|
|
74
67
|
{
|
|
75
68
|
}
|
|
76
|
-
/// Compute the unique edgeFlag value from edge kind and CallSiteID.
|
|
77
|
-
static inline GEdgeFlag makeEdgeFlagWithInvokeID(GEdgeKind k, CallSiteID cs)
|
|
78
|
-
{
|
|
79
|
-
return (cs << EdgeKindMaskBits) | k;
|
|
80
|
-
}
|
|
81
|
-
/// Get direct and indirect calls
|
|
82
|
-
//@{
|
|
83
|
-
inline CallSiteID getCallSiteID() const
|
|
84
|
-
{
|
|
85
|
-
return csId;
|
|
86
|
-
}
|
|
87
|
-
inline bool isDirectCallEdge() const
|
|
88
|
-
{
|
|
89
|
-
return !directCalls.empty() && indirectCalls.empty();
|
|
90
|
-
}
|
|
91
|
-
inline bool isIndirectCallEdge() const
|
|
92
|
-
{
|
|
93
|
-
return directCalls.empty() && !indirectCalls.empty();
|
|
94
|
-
}
|
|
95
|
-
inline CallInstSet& getDirectCalls()
|
|
96
|
-
{
|
|
97
|
-
return directCalls;
|
|
98
|
-
}
|
|
99
|
-
inline CallInstSet& getIndirectCalls()
|
|
100
|
-
{
|
|
101
|
-
return indirectCalls;
|
|
102
|
-
}
|
|
103
|
-
inline const CallInstSet& getDirectCalls() const
|
|
104
|
-
{
|
|
105
|
-
return directCalls;
|
|
106
|
-
}
|
|
107
|
-
inline const CallInstSet& getIndirectCalls() const
|
|
108
|
-
{
|
|
109
|
-
return indirectCalls;
|
|
110
|
-
}
|
|
111
|
-
//@}
|
|
112
69
|
|
|
113
|
-
/// Add direct
|
|
70
|
+
/// Add direct callsite
|
|
114
71
|
//@{
|
|
115
72
|
void addDirectCallSite(const CallICFGNode* call);
|
|
116
|
-
|
|
117
|
-
void addInDirectCallSite(const CallICFGNode* call);
|
|
118
73
|
//@}
|
|
119
74
|
|
|
120
75
|
/// Iterators for direct and indirect callsites
|
|
@@ -127,15 +82,6 @@ public:
|
|
|
127
82
|
{
|
|
128
83
|
return directCalls.end();
|
|
129
84
|
}
|
|
130
|
-
|
|
131
|
-
inline CallInstSet::const_iterator indirectCallsBegin() const
|
|
132
|
-
{
|
|
133
|
-
return indirectCalls.begin();
|
|
134
|
-
}
|
|
135
|
-
inline CallInstSet::const_iterator indirectCallsEnd() const
|
|
136
|
-
{
|
|
137
|
-
return indirectCalls.end();
|
|
138
|
-
}
|
|
139
85
|
//@}
|
|
140
86
|
|
|
141
87
|
/// ClassOf
|
|
@@ -144,17 +90,11 @@ public:
|
|
|
144
90
|
{
|
|
145
91
|
return true;
|
|
146
92
|
}
|
|
147
|
-
static inline bool classof(const GenericCallGraphEdgeTy *edge)
|
|
148
|
-
{
|
|
149
|
-
return edge->getEdgeKind() == CallGraphEdge::CallRetEdge ||
|
|
150
|
-
edge->getEdgeKind() == CallGraphEdge::TDForkEdge ||
|
|
151
|
-
edge->getEdgeKind() == CallGraphEdge::TDJoinEdge;
|
|
152
|
-
}
|
|
153
93
|
//@}
|
|
154
94
|
|
|
155
95
|
/// Overloading operator << for dumping ICFG node ID
|
|
156
96
|
//@{
|
|
157
|
-
friend OutStream& operator<< (OutStream &o, const CallGraphEdge
|
|
97
|
+
friend OutStream& operator<< (OutStream &o, const CallGraphEdge&edge)
|
|
158
98
|
{
|
|
159
99
|
o << edge.toString();
|
|
160
100
|
return o;
|
|
@@ -163,22 +103,16 @@ public:
|
|
|
163
103
|
|
|
164
104
|
virtual const std::string toString() const;
|
|
165
105
|
|
|
166
|
-
typedef GenericNode<CallGraphNode,CallGraphEdge>::GEdgeSetTy CallGraphEdgeSet;
|
|
106
|
+
typedef GenericNode<CallGraphNode, CallGraphEdge>::GEdgeSetTy CallGraphEdgeSet;
|
|
167
107
|
|
|
168
108
|
};
|
|
169
109
|
|
|
170
110
|
/*
|
|
171
111
|
* Call Graph node representing a function
|
|
172
112
|
*/
|
|
173
|
-
typedef GenericNode<CallGraphNode,CallGraphEdge> GenericCallGraphNodeTy;
|
|
113
|
+
typedef GenericNode<CallGraphNode, CallGraphEdge> GenericCallGraphNodeTy;
|
|
174
114
|
class CallGraphNode : public GenericCallGraphNodeTy
|
|
175
115
|
{
|
|
176
|
-
|
|
177
|
-
public:
|
|
178
|
-
typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
|
|
179
|
-
typedef CallGraphEdge::CallGraphEdgeSet::iterator iterator;
|
|
180
|
-
typedef CallGraphEdge::CallGraphEdgeSet::const_iterator const_iterator;
|
|
181
|
-
|
|
182
116
|
private:
|
|
183
117
|
const SVFFunction* fun;
|
|
184
118
|
|
|
@@ -186,7 +120,6 @@ public:
|
|
|
186
120
|
/// Constructor
|
|
187
121
|
CallGraphNode(NodeID i, const SVFFunction* f) : GenericCallGraphNodeTy(i,CallNodeKd), fun(f)
|
|
188
122
|
{
|
|
189
|
-
|
|
190
123
|
}
|
|
191
124
|
|
|
192
125
|
inline const std::string &getName() const
|
|
@@ -200,13 +133,10 @@ public:
|
|
|
200
133
|
return fun;
|
|
201
134
|
}
|
|
202
135
|
|
|
203
|
-
/// Return TRUE if this function can be reached from main.
|
|
204
|
-
bool isReachableFromProgEntry() const;
|
|
205
|
-
|
|
206
136
|
|
|
207
137
|
/// Overloading operator << for dumping ICFG node ID
|
|
208
138
|
//@{
|
|
209
|
-
friend OutStream& operator<< (OutStream &o, const CallGraphNode
|
|
139
|
+
friend OutStream& operator<< (OutStream &o, const CallGraphNode&node)
|
|
210
140
|
{
|
|
211
141
|
o << node.toString();
|
|
212
142
|
return o;
|
|
@@ -217,7 +147,7 @@ public:
|
|
|
217
147
|
|
|
218
148
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
219
149
|
//@{
|
|
220
|
-
static inline bool classof(const CallGraphNode
|
|
150
|
+
static inline bool classof(const CallGraphNode*)
|
|
221
151
|
{
|
|
222
152
|
return true;
|
|
223
153
|
}
|
|
@@ -237,53 +167,38 @@ public:
|
|
|
237
167
|
/*!
|
|
238
168
|
* Pointer Analysis Call Graph used internally for various pointer analysis
|
|
239
169
|
*/
|
|
240
|
-
typedef GenericGraph<CallGraphNode,CallGraphEdge> GenericCallGraphTy;
|
|
170
|
+
typedef GenericGraph<CallGraphNode, CallGraphEdge> GenericCallGraphTy;
|
|
241
171
|
class CallGraph : public GenericCallGraphTy
|
|
242
172
|
{
|
|
173
|
+
friend class PTACallGraph;
|
|
243
174
|
|
|
244
175
|
public:
|
|
245
176
|
typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
|
|
246
|
-
typedef Map<const SVFFunction*, CallGraphNode
|
|
177
|
+
typedef Map<const SVFFunction*, CallGraphNode*> FunToCallGraphNodeMap;
|
|
247
178
|
typedef Map<const CallICFGNode*, CallGraphEdgeSet> CallInstToCallGraphEdgesMap;
|
|
248
|
-
typedef std::pair<const CallICFGNode*, const SVFFunction*> CallSitePair;
|
|
249
|
-
typedef Map<CallSitePair, CallSiteID> CallSiteToIdMap;
|
|
250
|
-
typedef Map<CallSiteID, CallSitePair> IdToCallSiteMap;
|
|
251
179
|
typedef Set<const SVFFunction*> FunctionSet;
|
|
252
180
|
typedef OrderedMap<const CallICFGNode*, FunctionSet> CallEdgeMap;
|
|
253
|
-
typedef CallGraphEdgeSet::iterator CallGraphEdgeIter;
|
|
254
|
-
typedef CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter;
|
|
255
|
-
|
|
256
|
-
enum CGEK
|
|
257
|
-
{
|
|
258
|
-
NormCallGraph, ThdCallGraph
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
private:
|
|
262
|
-
/// Indirect call map
|
|
263
|
-
CallEdgeMap indirectCallMap;
|
|
264
|
-
|
|
265
|
-
/// Call site information
|
|
266
|
-
static CallSiteToIdMap csToIdMap; ///< Map a pair of call instruction and callee to a callsite ID
|
|
267
|
-
static IdToCallSiteMap idToCSMap; ///< Map a callsite ID to a pair of call instruction and callee
|
|
268
|
-
static CallSiteID totalCallSiteNum; ///< CallSiteIDs, start from 1;
|
|
269
181
|
|
|
270
182
|
protected:
|
|
271
183
|
FunToCallGraphNodeMap funToCallGraphNodeMap; ///< Call Graph node map
|
|
272
184
|
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap; ///< Map a call instruction to its corresponding call edges
|
|
273
185
|
|
|
274
186
|
NodeID callGraphNodeNum;
|
|
275
|
-
u32_t numOfResolvedIndCallEdge;
|
|
276
|
-
CGEK kind;
|
|
277
187
|
|
|
278
188
|
/// Clean up memory
|
|
279
189
|
void destroy();
|
|
280
190
|
|
|
191
|
+
/// Add call graph edge
|
|
192
|
+
inline void addEdge(CallGraphEdge* edge)
|
|
193
|
+
{
|
|
194
|
+
edge->getDstNode()->addIncomingEdge(edge);
|
|
195
|
+
edge->getSrcNode()->addOutgoingEdge(edge);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
281
199
|
public:
|
|
282
200
|
/// Constructor
|
|
283
|
-
CallGraph(
|
|
284
|
-
|
|
285
|
-
/// Copy constructor
|
|
286
|
-
CallGraph(const CallGraph& other);
|
|
201
|
+
CallGraph();
|
|
287
202
|
|
|
288
203
|
void addCallGraphNode(const SVFFunction* fun);
|
|
289
204
|
|
|
@@ -293,47 +208,6 @@ public:
|
|
|
293
208
|
destroy();
|
|
294
209
|
}
|
|
295
210
|
|
|
296
|
-
/// Return type of this callgraph
|
|
297
|
-
inline CGEK getKind() const
|
|
298
|
-
{
|
|
299
|
-
return kind;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/// Get callees from an indirect callsite
|
|
303
|
-
//@{
|
|
304
|
-
inline CallEdgeMap& getIndCallMap()
|
|
305
|
-
{
|
|
306
|
-
return indirectCallMap;
|
|
307
|
-
}
|
|
308
|
-
inline bool hasIndCSCallees(const CallICFGNode* cs) const
|
|
309
|
-
{
|
|
310
|
-
return (indirectCallMap.find(cs) != indirectCallMap.end());
|
|
311
|
-
}
|
|
312
|
-
inline const FunctionSet& getIndCSCallees(const CallICFGNode* cs) const
|
|
313
|
-
{
|
|
314
|
-
CallEdgeMap::const_iterator it = indirectCallMap.find(cs);
|
|
315
|
-
assert(it!=indirectCallMap.end() && "not an indirect callsite!");
|
|
316
|
-
return it->second;
|
|
317
|
-
}
|
|
318
|
-
//@}
|
|
319
|
-
inline u32_t getTotalCallSiteNumber() const
|
|
320
|
-
{
|
|
321
|
-
return totalCallSiteNum;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
inline u32_t getNumOfResolvedIndCallEdge() const
|
|
325
|
-
{
|
|
326
|
-
return numOfResolvedIndCallEdge;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
inline const CallInstToCallGraphEdgesMap& getCallInstToCallGraphEdgesMap() const
|
|
330
|
-
{
|
|
331
|
-
return callinstToCallGraphEdgesMap;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/// Issue a warning if the function which has indirect call sites can not be reached from program entry.
|
|
335
|
-
void verifyCallGraph();
|
|
336
|
-
|
|
337
211
|
/// Get call graph node
|
|
338
212
|
//@{
|
|
339
213
|
inline CallGraphNode* getCallGraphNode(NodeID id) const
|
|
@@ -349,117 +223,12 @@ public:
|
|
|
349
223
|
|
|
350
224
|
//@}
|
|
351
225
|
|
|
352
|
-
/// Add/Get CallSiteID
|
|
353
|
-
//@{
|
|
354
|
-
inline CallSiteID addCallSite(const CallICFGNode* cs, const SVFFunction* callee)
|
|
355
|
-
{
|
|
356
|
-
std::pair<const CallICFGNode*, const SVFFunction*> newCS(std::make_pair(cs, callee));
|
|
357
|
-
CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
|
|
358
|
-
//assert(it == csToIdMap.end() && "cannot add a callsite twice");
|
|
359
|
-
if(it == csToIdMap.end())
|
|
360
|
-
{
|
|
361
|
-
CallSiteID id = totalCallSiteNum++;
|
|
362
|
-
csToIdMap.insert(std::make_pair(newCS, id));
|
|
363
|
-
idToCSMap.insert(std::make_pair(id, newCS));
|
|
364
|
-
return id;
|
|
365
|
-
}
|
|
366
|
-
return it->second;
|
|
367
|
-
}
|
|
368
|
-
inline CallSiteID getCallSiteID(const CallICFGNode* cs, const SVFFunction* callee) const
|
|
369
|
-
{
|
|
370
|
-
CallSitePair newCS(std::make_pair(cs, callee));
|
|
371
|
-
CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
|
|
372
|
-
assert(it != csToIdMap.end() && "callsite id not found! This maybe a partially resolved callgraph, please check the indCallEdge limit");
|
|
373
|
-
return it->second;
|
|
374
|
-
}
|
|
375
|
-
inline bool hasCallSiteID(const CallICFGNode* cs, const SVFFunction* callee) const
|
|
376
|
-
{
|
|
377
|
-
CallSitePair newCS(std::make_pair(cs, callee));
|
|
378
|
-
CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
|
|
379
|
-
return it != csToIdMap.end();
|
|
380
|
-
}
|
|
381
|
-
inline const CallSitePair& getCallSitePair(CallSiteID id) const
|
|
382
|
-
{
|
|
383
|
-
IdToCallSiteMap::const_iterator it = idToCSMap.find(id);
|
|
384
|
-
assert(it != idToCSMap.end() && "cannot find call site for this CallSiteID");
|
|
385
|
-
return (it->second);
|
|
386
|
-
}
|
|
387
|
-
inline const CallICFGNode* getCallSite(CallSiteID id) const
|
|
388
|
-
{
|
|
389
|
-
return getCallSitePair(id).first;
|
|
390
|
-
}
|
|
391
|
-
inline const SVFFunction* getCallerOfCallSite(CallSiteID id) const
|
|
392
|
-
{
|
|
393
|
-
return getCallSite(id)->getCaller();
|
|
394
|
-
}
|
|
395
|
-
inline const SVFFunction* getCalleeOfCallSite(CallSiteID id) const
|
|
396
|
-
{
|
|
397
|
-
return getCallSitePair(id).second;
|
|
398
|
-
}
|
|
399
|
-
//@}
|
|
400
226
|
/// Whether we have already created this call graph edge
|
|
401
|
-
CallGraphEdge* hasGraphEdge(CallGraphNode* src, CallGraphNode* dst,
|
|
402
|
-
|
|
403
|
-
CallGraphEdge* getGraphEdge(CallGraphNode* src, CallGraphNode* dst,CallGraphEdge::CEDGEK kind, CallSiteID csId);
|
|
404
|
-
|
|
405
|
-
/// Get all callees for a callsite
|
|
406
|
-
inline void getCallees(const CallICFGNode* cs, FunctionSet& callees)
|
|
407
|
-
{
|
|
408
|
-
if(hasCallGraphEdge(cs))
|
|
409
|
-
{
|
|
410
|
-
for (CallGraphEdgeSet::const_iterator it = getCallEdgeBegin(cs), eit =
|
|
411
|
-
getCallEdgeEnd(cs); it != eit; ++it)
|
|
412
|
-
{
|
|
413
|
-
callees.insert((*it)->getDstNode()->getFunction());
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/// Get call graph edge via call instruction
|
|
419
|
-
//@{
|
|
420
|
-
/// whether this call instruction has a valid call graph edge
|
|
421
|
-
inline bool hasCallGraphEdge(const CallICFGNode* inst) const
|
|
422
|
-
{
|
|
423
|
-
return callinstToCallGraphEdgesMap.find(inst)!=callinstToCallGraphEdgesMap.end();
|
|
424
|
-
}
|
|
425
|
-
inline CallGraphEdgeSet::const_iterator getCallEdgeBegin(const CallICFGNode* inst) const
|
|
426
|
-
{
|
|
427
|
-
CallInstToCallGraphEdgesMap::const_iterator it = callinstToCallGraphEdgesMap.find(inst);
|
|
428
|
-
assert(it!=callinstToCallGraphEdgesMap.end()
|
|
429
|
-
&& "call instruction does not have a valid callee");
|
|
430
|
-
return it->second.begin();
|
|
431
|
-
}
|
|
432
|
-
inline CallGraphEdgeSet::const_iterator getCallEdgeEnd(const CallICFGNode* inst) const
|
|
433
|
-
{
|
|
434
|
-
CallInstToCallGraphEdgesMap::const_iterator it = callinstToCallGraphEdgesMap.find(inst);
|
|
435
|
-
assert(it!=callinstToCallGraphEdgesMap.end()
|
|
436
|
-
&& "call instruction does not have a valid callee");
|
|
437
|
-
return it->second.end();
|
|
438
|
-
}
|
|
439
|
-
//@}
|
|
440
|
-
/// Add call graph edge
|
|
441
|
-
inline void addEdge(CallGraphEdge* edge)
|
|
442
|
-
{
|
|
443
|
-
edge->getDstNode()->addIncomingEdge(edge);
|
|
444
|
-
edge->getSrcNode()->addOutgoingEdge(edge);
|
|
445
|
-
}
|
|
227
|
+
CallGraphEdge* hasGraphEdge(CallGraphNode* src, CallGraphNode* dst,
|
|
228
|
+
const CallICFGNode* callIcfgNode) const;
|
|
446
229
|
|
|
447
|
-
/// Add direct
|
|
448
|
-
//@{
|
|
230
|
+
/// Add direct call edges
|
|
449
231
|
void addDirectCallGraphEdge(const CallICFGNode* call, const SVFFunction* callerFun, const SVFFunction* calleeFun);
|
|
450
|
-
void addIndirectCallGraphEdge(const CallICFGNode* cs,const SVFFunction* callerFun, const SVFFunction* calleeFun);
|
|
451
|
-
//@}
|
|
452
|
-
|
|
453
|
-
/// Get callsites invoking the callee
|
|
454
|
-
//@{
|
|
455
|
-
void getAllCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet);
|
|
456
|
-
void getDirCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet);
|
|
457
|
-
void getIndCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet);
|
|
458
|
-
//@}
|
|
459
|
-
|
|
460
|
-
/// Whether its reachable between two functions
|
|
461
|
-
bool isReachableBetweenFunctions(const SVFFunction* srcFn, const SVFFunction* dstFn) const;
|
|
462
|
-
|
|
463
232
|
/// Dump the graph
|
|
464
233
|
void dump(const std::string& filename);
|
|
465
234
|
|
|
@@ -481,13 +250,13 @@ template<> struct GenericGraphTraits<SVF::CallGraphNode*> : public GenericGraphT
|
|
|
481
250
|
|
|
482
251
|
/// Inverse GenericGraphTraits specializations for call graph node, it is used for inverse traversal.
|
|
483
252
|
template<>
|
|
484
|
-
struct GenericGraphTraits<Inverse<SVF::CallGraphNode
|
|
253
|
+
struct GenericGraphTraits<Inverse<SVF::CallGraphNode*> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::CallGraphNode,SVF::CallGraphEdge>* > >
|
|
485
254
|
{
|
|
486
255
|
};
|
|
487
256
|
|
|
488
257
|
template<> struct GenericGraphTraits<SVF::CallGraph*> : public GenericGraphTraits<SVF::GenericGraph<SVF::CallGraphNode,SVF::CallGraphEdge>* >
|
|
489
258
|
{
|
|
490
|
-
typedef SVF::CallGraphNode
|
|
259
|
+
typedef SVF::CallGraphNode*NodeRef;
|
|
491
260
|
};
|
|
492
261
|
|
|
493
262
|
} // End namespace llvm
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
namespace SVF
|
|
39
39
|
{
|
|
40
40
|
|
|
41
|
-
class
|
|
41
|
+
class PTACallGraph;
|
|
42
42
|
|
|
43
43
|
/*!
|
|
44
44
|
* Interprocedural Control-Flow Graph (ICFG)
|
|
@@ -111,7 +111,7 @@ public:
|
|
|
111
111
|
void view();
|
|
112
112
|
|
|
113
113
|
/// update ICFG for indirect calls
|
|
114
|
-
void updateCallGraph(
|
|
114
|
+
void updateCallGraph(PTACallGraph* callgraph);
|
|
115
115
|
|
|
116
116
|
/// Whether node is in a loop
|
|
117
117
|
inline bool isInLoop(const ICFGNode *node)
|