svf-tools 1.0.1025 → 1.0.1027
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/GenericGraph.h +3 -2
- package/svf/include/Graphs/VFGNode.h +8 -6
- package/svf/include/SVFIR/SVFIR.h +7 -0
- package/svf/include/SVFIR/SVFStatements.h +8 -12
- package/svf/include/SVFIR/SVFVariables.h +77 -5
- package/svf/include/Util/SVFUtil.h +2 -0
- package/svf/lib/AE/Core/AbstractState.cpp +5 -6
- package/svf/lib/Graphs/VFG.cpp +9 -9
- package/svf/lib/MTA/MTA.cpp +1 -1
- package/svf/lib/SABER/SaberCondAllocator.cpp +5 -4
- package/svf/lib/SVFIR/SVFFileSystem.cpp +1 -0
- package/svf/lib/SVFIR/SVFIR.cpp +5 -6
- package/svf/lib/SVFIR/SVFVariables.cpp +34 -1
- package/svf/lib/Util/SVFUtil.cpp +8 -0
- package/svf/lib/Util/ThreadAPI.cpp +2 -2
- package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +7 -8
- package/svf-llvm/lib/SVFIRBuilder.cpp +10 -1
- package/svf-llvm/tools/Example/svf-ex.cpp +7 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1027",
|
|
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": {
|
|
@@ -154,6 +154,7 @@ public:
|
|
|
154
154
|
// ┌── SVFVar: Classes of top-level variables (ValVar) and address-taken variables (ObjVar)
|
|
155
155
|
// │ └── ValVar: Classes of top-level variable nodes
|
|
156
156
|
ValNode, // ├──Represents a standard value variable
|
|
157
|
+
ArgNode, // ├──Represents an argument value variable
|
|
157
158
|
FunValNode, // ├──Represents a Function value variable
|
|
158
159
|
GepValNode, // ├──Represents a GEP value variable
|
|
159
160
|
RetNode, // ├──Represents a return value node
|
|
@@ -289,7 +290,7 @@ protected:
|
|
|
289
290
|
|
|
290
291
|
static inline bool isSVFVarKind(GNodeK n)
|
|
291
292
|
{
|
|
292
|
-
static_assert(DummyObjNode - ValNode ==
|
|
293
|
+
static_assert(DummyObjNode - ValNode == 24,
|
|
293
294
|
"The number of SVFVarKinds has changed, make sure the "
|
|
294
295
|
"range is correct");
|
|
295
296
|
|
|
@@ -298,7 +299,7 @@ protected:
|
|
|
298
299
|
|
|
299
300
|
static inline bool isValVarKinds(GNodeK n)
|
|
300
301
|
{
|
|
301
|
-
static_assert(DummyValNode - ValNode ==
|
|
302
|
+
static_assert(DummyValNode - ValNode == 12,
|
|
302
303
|
"The number of ValVarKinds has changed, make sure the "
|
|
303
304
|
"range is correct");
|
|
304
305
|
return n <= DummyValNode && n >= ValNode;
|
|
@@ -82,7 +82,7 @@ public:
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/// Return the corresponding LLVM value, if possible, nullptr otherwise.
|
|
85
|
-
virtual const
|
|
85
|
+
virtual const SVFVar* getValue() const
|
|
86
86
|
{
|
|
87
87
|
return nullptr;
|
|
88
88
|
}
|
|
@@ -190,7 +190,7 @@ public:
|
|
|
190
190
|
}
|
|
191
191
|
//@}
|
|
192
192
|
|
|
193
|
-
const
|
|
193
|
+
const SVFVar* getValue() const override;
|
|
194
194
|
const std::string toString() const override;
|
|
195
195
|
};
|
|
196
196
|
|
|
@@ -401,7 +401,9 @@ public:
|
|
|
401
401
|
|
|
402
402
|
const NodeBS getDefSVFVars() const override;
|
|
403
403
|
|
|
404
|
-
const
|
|
404
|
+
const SVFVar* getValue() const override;
|
|
405
|
+
|
|
406
|
+
|
|
405
407
|
const std::string toString() const override;
|
|
406
408
|
};
|
|
407
409
|
|
|
@@ -476,7 +478,7 @@ public:
|
|
|
476
478
|
|
|
477
479
|
const NodeBS getDefSVFVars() const override;
|
|
478
480
|
|
|
479
|
-
const
|
|
481
|
+
const SVFVar* getValue() const override;
|
|
480
482
|
const std::string toString() const override;
|
|
481
483
|
};
|
|
482
484
|
|
|
@@ -736,7 +738,7 @@ public:
|
|
|
736
738
|
|
|
737
739
|
const NodeBS getDefSVFVars() const override;
|
|
738
740
|
|
|
739
|
-
const
|
|
741
|
+
const SVFVar* getValue() const override;
|
|
740
742
|
const std::string toString() const override;
|
|
741
743
|
};
|
|
742
744
|
|
|
@@ -879,7 +881,7 @@ public:
|
|
|
879
881
|
}
|
|
880
882
|
//@}
|
|
881
883
|
|
|
882
|
-
const
|
|
884
|
+
const SVFVar* getValue() const override;
|
|
883
885
|
const std::string toString() const override;
|
|
884
886
|
};
|
|
885
887
|
|
|
@@ -578,6 +578,13 @@ private:
|
|
|
578
578
|
return addValNode(nullptr, node, i);
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
+
NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode, bool isUncalled = false)
|
|
582
|
+
{
|
|
583
|
+
ArgValVar* node =
|
|
584
|
+
new ArgValVar(i, argNo, icfgNode, callGraphNode, isUncalled);
|
|
585
|
+
return addValNode(nullptr, node, i);
|
|
586
|
+
}
|
|
587
|
+
|
|
581
588
|
inline NodeID addConstantFPValNode(const SVFValue* curInst, double dval, const NodeID i,
|
|
582
589
|
const ICFGNode* icfgNode)
|
|
583
590
|
{
|
|
@@ -78,7 +78,7 @@ public:
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
private:
|
|
81
|
-
const
|
|
81
|
+
const SVFVar* value; ///< LLVM value
|
|
82
82
|
const SVFBasicBlock* basicBlock; ///< LLVM BasicBlock
|
|
83
83
|
ICFGNode* icfgNode; ///< ICFGNode
|
|
84
84
|
EdgeID edgeId; ///< Edge ID
|
|
@@ -134,20 +134,16 @@ public:
|
|
|
134
134
|
|
|
135
135
|
/// Get/set methods for llvm instruction
|
|
136
136
|
//@{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (const SVFInstruction* i = SVFUtil::dyn_cast<SVFInstruction>(value))
|
|
140
|
-
return i;
|
|
141
|
-
return nullptr;
|
|
142
|
-
}
|
|
143
|
-
inline void setValue(const SVFValue* val)
|
|
137
|
+
|
|
138
|
+
inline void setValue(const SVFVar* val)
|
|
144
139
|
{
|
|
145
140
|
value = val;
|
|
146
141
|
}
|
|
147
|
-
inline const
|
|
142
|
+
inline const SVFVar* getValue() const
|
|
148
143
|
{
|
|
149
144
|
return value;
|
|
150
145
|
}
|
|
146
|
+
|
|
151
147
|
inline void setBB(const SVFBasicBlock* bb)
|
|
152
148
|
{
|
|
153
149
|
basicBlock = bb;
|
|
@@ -321,7 +317,7 @@ private:
|
|
|
321
317
|
AddrStmt(const AddrStmt&); ///< place holder
|
|
322
318
|
void operator=(const AddrStmt&); ///< place holder
|
|
323
319
|
|
|
324
|
-
std::vector<
|
|
320
|
+
std::vector<SVFVar*> arrSize; ///< Array size of the allocated memory
|
|
325
321
|
|
|
326
322
|
public:
|
|
327
323
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
@@ -345,13 +341,13 @@ public:
|
|
|
345
341
|
|
|
346
342
|
virtual const std::string toString() const override;
|
|
347
343
|
|
|
348
|
-
inline void addArrSize(
|
|
344
|
+
inline void addArrSize(SVFVar* size) //TODO:addSizeVar
|
|
349
345
|
{
|
|
350
346
|
arrSize.push_back(size);
|
|
351
347
|
}
|
|
352
348
|
|
|
353
349
|
///< get array size of the allocated memory
|
|
354
|
-
inline const std::vector<
|
|
350
|
+
inline const std::vector<SVFVar*>& getArrSize() const //TODO:getSizeVars
|
|
355
351
|
{
|
|
356
352
|
return arrSize;
|
|
357
353
|
}
|
|
@@ -133,11 +133,6 @@ public:
|
|
|
133
133
|
{
|
|
134
134
|
return inst->getParent()->getParent();
|
|
135
135
|
}
|
|
136
|
-
// For function arguments, return their parent function
|
|
137
|
-
else if (auto arg = SVFUtil::dyn_cast<SVFArgument>(value))
|
|
138
|
-
{
|
|
139
|
-
return arg->getParent();
|
|
140
|
-
}
|
|
141
136
|
}
|
|
142
137
|
|
|
143
138
|
// Return nullptr for globals/constants with no parent function
|
|
@@ -388,6 +383,83 @@ public:
|
|
|
388
383
|
};
|
|
389
384
|
|
|
390
385
|
|
|
386
|
+
/**
|
|
387
|
+
* @brief Class representing a function argument variable in the SVFIR
|
|
388
|
+
*
|
|
389
|
+
* This class models function argument in the program analysis. It extends ValVar
|
|
390
|
+
* to specifically handle function argument.
|
|
391
|
+
*/
|
|
392
|
+
class ArgValVar: public ValVar
|
|
393
|
+
{
|
|
394
|
+
friend class SVFIRWriter;
|
|
395
|
+
friend class SVFIRReader;
|
|
396
|
+
|
|
397
|
+
private:
|
|
398
|
+
const CallGraphNode* cgNode;
|
|
399
|
+
u32_t argNo;
|
|
400
|
+
bool uncalled;
|
|
401
|
+
|
|
402
|
+
protected:
|
|
403
|
+
/// Constructor to create function argument (for SVFIRReader/deserialization)
|
|
404
|
+
ArgValVar(NodeID i, PNODEK ty = ArgNode) : ValVar(i, ty) {}
|
|
405
|
+
|
|
406
|
+
public:
|
|
407
|
+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
408
|
+
//@{
|
|
409
|
+
static inline bool classof(const ArgValVar*)
|
|
410
|
+
{
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
413
|
+
static inline bool classof(const ValVar* node)
|
|
414
|
+
{
|
|
415
|
+
return node->getNodeKind() == ArgNode;
|
|
416
|
+
}
|
|
417
|
+
static inline bool classof(const SVFVar* node)
|
|
418
|
+
{
|
|
419
|
+
return node->getNodeKind() == ArgNode;
|
|
420
|
+
}
|
|
421
|
+
static inline bool classof(const GenericPAGNodeTy* node)
|
|
422
|
+
{
|
|
423
|
+
return node->getNodeKind() == ArgNode;
|
|
424
|
+
}
|
|
425
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
426
|
+
{
|
|
427
|
+
return node->getNodeKind() == ArgNode;
|
|
428
|
+
}
|
|
429
|
+
//@}
|
|
430
|
+
|
|
431
|
+
/// Constructor
|
|
432
|
+
ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn, const CallGraphNode* callGraphNode,
|
|
433
|
+
bool isUncalled = false, PNODEK ty = ArgNode);
|
|
434
|
+
|
|
435
|
+
/// Return name of a LLVM value
|
|
436
|
+
inline const std::string getValueName() const
|
|
437
|
+
{
|
|
438
|
+
if (value)
|
|
439
|
+
return value->getName() + " (argument valvar)";
|
|
440
|
+
return " (argument valvar)";
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
virtual const SVFFunction* getFunction() const;
|
|
444
|
+
|
|
445
|
+
const SVFFunction* getParent() const;
|
|
446
|
+
|
|
447
|
+
/// Return the index of this formal argument in its containing function.
|
|
448
|
+
/// For example in "void foo(int a, float b)" a is 0 and b is 1.
|
|
449
|
+
inline u32_t getArgNo() const
|
|
450
|
+
{
|
|
451
|
+
return argNo;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
inline bool isArgOfUncalledFunction() const
|
|
455
|
+
{
|
|
456
|
+
return uncalled;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
virtual const std::string toString() const;
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
|
|
391
463
|
/*
|
|
392
464
|
* Gep Value (Pointer) variable, this variable can be dynamic generated for field sensitive analysis
|
|
393
465
|
* e.g. memcpy, temp gep value variable needs to be created
|
|
@@ -485,7 +485,6 @@ const SVFType* AbstractState::getPointeeElement(NodeID id)
|
|
|
485
485
|
|
|
486
486
|
u32_t AbstractState::getAllocaInstByteSize(const AddrStmt *addr)
|
|
487
487
|
{
|
|
488
|
-
SVFIR* svfir = PAG::getPAG();
|
|
489
488
|
if (const ObjVar* objvar = SVFUtil::dyn_cast<ObjVar>(addr->getRHSVar()))
|
|
490
489
|
{
|
|
491
490
|
objvar->getType();
|
|
@@ -497,18 +496,18 @@ u32_t AbstractState::getAllocaInstByteSize(const AddrStmt *addr)
|
|
|
497
496
|
|
|
498
497
|
else
|
|
499
498
|
{
|
|
500
|
-
const std::vector<
|
|
499
|
+
const std::vector<SVFVar*>& sizes = addr->getArrSize();
|
|
501
500
|
// Default element size is set to 1.
|
|
502
501
|
u32_t elementSize = 1;
|
|
503
502
|
u64_t res = elementSize;
|
|
504
|
-
for (const
|
|
503
|
+
for (const SVFVar* value: sizes)
|
|
505
504
|
{
|
|
506
|
-
if (!inVarToValTable(
|
|
505
|
+
if (!inVarToValTable(value->getId()))
|
|
507
506
|
{
|
|
508
|
-
(*this)[
|
|
507
|
+
(*this)[value->getId()] = IntervalValue(Options::MaxFieldLimit());
|
|
509
508
|
}
|
|
510
509
|
IntervalValue itv =
|
|
511
|
-
(*this)[
|
|
510
|
+
(*this)[value->getId()].getInterval();
|
|
512
511
|
res = res * itv.ub().getIntNumeral() > Options::MaxFieldLimit()? Options::MaxFieldLimit(): res * itv.ub().getIntNumeral();
|
|
513
512
|
}
|
|
514
513
|
return (u32_t)res;
|
package/svf/lib/Graphs/VFG.cpp
CHANGED
|
@@ -1073,29 +1073,29 @@ const SVFFunction* VFG::isFunEntryVFGNode(const VFGNode* node) const
|
|
|
1073
1073
|
}
|
|
1074
1074
|
|
|
1075
1075
|
|
|
1076
|
-
const
|
|
1076
|
+
const SVFVar* StmtVFGNode::getValue() const
|
|
1077
1077
|
{
|
|
1078
1078
|
return getPAGEdge()->getValue();
|
|
1079
1079
|
}
|
|
1080
1080
|
|
|
1081
|
-
const
|
|
1081
|
+
const SVFVar* CmpVFGNode::getValue() const
|
|
1082
1082
|
{
|
|
1083
|
-
return getRes()
|
|
1083
|
+
return getRes();
|
|
1084
1084
|
}
|
|
1085
1085
|
|
|
1086
|
-
const
|
|
1086
|
+
const SVFVar* BinaryOPVFGNode::getValue() const
|
|
1087
1087
|
{
|
|
1088
|
-
return getRes()
|
|
1088
|
+
return getRes();
|
|
1089
1089
|
}
|
|
1090
1090
|
|
|
1091
|
-
const
|
|
1091
|
+
const SVFVar* PHIVFGNode::getValue() const
|
|
1092
1092
|
{
|
|
1093
|
-
return getRes()->hasValue() ? getRes()
|
|
1093
|
+
return getRes()->hasValue() ? getRes(): nullptr;
|
|
1094
1094
|
}
|
|
1095
1095
|
|
|
1096
|
-
const
|
|
1096
|
+
const SVFVar* ArgumentVFGNode::getValue() const
|
|
1097
1097
|
{
|
|
1098
|
-
return param->hasValue() ? param
|
|
1098
|
+
return param->hasValue() ? param : nullptr;
|
|
1099
1099
|
}
|
|
1100
1100
|
|
|
1101
1101
|
/*!
|
package/svf/lib/MTA/MTA.cpp
CHANGED
|
@@ -164,7 +164,7 @@ void MTA::detect(SVFModule* module)
|
|
|
164
164
|
for (Set<const StoreStmt*>::const_iterator sit = stores.begin(), esit = stores.end(); sit != esit; ++sit)
|
|
165
165
|
{
|
|
166
166
|
const StoreStmt* store = *sit;
|
|
167
|
-
if(load->
|
|
167
|
+
if(SVFUtil::isa<GlobalICFGNode>(load->getICFGNode()) || SVFUtil::isa<GlobalICFGNode>(store->getICFGNode()))
|
|
168
168
|
continue;
|
|
169
169
|
if(mhp->mayHappenInParallelInst(load->getICFGNode(),store->getICFGNode()) && pta->alias(load->getRHSVarID(),store->getLHSVarID()))
|
|
170
170
|
if(lsa->isProtectedByCommonLock(load->getICFGNode(),store->getICFGNode()) == false)
|
|
@@ -399,27 +399,28 @@ bool SaberCondAllocator::isTestNotNullExpr(const ICFGNode* test) const
|
|
|
399
399
|
bool SaberCondAllocator::isTestContainsNullAndTheValue(const CmpStmt *cmp) const
|
|
400
400
|
{
|
|
401
401
|
|
|
402
|
+
// must be val var?
|
|
402
403
|
const SVFVar* op0 = cmp->getOpVar(0);
|
|
403
404
|
const SVFVar* op1 = cmp->getOpVar(1);
|
|
404
405
|
if (SVFUtil::isa<ConstantNullPtrValVar>(op1))
|
|
405
406
|
{
|
|
406
|
-
Set<const
|
|
407
|
+
Set<const SVFVar* > inDirVal;
|
|
407
408
|
inDirVal.insert(getCurEvalSVFGNode()->getValue());
|
|
408
409
|
for (const auto &it: getCurEvalSVFGNode()->getOutEdges())
|
|
409
410
|
{
|
|
410
411
|
inDirVal.insert(it->getDstNode()->getValue());
|
|
411
412
|
}
|
|
412
|
-
return inDirVal.find(op0
|
|
413
|
+
return inDirVal.find(op0) != inDirVal.end();
|
|
413
414
|
}
|
|
414
415
|
else if (SVFUtil::isa<ConstantNullPtrValVar>(op0))
|
|
415
416
|
{
|
|
416
|
-
Set<const
|
|
417
|
+
Set<const SVFVar* > inDirVal;
|
|
417
418
|
inDirVal.insert(getCurEvalSVFGNode()->getValue());
|
|
418
419
|
for (const auto &it: getCurEvalSVFGNode()->getOutEdges())
|
|
419
420
|
{
|
|
420
421
|
inDirVal.insert(it->getDstNode()->getValue());
|
|
421
422
|
}
|
|
422
|
-
return inDirVal.find(op1
|
|
423
|
+
return inDirVal.find(op1) != inDirVal.end();
|
|
423
424
|
}
|
|
424
425
|
return false;
|
|
425
426
|
}
|
|
@@ -222,6 +222,7 @@ cJSON* SVFIRWriter::virtToJson(const SVFVar* var)
|
|
|
222
222
|
CASE(DummyValNode, DummyValVar);
|
|
223
223
|
CASE(DummyObjNode, DummyObjVar);
|
|
224
224
|
CASE(FunObjNode, FunObjVar);
|
|
225
|
+
CASE(ArgNode, ArgValVar);
|
|
225
226
|
CASE(FunValNode, FunValVar);
|
|
226
227
|
CASE(HeapObjNode, HeapObjVar);
|
|
227
228
|
CASE(StackObjNode, StackObjVar);
|
package/svf/lib/SVFIR/SVFIR.cpp
CHANGED
|
@@ -670,11 +670,10 @@ bool SVFIR::isValidPointer(NodeID nodeId) const
|
|
|
670
670
|
|
|
671
671
|
if (node->hasValue() && node->isPointer())
|
|
672
672
|
{
|
|
673
|
-
if(const
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
}
|
|
673
|
+
if (const ValVar* pVar = pag->getBaseValVar(nodeId))
|
|
674
|
+
if (const ArgValVar* arg = SVFUtil::dyn_cast<ArgValVar>(pVar))
|
|
675
|
+
if (!(arg->getParent()->isDeclaration()))
|
|
676
|
+
return true;
|
|
678
677
|
}
|
|
679
678
|
|
|
680
679
|
if ((node->getInEdges().empty() && node->getOutEdges().empty()))
|
|
@@ -694,7 +693,7 @@ bool SVFIR::isValidTopLevelPtr(const SVFVar* node)
|
|
|
694
693
|
return true;
|
|
695
694
|
}
|
|
696
695
|
else if(node->hasValue())
|
|
697
|
-
return !SVFUtil::isArgOfUncalledFunction(node
|
|
696
|
+
return !SVFUtil::isArgOfUncalledFunction(node);
|
|
698
697
|
}
|
|
699
698
|
}
|
|
700
699
|
return false;
|
|
@@ -46,6 +46,7 @@ SVFVar::SVFVar(const SVFValue* val, NodeID i, PNODEK k) :
|
|
|
46
46
|
switch (k)
|
|
47
47
|
{
|
|
48
48
|
case ValNode:
|
|
49
|
+
case ArgNode:
|
|
49
50
|
case ConstantDataValNode:
|
|
50
51
|
case GlobalValNode:
|
|
51
52
|
case BlackHoleNode:
|
|
@@ -144,6 +145,39 @@ const std::string ObjVar::toString() const
|
|
|
144
145
|
return rawstr.str();
|
|
145
146
|
}
|
|
146
147
|
|
|
148
|
+
ArgValVar::ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn,
|
|
149
|
+
const SVF::CallGraphNode* callGraphNode, bool isUncalled,
|
|
150
|
+
SVF::SVFVar::PNODEK ty)
|
|
151
|
+
: ValVar(callGraphNode->getFunction()->getArg(argNo), i, ty, icn),
|
|
152
|
+
cgNode(callGraphNode), argNo(argNo), uncalled(isUncalled)
|
|
153
|
+
{
|
|
154
|
+
isPtr =
|
|
155
|
+
callGraphNode->getFunction()->getArg(argNo)->getType()->isPointerTy();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const SVFFunction* ArgValVar::getFunction() const
|
|
159
|
+
{
|
|
160
|
+
return getParent();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const SVFFunction* ArgValVar::getParent() const
|
|
164
|
+
{
|
|
165
|
+
return cgNode->getFunction();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const std::string ArgValVar::toString() const
|
|
169
|
+
{
|
|
170
|
+
std::string str;
|
|
171
|
+
std::stringstream rawstr(str);
|
|
172
|
+
rawstr << "ArgValVar ID: " << getId();
|
|
173
|
+
if (Options::ShowSVFIRValue())
|
|
174
|
+
{
|
|
175
|
+
rawstr << "\n";
|
|
176
|
+
rawstr << valueOnlyToString();
|
|
177
|
+
}
|
|
178
|
+
return rawstr.str();
|
|
179
|
+
}
|
|
180
|
+
|
|
147
181
|
const std::string GepValVar::toString() const
|
|
148
182
|
{
|
|
149
183
|
std::string str;
|
|
@@ -468,4 +502,3 @@ bool SVFVar::isConstDataOrAggDataButNotNullPtr() const
|
|
|
468
502
|
else
|
|
469
503
|
return false;
|
|
470
504
|
}
|
|
471
|
-
|
package/svf/lib/Util/SVFUtil.cpp
CHANGED
|
@@ -425,6 +425,14 @@ const SVFFunction* SVFUtil::getProgEntryFunction()
|
|
|
425
425
|
return nullptr;
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
bool SVFUtil::isArgOfUncalledFunction(const SVFVar* svfvar)
|
|
429
|
+
{
|
|
430
|
+
const ValVar* pVar = PAG::getPAG()->getBaseValVar(svfvar->getId());
|
|
431
|
+
if(const ArgValVar* arg = SVFUtil::dyn_cast<ArgValVar>(pVar))
|
|
432
|
+
return arg->isArgOfUncalledFunction();
|
|
433
|
+
else
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
428
436
|
|
|
429
437
|
const ObjVar* SVFUtil::getObjVarOfValVar(const SVF::ValVar* valVar)
|
|
430
438
|
{
|
|
@@ -207,13 +207,13 @@ const SVFVar* ThreadAPI::getLockVal(const ICFGNode *cs) const
|
|
|
207
207
|
const SVFVar* ThreadAPI::getJoinedThread(const CallICFGNode *cs) const
|
|
208
208
|
{
|
|
209
209
|
assert(isTDJoin(cs) && "not a thread join function!");
|
|
210
|
-
const
|
|
210
|
+
const ValVar* join = cs->getArgument(0);
|
|
211
211
|
for(const SVFStmt* stmt : join->getInEdges())
|
|
212
212
|
{
|
|
213
213
|
if(SVFUtil::isa<LoadStmt>(stmt))
|
|
214
214
|
return stmt->getSrcNode();
|
|
215
215
|
}
|
|
216
|
-
if(SVFUtil::isa<
|
|
216
|
+
if(SVFUtil::isa<ArgValVar>(join))
|
|
217
217
|
return join;
|
|
218
218
|
|
|
219
219
|
assert(false && "the value of the first argument at join is not a load instruction?");
|
|
@@ -307,8 +307,7 @@ protected:
|
|
|
307
307
|
AddrStmt* edge = addAddrEdge(src, dst);
|
|
308
308
|
if (inst.getArraySize())
|
|
309
309
|
{
|
|
310
|
-
|
|
311
|
-
edge->addArrSize(arrSz);
|
|
310
|
+
edge->addArrSize(pag->getGNode(getValueNode(inst.getArraySize())));
|
|
312
311
|
}
|
|
313
312
|
return edge;
|
|
314
313
|
}
|
|
@@ -334,8 +333,7 @@ protected:
|
|
|
334
333
|
if (cs->arg_size() > 0)
|
|
335
334
|
{
|
|
336
335
|
const llvm::Value* val = cs->getArgOperand(0);
|
|
337
|
-
|
|
338
|
-
edge->addArrSize(svfval);
|
|
336
|
+
edge->addArrSize(pag->getGNode(getValueNode(val)));
|
|
339
337
|
}
|
|
340
338
|
}
|
|
341
339
|
// Check if the function called is 'calloc' and process its arguments.
|
|
@@ -344,8 +342,10 @@ protected:
|
|
|
344
342
|
{
|
|
345
343
|
if (cs->arg_size() > 1)
|
|
346
344
|
{
|
|
347
|
-
edge->addArrSize(
|
|
348
|
-
|
|
345
|
+
edge->addArrSize(
|
|
346
|
+
pag->getGNode(getValueNode(cs->getArgOperand(0))));
|
|
347
|
+
edge->addArrSize(
|
|
348
|
+
pag->getGNode(getValueNode(cs->getArgOperand(1))));
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
else
|
|
@@ -353,8 +353,7 @@ protected:
|
|
|
353
353
|
if (cs->arg_size() > 0)
|
|
354
354
|
{
|
|
355
355
|
const llvm::Value* val = cs->getArgOperand(0);
|
|
356
|
-
|
|
357
|
-
edge->addArrSize(svfval);
|
|
356
|
+
edge->addArrSize(pag->getGNode(getValueNode(val)));
|
|
358
357
|
}
|
|
359
358
|
}
|
|
360
359
|
return edge;
|
|
@@ -245,6 +245,15 @@ void SVFIRBuilder::initialiseNodes()
|
|
|
245
245
|
// add value node representing the function
|
|
246
246
|
pag->addFunValNode(cgn, iter->second, icfgNode);
|
|
247
247
|
}
|
|
248
|
+
else if (auto argval = SVFUtil::dyn_cast<Argument>(llvmValue))
|
|
249
|
+
{
|
|
250
|
+
pag->addArgValNode(
|
|
251
|
+
iter->second, argval->getArgNo(), icfgNode,
|
|
252
|
+
llvmModuleSet()->getCallGraphNode(argval->getParent()),
|
|
253
|
+
LLVMUtil::isArgOfUncalledFunction(argval));
|
|
254
|
+
llvmModuleSet()->addToLLVMVal2SVFVarMap(
|
|
255
|
+
argval, pag->getGNode(iter->second));
|
|
256
|
+
}
|
|
248
257
|
else if (auto fpValue = SVFUtil::dyn_cast<ConstantFP>(llvmValue))
|
|
249
258
|
{
|
|
250
259
|
pag->addConstantFPValNode(iter->first, LLVMUtil::getDoubleValue(fpValue), iter->second, icfgNode);
|
|
@@ -1433,7 +1442,7 @@ void SVFIRBuilder::setCurrentBBAndValueForPAGEdge(PAGEdge* edge)
|
|
|
1433
1442
|
|
|
1434
1443
|
assert(curVal && "current Val is nullptr?");
|
|
1435
1444
|
edge->setBB(curBB!=nullptr ? curBB : nullptr);
|
|
1436
|
-
edge->setValue(curVal);
|
|
1445
|
+
edge->setValue(pag->getGNode(pag->getValueNode(curVal)));
|
|
1437
1446
|
// backmap in valuToEdgeMap
|
|
1438
1447
|
pag->mapValueToEdge(curVal, edge);
|
|
1439
1448
|
ICFGNode* icfgNode = pag->getICFG()->getGlobalICFGNode();
|
|
@@ -41,21 +41,21 @@ using namespace SVF;
|
|
|
41
41
|
/*!
|
|
42
42
|
* An example to query alias results of two SVF values
|
|
43
43
|
*/
|
|
44
|
-
SVF::AliasResult aliasQuery(PointerAnalysis* pta, const
|
|
44
|
+
SVF::AliasResult aliasQuery(PointerAnalysis* pta, const SVFVar* v1, const SVFVar* v2)
|
|
45
45
|
{
|
|
46
|
-
return pta->alias(v1, v2);
|
|
46
|
+
return pta->alias(v1->getId(), v2->getId());
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/*!
|
|
50
50
|
* An example to print points-to set of an SVF value
|
|
51
51
|
*/
|
|
52
|
-
std::string printPts(PointerAnalysis* pta, const
|
|
52
|
+
std::string printPts(PointerAnalysis* pta, const SVFVar* svfval)
|
|
53
53
|
{
|
|
54
54
|
|
|
55
55
|
std::string str;
|
|
56
56
|
raw_string_ostream rawstr(str);
|
|
57
57
|
|
|
58
|
-
NodeID pNodeId =
|
|
58
|
+
NodeID pNodeId = svfval->getId();
|
|
59
59
|
const PointsTo& pts = pta->getPts(pNodeId);
|
|
60
60
|
for (PointsTo::iterator ii = pts.begin(), ie = pts.end();
|
|
61
61
|
ii != ie; ii++)
|
|
@@ -105,13 +105,11 @@ void dummyVisit(const VFGNode* node)
|
|
|
105
105
|
/*!
|
|
106
106
|
* An example to query/collect all the uses of a definition of a value along value-flow graph (VFG)
|
|
107
107
|
*/
|
|
108
|
-
void traverseOnVFG(const SVFG* vfg, const
|
|
108
|
+
void traverseOnVFG(const SVFG* vfg, const SVFVar* svfval)
|
|
109
109
|
{
|
|
110
|
-
|
|
111
|
-
PAGNode* pNode = pag->getGNode(pag->getValueNode(svfval));
|
|
112
|
-
if (!vfg->hasDefSVFGNode(pNode))
|
|
110
|
+
if (!vfg->hasDefSVFGNode(svfval))
|
|
113
111
|
return;
|
|
114
|
-
const VFGNode* vNode = vfg->getDefSVFGNode(
|
|
112
|
+
const VFGNode* vNode = vfg->getDefSVFGNode(svfval);
|
|
115
113
|
FIFOWorkList<const VFGNode*> worklist;
|
|
116
114
|
Set<const VFGNode*> visited;
|
|
117
115
|
worklist.push(vNode);
|