svf-tools 1.0.993 → 1.0.995
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/Graphs/CDG.h +18 -1
- package/svf/include/Graphs/CFLGraph.h +19 -1
- package/svf/include/Graphs/CHG.h +19 -1
- package/svf/include/Graphs/CallGraph.h +19 -1
- package/svf/include/Graphs/ConsGNode.h +19 -1
- package/svf/include/Graphs/GenericGraph.h +243 -17
- package/svf/include/Graphs/ICFG.h +0 -96
- package/svf/include/Graphs/ICFGNode.h +55 -22
- package/svf/include/Graphs/SVFG.h +2 -2
- package/svf/include/Graphs/SVFGNode.h +5 -17
- package/svf/include/Graphs/SVFGOPT.h +2 -1
- package/svf/include/Graphs/ThreadCallGraph.h +5 -4
- package/svf/include/Graphs/VFG.h +2 -2
- package/svf/include/Graphs/VFGNode.h +99 -26
- package/svf/include/MTA/TCT.h +19 -1
- package/svf/include/MemoryModel/PointerAnalysis.h +1 -1
- package/svf/include/MemoryModel/PointerAnalysisImpl.h +4 -0
- package/svf/include/SABER/SaberCondAllocator.h +2 -2
- package/svf/include/SVFIR/SVFFileSystem.h +1 -1
- package/svf/include/SVFIR/SVFIR.h +2 -2
- package/svf/include/SVFIR/SVFVariables.h +68 -38
- package/svf/include/SVFIR/SymbolTableInfo.h +11 -1
- package/svf/include/Util/SVFUtil.h +1 -1
- package/svf/include/Util/ThreadAPI.h +8 -2
- package/svf/include/WPA/Andersen.h +26 -13
- package/svf/include/WPA/Steensgaard.h +10 -20
- package/svf/include/WPA/TypeAnalysis.h +10 -3
- package/svf/lib/AE/Svfexe/AEDetector.cpp +4 -2
- package/svf/lib/AE/Svfexe/AbsExtAPI.cpp +10 -12
- package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +2 -0
- package/svf/lib/DDA/ContextDDA.cpp +12 -8
- package/svf/lib/Graphs/ICFG.cpp +9 -93
- package/svf/lib/Graphs/SVFG.cpp +1 -1
- package/svf/lib/Graphs/ThreadCallGraph.cpp +10 -2
- package/svf/lib/Graphs/VFG.cpp +2 -4
- package/svf/lib/MSSA/MemRegion.cpp +2 -2
- package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +37 -0
- package/svf/lib/SABER/LeakChecker.cpp +1 -2
- package/svf/lib/SABER/SaberCondAllocator.cpp +13 -16
- package/svf/lib/SABER/SaberSVFGBuilder.cpp +2 -2
- package/svf/lib/SVFIR/SVFFileSystem.cpp +0 -6
- package/svf/lib/SVFIR/SVFVariables.cpp +3 -0
- package/svf/lib/SVFIR/SymbolTableInfo.cpp +3 -2
- package/svf/lib/Util/ThreadAPI.cpp +15 -5
- package/svf/lib/WPA/Andersen.cpp +205 -151
- package/svf/lib/WPA/Steensgaard.cpp +1 -163
- package/svf-llvm/include/SVF-LLVM/DCHG.h +1 -1
- package/svf-llvm/include/SVF-LLVM/ICFGBuilder.h +93 -23
- package/svf-llvm/include/SVF-LLVM/LLVMModule.h +84 -0
- package/svf-llvm/include/SVF-LLVM/LLVMUtil.h +15 -0
- package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +19 -12
- package/svf-llvm/lib/ICFGBuilder.cpp +125 -54
- package/svf-llvm/lib/LLVMLoopAnalysis.cpp +6 -11
- package/svf-llvm/lib/LLVMModule.cpp +54 -0
- package/svf-llvm/lib/LLVMUtil.cpp +15 -0
- package/svf-llvm/lib/SVFIRBuilder.cpp +92 -76
- package/svf-llvm/lib/SVFIRExtAPI.cpp +5 -5
- package/svf-llvm/lib/SymbolTableBuilder.cpp +4 -4
|
@@ -60,19 +60,8 @@ public:
|
|
|
60
60
|
/// GepValNode: temporary gep obj node for field sensitivity
|
|
61
61
|
/// FIObjNode: for field insensitive analysis
|
|
62
62
|
/// DummyValNode and DummyObjNode: for non-llvm-value node
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
ValNode,
|
|
66
|
-
ObjNode,
|
|
67
|
-
RetNode,
|
|
68
|
-
VarargNode,
|
|
69
|
-
GepValNode,
|
|
70
|
-
GepObjNode,
|
|
71
|
-
FIObjNode,
|
|
72
|
-
DummyValNode,
|
|
73
|
-
DummyObjNode,
|
|
74
|
-
};
|
|
75
|
-
|
|
63
|
+
typedef GNodeK PNODEK;
|
|
64
|
+
typedef s64_t GEdgeKind;
|
|
76
65
|
|
|
77
66
|
protected:
|
|
78
67
|
const SVFValue* value; ///< value of this SVFIR node
|
|
@@ -206,19 +195,34 @@ public:
|
|
|
206
195
|
}
|
|
207
196
|
//@}
|
|
208
197
|
|
|
198
|
+
static inline bool classof(const SVFVar *)
|
|
199
|
+
{
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
static inline bool classof(const GenericPAGNodeTy * node)
|
|
204
|
+
{
|
|
205
|
+
return isSVFVarKind(node->getNodeKind());
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
209
|
+
{
|
|
210
|
+
return isSVFVarKind(node->getNodeKind());
|
|
211
|
+
}
|
|
212
|
+
|
|
209
213
|
private:
|
|
210
214
|
/// add methods of the components
|
|
211
215
|
//@{
|
|
212
216
|
inline void addInEdge(SVFStmt* inEdge)
|
|
213
217
|
{
|
|
214
|
-
|
|
218
|
+
GEdgeKind kind = inEdge->getEdgeKind();
|
|
215
219
|
InEdgeKindToSetMap[kind].insert(inEdge);
|
|
216
220
|
addIncomingEdge(inEdge);
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
inline void addOutEdge(SVFStmt* outEdge)
|
|
220
224
|
{
|
|
221
|
-
|
|
225
|
+
GEdgeKind kind = outEdge->getEdgeKind();
|
|
222
226
|
OutEdgeKindToSetMap[kind].insert(outEdge);
|
|
223
227
|
addOutgoingEdge(outEdge);
|
|
224
228
|
}
|
|
@@ -264,9 +268,11 @@ class ValVar: public SVFVar
|
|
|
264
268
|
friend class SVFIRWriter;
|
|
265
269
|
friend class SVFIRReader;
|
|
266
270
|
|
|
271
|
+
private:
|
|
272
|
+
const SVFBaseNode* gNode; // constant, gepValvar, retPN, dummy could be null
|
|
267
273
|
protected:
|
|
268
274
|
/// Constructor to create an empty ValVar (for SVFIRReader/deserialization)
|
|
269
|
-
ValVar(NodeID i, PNODEK ty = ValNode) : SVFVar(i, ty) {}
|
|
275
|
+
ValVar(NodeID i, PNODEK ty = ValNode) : SVFVar(i, ty), gNode(nullptr) {}
|
|
270
276
|
|
|
271
277
|
public:
|
|
272
278
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
@@ -277,25 +283,21 @@ public:
|
|
|
277
283
|
}
|
|
278
284
|
static inline bool classof(const SVFVar* node)
|
|
279
285
|
{
|
|
280
|
-
return node->getNodeKind()
|
|
281
|
-
node->getNodeKind() == SVFVar::GepValNode ||
|
|
282
|
-
node->getNodeKind() == SVFVar::RetNode ||
|
|
283
|
-
node->getNodeKind() == SVFVar::VarargNode ||
|
|
284
|
-
node->getNodeKind() == SVFVar::DummyValNode;
|
|
286
|
+
return isValVarKinds(node->getNodeKind());
|
|
285
287
|
}
|
|
286
288
|
static inline bool classof(const GenericPAGNodeTy* node)
|
|
287
289
|
{
|
|
288
|
-
return node->getNodeKind()
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
return isValVarKinds(node->getNodeKind());
|
|
291
|
+
}
|
|
292
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
293
|
+
{
|
|
294
|
+
return isValVarKinds(node->getNodeKind());
|
|
293
295
|
}
|
|
294
296
|
//@}
|
|
295
297
|
|
|
296
298
|
/// Constructor
|
|
297
|
-
ValVar(const SVFValue* val, NodeID i, PNODEK ty = ValNode)
|
|
298
|
-
: SVFVar(val, i, ty)
|
|
299
|
+
ValVar(const SVFValue* val, NodeID i, PNODEK ty = ValNode, const SVFBaseNode* node = nullptr)
|
|
300
|
+
: SVFVar(val, i, ty), gNode(node)
|
|
299
301
|
{
|
|
300
302
|
}
|
|
301
303
|
/// Return name of a LLVM value
|
|
@@ -306,6 +308,11 @@ public:
|
|
|
306
308
|
return "";
|
|
307
309
|
}
|
|
308
310
|
|
|
311
|
+
const SVFBaseNode* getGNode() const
|
|
312
|
+
{
|
|
313
|
+
return gNode;
|
|
314
|
+
}
|
|
315
|
+
|
|
309
316
|
virtual const std::string toString() const;
|
|
310
317
|
};
|
|
311
318
|
|
|
@@ -335,17 +342,15 @@ public:
|
|
|
335
342
|
}
|
|
336
343
|
static inline bool classof(const SVFVar* node)
|
|
337
344
|
{
|
|
338
|
-
return node->getNodeKind()
|
|
339
|
-
node->getNodeKind() == SVFVar::GepObjNode ||
|
|
340
|
-
node->getNodeKind() == SVFVar::FIObjNode ||
|
|
341
|
-
node->getNodeKind() == SVFVar::DummyObjNode;
|
|
345
|
+
return isObjVarKinds(node->getNodeKind());
|
|
342
346
|
}
|
|
343
347
|
static inline bool classof(const GenericPAGNodeTy* node)
|
|
344
348
|
{
|
|
345
|
-
return node->getNodeKind()
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
+
return isObjVarKinds(node->getNodeKind());
|
|
350
|
+
}
|
|
351
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
352
|
+
{
|
|
353
|
+
return isObjVarKinds(node->getNodeKind());
|
|
349
354
|
}
|
|
350
355
|
//@}
|
|
351
356
|
|
|
@@ -477,6 +482,10 @@ public:
|
|
|
477
482
|
{
|
|
478
483
|
return node->getNodeKind() == SVFVar::GepObjNode;
|
|
479
484
|
}
|
|
485
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
486
|
+
{
|
|
487
|
+
return node->getNodeKind() == SVFVar::GepObjNode;
|
|
488
|
+
}
|
|
480
489
|
//@}
|
|
481
490
|
|
|
482
491
|
/// Constructor
|
|
@@ -494,9 +503,9 @@ public:
|
|
|
494
503
|
}
|
|
495
504
|
|
|
496
505
|
/// Set the base object from which this GEP node came from.
|
|
497
|
-
inline void setBaseNode(NodeID
|
|
506
|
+
inline void setBaseNode(NodeID bs)
|
|
498
507
|
{
|
|
499
|
-
this->base =
|
|
508
|
+
this->base = bs;
|
|
500
509
|
}
|
|
501
510
|
|
|
502
511
|
/// Return the base object from which this GEP node came from.
|
|
@@ -554,6 +563,10 @@ public:
|
|
|
554
563
|
{
|
|
555
564
|
return node->getNodeKind() == SVFVar::FIObjNode;
|
|
556
565
|
}
|
|
566
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
567
|
+
{
|
|
568
|
+
return node->getNodeKind() == SVFVar::FIObjNode;
|
|
569
|
+
}
|
|
557
570
|
//@}
|
|
558
571
|
|
|
559
572
|
/// Constructor
|
|
@@ -604,6 +617,10 @@ public:
|
|
|
604
617
|
{
|
|
605
618
|
return node->getNodeKind() == SVFVar::RetNode;
|
|
606
619
|
}
|
|
620
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
621
|
+
{
|
|
622
|
+
return node->getNodeKind() == SVFVar::RetNode;
|
|
623
|
+
}
|
|
607
624
|
//@}
|
|
608
625
|
|
|
609
626
|
/// Constructor
|
|
@@ -648,6 +665,10 @@ public:
|
|
|
648
665
|
{
|
|
649
666
|
return node->getNodeKind() == SVFVar::VarargNode;
|
|
650
667
|
}
|
|
668
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
669
|
+
{
|
|
670
|
+
return node->getNodeKind() == SVFVar::VarargNode;
|
|
671
|
+
}
|
|
651
672
|
//@}
|
|
652
673
|
|
|
653
674
|
/// Constructor
|
|
@@ -688,6 +709,10 @@ public:
|
|
|
688
709
|
{
|
|
689
710
|
return node->getNodeKind() == SVFVar::DummyValNode;
|
|
690
711
|
}
|
|
712
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
713
|
+
{
|
|
714
|
+
return node->getNodeKind() == SVFVar::DummyValNode;
|
|
715
|
+
}
|
|
691
716
|
//@}
|
|
692
717
|
|
|
693
718
|
/// Constructor
|
|
@@ -732,6 +757,11 @@ public:
|
|
|
732
757
|
{
|
|
733
758
|
return node->getNodeKind() == SVFVar::DummyObjNode;
|
|
734
759
|
}
|
|
760
|
+
|
|
761
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
762
|
+
{
|
|
763
|
+
return node->getNodeKind() == SVFVar::DummyObjNode;
|
|
764
|
+
}
|
|
735
765
|
//@}
|
|
736
766
|
|
|
737
767
|
/// Constructor
|
|
@@ -373,6 +373,7 @@ protected:
|
|
|
373
373
|
Set<const StInfo*> stInfos;
|
|
374
374
|
};
|
|
375
375
|
|
|
376
|
+
class SVFBaseNode;
|
|
376
377
|
|
|
377
378
|
/*!
|
|
378
379
|
* Memory object symbols or MemObj (address-taken variables in LLVM-based languages)
|
|
@@ -381,6 +382,7 @@ class MemObj
|
|
|
381
382
|
{
|
|
382
383
|
friend class SVFIRWriter;
|
|
383
384
|
friend class SVFIRReader;
|
|
385
|
+
friend class SVFIRBuilder;
|
|
384
386
|
|
|
385
387
|
private:
|
|
386
388
|
/// Type information of this object
|
|
@@ -390,9 +392,11 @@ private:
|
|
|
390
392
|
/// The unique id to represent this symbol
|
|
391
393
|
SymID symId;
|
|
392
394
|
|
|
395
|
+
const SVFBaseNode* gNode;
|
|
396
|
+
|
|
393
397
|
public:
|
|
394
398
|
/// Constructor
|
|
395
|
-
MemObj(SymID id, ObjTypeInfo* ti, const SVFValue* val = nullptr);
|
|
399
|
+
MemObj(SymID id, ObjTypeInfo* ti, const SVFValue* val = nullptr, const SVFBaseNode* node = nullptr);
|
|
396
400
|
|
|
397
401
|
/// Destructor
|
|
398
402
|
virtual ~MemObj()
|
|
@@ -408,6 +412,12 @@ public:
|
|
|
408
412
|
return refVal;
|
|
409
413
|
}
|
|
410
414
|
|
|
415
|
+
/// Get the reference value to this object
|
|
416
|
+
inline const SVFBaseNode* getGNode() const
|
|
417
|
+
{
|
|
418
|
+
return gNode;
|
|
419
|
+
}
|
|
420
|
+
|
|
411
421
|
/// Get the memory object id
|
|
412
422
|
inline SymID getId() const
|
|
413
423
|
{
|
|
@@ -457,7 +457,7 @@ inline bool isBarrierWaitCall(const CallICFGNode* cs)
|
|
|
457
457
|
|
|
458
458
|
/// Return sole argument of the thread routine
|
|
459
459
|
//@{
|
|
460
|
-
inline const
|
|
460
|
+
inline const SVFVar* getActualParmAtForkSite(const CallICFGNode* cs)
|
|
461
461
|
{
|
|
462
462
|
return ThreadAPI::getThreadAPI()->getActualParmAtForkSite(cs);
|
|
463
463
|
}
|
|
@@ -38,6 +38,7 @@ namespace SVF
|
|
|
38
38
|
class SVFModule;
|
|
39
39
|
class ICFGNode;
|
|
40
40
|
class CallICFGNode;
|
|
41
|
+
class SVFVar;
|
|
41
42
|
|
|
42
43
|
/*
|
|
43
44
|
* ThreadAPI class contains interfaces for pthread programs
|
|
@@ -128,11 +129,16 @@ public:
|
|
|
128
129
|
/// Note that, it could be function type or a void* pointer
|
|
129
130
|
const SVFValue* getForkedFun(const CallICFGNode *inst) const;
|
|
130
131
|
|
|
131
|
-
/// Return the
|
|
132
|
+
/// Return the actual param of forksite
|
|
132
133
|
/// Note that, it is the sole argument of start routine ( a void* pointer )
|
|
133
|
-
const
|
|
134
|
+
const SVFVar* getActualParmAtForkSite(const CallICFGNode *inst) const;
|
|
135
|
+
|
|
136
|
+
/// Return the formal parm of forked function (the first arg in pthread)
|
|
137
|
+
const SVFVar* getFormalParmOfForkedFun(const SVFFunction* F) const;
|
|
134
138
|
//@}
|
|
135
139
|
|
|
140
|
+
|
|
141
|
+
|
|
136
142
|
/// Return true if this call create a new thread
|
|
137
143
|
//@{
|
|
138
144
|
bool isTDFork(const CallICFGNode *inst) const;
|
|
@@ -47,6 +47,8 @@ namespace SVF
|
|
|
47
47
|
|
|
48
48
|
class SVFModule;
|
|
49
49
|
|
|
50
|
+
class ThreadCallGraph;
|
|
51
|
+
|
|
50
52
|
/*!
|
|
51
53
|
* Abstract class of inclusion-based Pointer Analysis
|
|
52
54
|
*/
|
|
@@ -54,6 +56,9 @@ typedef WPASolver<ConstraintGraph*> WPAConstraintSolver;
|
|
|
54
56
|
|
|
55
57
|
class AndersenBase: public WPAConstraintSolver, public BVDataPTAImpl
|
|
56
58
|
{
|
|
59
|
+
public:
|
|
60
|
+
typedef OrderedMap<const CallICFGNode*, NodeID> CallSite2DummyValPN;
|
|
61
|
+
|
|
57
62
|
public:
|
|
58
63
|
|
|
59
64
|
/// Constructor
|
|
@@ -81,11 +86,19 @@ public:
|
|
|
81
86
|
/// Finalize analysis
|
|
82
87
|
virtual void finalize() override;
|
|
83
88
|
|
|
84
|
-
///
|
|
85
|
-
virtual
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
/// Update call graph
|
|
90
|
+
virtual bool updateCallGraph(const CallSiteToFunPtrMap&) override;
|
|
91
|
+
|
|
92
|
+
/// Update thread call graph
|
|
93
|
+
virtual bool updateThreadCallGraph(const CallSiteToFunPtrMap&, NodePairSet&);
|
|
94
|
+
|
|
95
|
+
/// Connect formal and actual parameters for indirect forksites
|
|
96
|
+
virtual void connectCaller2ForkedFunParams(const CallICFGNode* cs, const SVFFunction* F,
|
|
97
|
+
NodePairSet& cpySrcNodes);
|
|
98
|
+
|
|
99
|
+
/// Connect formal and actual parameters for indirect callsites
|
|
100
|
+
virtual void connectCaller2CalleeParams(const CallICFGNode* cs, const SVFFunction* F,
|
|
101
|
+
NodePairSet& cpySrcNodes);
|
|
89
102
|
|
|
90
103
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
91
104
|
//@{
|
|
@@ -123,6 +136,9 @@ public:
|
|
|
123
136
|
}
|
|
124
137
|
//@}
|
|
125
138
|
|
|
139
|
+
/// Add copy edge on constraint graph
|
|
140
|
+
virtual bool addCopyEdge(NodeID src, NodeID dst) = 0;
|
|
141
|
+
|
|
126
142
|
/// dump statistics
|
|
127
143
|
inline void printStat()
|
|
128
144
|
{
|
|
@@ -160,6 +176,11 @@ public:
|
|
|
160
176
|
protected:
|
|
161
177
|
/// Constraint Graph
|
|
162
178
|
ConstraintGraph* consCG;
|
|
179
|
+
CallSite2DummyValPN
|
|
180
|
+
callsite2DummyValPN; ///< Map an instruction to a dummy obj which
|
|
181
|
+
///< created at an indirect callsite, which invokes
|
|
182
|
+
///< a heap allocator
|
|
183
|
+
void heapAllocatorViaIndCall(const CallICFGNode* cs, NodePairSet& cpySrcNodes);
|
|
163
184
|
};
|
|
164
185
|
|
|
165
186
|
/*!
|
|
@@ -171,7 +192,6 @@ class Andersen: public AndersenBase
|
|
|
171
192
|
|
|
172
193
|
public:
|
|
173
194
|
typedef SCCDetection<ConstraintGraph*> CGSCC;
|
|
174
|
-
typedef OrderedMap<const CallICFGNode*, NodeID> CallSite2DummyValPN;
|
|
175
195
|
|
|
176
196
|
/// Constructor
|
|
177
197
|
Andersen(SVFIR* _pag, PTATY type = Andersen_WPA, bool alias_check = true)
|
|
@@ -243,7 +263,6 @@ public:
|
|
|
243
263
|
protected:
|
|
244
264
|
|
|
245
265
|
CallSite2DummyValPN callsite2DummyValPN; ///< Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocator
|
|
246
|
-
void heapAllocatorViaIndCall(const CallICFGNode* cs,NodePairSet &cpySrcNodes);
|
|
247
266
|
|
|
248
267
|
/// Handle diff points-to set.
|
|
249
268
|
virtual inline void computeDiffPts(NodeID id)
|
|
@@ -311,12 +330,6 @@ protected:
|
|
|
311
330
|
return false;
|
|
312
331
|
}
|
|
313
332
|
|
|
314
|
-
/// Update call graph for the input indirect callsites
|
|
315
|
-
virtual bool updateCallGraph(const CallSiteToFunPtrMap& callsites);
|
|
316
|
-
|
|
317
|
-
/// Connect formal and actual parameters for indirect callsites
|
|
318
|
-
void connectCaller2CalleeParams(const CallICFGNode* cs, const SVFFunction* F, NodePairSet& cpySrcNodes);
|
|
319
|
-
|
|
320
333
|
/// Merge sub node to its rep
|
|
321
334
|
virtual void mergeNodeToRep(NodeID nodeId,NodeID newRepId);
|
|
322
335
|
|
|
@@ -23,7 +23,6 @@ class Steensgaard : public AndersenBase
|
|
|
23
23
|
public:
|
|
24
24
|
typedef Map<NodeID, NodeID> NodeToEquivClassMap;
|
|
25
25
|
typedef Map<NodeID, Set<NodeID>> NodeToSubsMap;
|
|
26
|
-
typedef OrderedMap<const CallICFGNode*, NodeID> CallSite2DummyValPN;
|
|
27
26
|
|
|
28
27
|
/// Constructor
|
|
29
28
|
Steensgaard(SVFIR* _pag) : AndersenBase(_pag, Steensgaard_WPA, true) {}
|
|
@@ -46,7 +45,7 @@ public:
|
|
|
46
45
|
steens = nullptr;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
virtual void solveWorklist();
|
|
48
|
+
virtual void solveWorklist() override;
|
|
50
49
|
|
|
51
50
|
void processAllAddr();
|
|
52
51
|
|
|
@@ -69,18 +68,18 @@ public:
|
|
|
69
68
|
//@}
|
|
70
69
|
|
|
71
70
|
/// Operation of points-to set
|
|
72
|
-
virtual inline const PointsTo& getPts(NodeID id)
|
|
71
|
+
virtual inline const PointsTo& getPts(NodeID id) override
|
|
73
72
|
{
|
|
74
73
|
return getPTDataTy()->getPts(getEC(id));
|
|
75
74
|
}
|
|
76
75
|
/// pts(id) = pts(id) U target
|
|
77
|
-
virtual inline bool unionPts(NodeID id, const PointsTo& target)
|
|
76
|
+
virtual inline bool unionPts(NodeID id, const PointsTo& target) override
|
|
78
77
|
{
|
|
79
78
|
id = getEC(id);
|
|
80
79
|
return getPTDataTy()->unionPts(id, target);
|
|
81
80
|
}
|
|
82
81
|
/// pts(id) = pts(id) U pts(ptd)
|
|
83
|
-
virtual inline bool unionPts(NodeID id, NodeID ptd)
|
|
82
|
+
virtual inline bool unionPts(NodeID id, NodeID ptd) override
|
|
84
83
|
{
|
|
85
84
|
id = getEC(id);
|
|
86
85
|
ptd = getEC(ptd);
|
|
@@ -98,6 +97,11 @@ public:
|
|
|
98
97
|
else
|
|
99
98
|
return it->second;
|
|
100
99
|
}
|
|
100
|
+
/// Return getEC(id)
|
|
101
|
+
inline NodeID sccRepNode(NodeID id) const override
|
|
102
|
+
{
|
|
103
|
+
return getEC(id);
|
|
104
|
+
}
|
|
101
105
|
void setEC(NodeID node, NodeID rep);
|
|
102
106
|
|
|
103
107
|
inline Set<NodeID>& getSubNodes(NodeID id)
|
|
@@ -111,25 +115,11 @@ public:
|
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
/// Add copy edge on constraint graph
|
|
114
|
-
virtual inline bool addCopyEdge(NodeID src, NodeID dst)
|
|
118
|
+
virtual inline bool addCopyEdge(NodeID src, NodeID dst) override
|
|
115
119
|
{
|
|
116
120
|
return consCG->addCopyCGEdge(src, dst);
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
protected:
|
|
120
|
-
CallSite2DummyValPN
|
|
121
|
-
callsite2DummyValPN; ///< Map an instruction to a dummy obj which
|
|
122
|
-
///< created at an indirect callsite, which invokes
|
|
123
|
-
///< a heap allocator
|
|
124
|
-
void heapAllocatorViaIndCall(const CallICFGNode* cs, NodePairSet& cpySrcNodes);
|
|
125
|
-
|
|
126
|
-
/// Update call graph for the input indirect callsites
|
|
127
|
-
virtual bool updateCallGraph(const CallSiteToFunPtrMap& callsites);
|
|
128
|
-
|
|
129
|
-
/// Connect formal and actual parameters for indirect callsites
|
|
130
|
-
void connectCaller2CalleeParams(const CallICFGNode* cs, const SVFFunction* F,
|
|
131
|
-
NodePairSet& cpySrcNodes);
|
|
132
|
-
|
|
133
123
|
private:
|
|
134
124
|
static Steensgaard* steens; // static instance
|
|
135
125
|
NodeToEquivClassMap nodeToECMap;
|
|
@@ -51,13 +51,20 @@ public:
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/// Type analysis
|
|
54
|
-
void analyze();
|
|
54
|
+
void analyze() override;
|
|
55
55
|
|
|
56
56
|
/// Initialize analysis
|
|
57
|
-
void initialize();
|
|
57
|
+
void initialize() override;
|
|
58
58
|
|
|
59
59
|
/// Finalize analysis
|
|
60
|
-
virtual inline void finalize();
|
|
60
|
+
virtual inline void finalize() override;
|
|
61
|
+
|
|
62
|
+
/// Add copy edge on constraint graph
|
|
63
|
+
inline bool addCopyEdge(NodeID src, NodeID dst) override
|
|
64
|
+
{
|
|
65
|
+
assert(false && "this function should never be executed!");
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
61
68
|
|
|
62
69
|
/// Resolve callgraph based on CHA
|
|
63
70
|
void callGraphSolveBasedOnCHA(const CallSiteToFunPtrMap& callsites, CallEdgeMap& newEdges);
|
|
@@ -70,7 +70,8 @@ void BufOverflowDetector::detect(AbstractState& as, const ICFGNode* node)
|
|
|
70
70
|
}
|
|
71
71
|
else
|
|
72
72
|
{
|
|
73
|
-
const ICFGNode* addrNode =
|
|
73
|
+
const ICFGNode* addrNode = SVFUtil::cast<ICFGNode>(
|
|
74
|
+
svfir->getBaseObj(objId)->getGNode());
|
|
74
75
|
for (const SVFStmt* stmt2 : addrNode->getSVFStmts())
|
|
75
76
|
{
|
|
76
77
|
if (const AddrStmt* addrStmt = SVFUtil::dyn_cast<AddrStmt>(stmt2))
|
|
@@ -477,7 +478,8 @@ bool BufOverflowDetector::canSafelyAccessMemory(AbstractState& as, const SVF::SV
|
|
|
477
478
|
else
|
|
478
479
|
{
|
|
479
480
|
// if the object is not a constant size object, get the size from the addrStmt
|
|
480
|
-
const ICFGNode* addrNode =
|
|
481
|
+
const ICFGNode* addrNode = SVFUtil::cast<ICFGNode>(
|
|
482
|
+
svfir->getBaseObj(objId)->getGNode());
|
|
481
483
|
for (const SVFStmt* stmt2 : addrNode->getSVFStmts())
|
|
482
484
|
{
|
|
483
485
|
if (const AddrStmt* addrStmt = SVFUtil::dyn_cast<AddrStmt>(stmt2))
|
|
@@ -130,17 +130,15 @@ void AbsExtAPI::initExtFunMap()
|
|
|
130
130
|
assert(lb.getInterval().is_numeral() && ub.getInterval().is_numeral());
|
|
131
131
|
num.getInterval().set_to_top();
|
|
132
132
|
num.getInterval().meet_with(IntervalValue(lb.getInterval().lb(), ub.getInterval().ub()));
|
|
133
|
-
|
|
133
|
+
const ICFGNode* node = SVFUtil::cast<ICFGNode>(
|
|
134
|
+
SVFUtil::cast<ValVar>(callNode->getArgumentVar(0))->getGNode());
|
|
135
|
+
for (const SVFStmt* stmt: node->getSVFStmts())
|
|
134
136
|
{
|
|
135
|
-
|
|
136
|
-
for (const SVFStmt* stmt: node->getSVFStmts())
|
|
137
|
+
if (SVFUtil::isa<LoadStmt>(stmt))
|
|
137
138
|
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
NodeID rhsId = load->getRHSVarID();
|
|
142
|
-
as.storeValue(rhsId, num);
|
|
143
|
-
}
|
|
139
|
+
const LoadStmt* load = SVFUtil::cast<LoadStmt>(stmt);
|
|
140
|
+
NodeID rhsId = load->getRHSVarID();
|
|
141
|
+
as.storeValue(rhsId, num);
|
|
144
142
|
}
|
|
145
143
|
}
|
|
146
144
|
return;
|
|
@@ -286,7 +284,7 @@ void AbsExtAPI::initExtFunMap()
|
|
|
286
284
|
}
|
|
287
285
|
else
|
|
288
286
|
{
|
|
289
|
-
const ICFGNode* addrNode =
|
|
287
|
+
const ICFGNode* addrNode = SVFUtil::cast<ICFGNode>(svfir->getBaseObj(objId)->getGNode());
|
|
290
288
|
for (const SVFStmt* stmt2: addrNode->getSVFStmts())
|
|
291
289
|
{
|
|
292
290
|
if (const AddrStmt* addrStmt = SVFUtil::dyn_cast<AddrStmt>(stmt2))
|
|
@@ -477,8 +475,8 @@ IntervalValue AbsExtAPI::getStrlen(AbstractState& as, const SVF::SVFVar *strValu
|
|
|
477
475
|
}
|
|
478
476
|
else
|
|
479
477
|
{
|
|
480
|
-
const ICFGNode*
|
|
481
|
-
for (const SVFStmt* stmt2:
|
|
478
|
+
const ICFGNode* icfgNode = SVFUtil::cast<ICFGNode>( svfir->getBaseObj(objId)->getGNode());
|
|
479
|
+
for (const SVFStmt* stmt2: icfgNode->getSVFStmts())
|
|
482
480
|
{
|
|
483
481
|
if (const AddrStmt* addrStmt = SVFUtil::dyn_cast<AddrStmt>(stmt2))
|
|
484
482
|
{
|
|
@@ -96,6 +96,8 @@ void AbstractInterpretation::initWTO()
|
|
|
96
96
|
// Initialize WTO for each function in the module
|
|
97
97
|
for (const SVFFunction* fun : svfir->getModule()->getFunctionSet())
|
|
98
98
|
{
|
|
99
|
+
if(fun->isDeclaration())
|
|
100
|
+
continue;
|
|
99
101
|
auto* wto = new ICFGWTO(icfg, icfg->getFunEntryICFGNode(fun));
|
|
100
102
|
wto->init();
|
|
101
103
|
funcToWTO[fun] = wto;
|
|
@@ -354,15 +354,19 @@ bool ContextDDA::isHeapCondMemObj(const CxtVar& var, const StoreSVFGNode*)
|
|
|
354
354
|
}
|
|
355
355
|
return true;
|
|
356
356
|
}
|
|
357
|
-
else if(const
|
|
357
|
+
else if(const SVFBaseNode* gNode = mem->getGNode())
|
|
358
358
|
{
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
359
|
+
if (const auto& node =
|
|
360
|
+
SVFUtil::dyn_cast<ICFGNode>(gNode))
|
|
361
|
+
{
|
|
362
|
+
const SVFFunction* svfFun = node->getFun();
|
|
363
|
+
if(_ander->isInRecursion(svfFun))
|
|
364
|
+
return true;
|
|
365
|
+
if(var.get_cond().isConcreteCxt() == false)
|
|
366
|
+
return true;
|
|
367
|
+
if(_pag->getICFG()->isInLoop(node))
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
366
370
|
}
|
|
367
371
|
}
|
|
368
372
|
return false;
|