svf-tools 1.0.1026 → 1.0.1028
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/SVFIR/SVFIR.h +26 -19
- package/svf/include/SVFIR/SVFVariables.h +89 -17
- package/svf/include/Util/SVFUtil.h +2 -0
- package/svf/lib/SVFIR/SVFFileSystem.cpp +1 -0
- package/svf/lib/SVFIR/SVFIR.cpp +7 -8
- package/svf/lib/SVFIR/SVFVariables.cpp +40 -9
- package/svf/lib/Util/SVFUtil.cpp +8 -0
- package/svf/lib/Util/ThreadAPI.cpp +2 -2
- package/svf-llvm/lib/SVFIRBuilder.cpp +23 -16
- package/svf-llvm/lib/SVFIRExtAPI.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.1028",
|
|
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;
|
|
@@ -572,23 +572,30 @@ private:
|
|
|
572
572
|
return addValNode(val, node, i);
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
-
NodeID addFunValNode(
|
|
575
|
+
NodeID addFunValNode(NodeID i, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode)
|
|
576
576
|
{
|
|
577
|
-
FunValVar* node = new FunValVar(
|
|
577
|
+
FunValVar* node = new FunValVar(i, icfgNode, callGraphNode);
|
|
578
578
|
return addValNode(nullptr, node, i);
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
-
|
|
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
|
+
|
|
588
|
+
inline NodeID addConstantFPValNode(const SVFValue* curInst, const NodeID i, double dval,
|
|
582
589
|
const ICFGNode* icfgNode)
|
|
583
590
|
{
|
|
584
|
-
SVFVar* node = new ConstantFPValVar(curInst,
|
|
591
|
+
SVFVar* node = new ConstantFPValVar(curInst, i, dval, icfgNode);
|
|
585
592
|
return addNode(node, i);
|
|
586
593
|
}
|
|
587
594
|
|
|
588
|
-
inline NodeID addConstantIntValNode(const SVFValue* curInst, const std::pair<s64_t, u64_t>& intValue,
|
|
595
|
+
inline NodeID addConstantIntValNode(const SVFValue* curInst, NodeID i, const std::pair<s64_t, u64_t>& intValue,
|
|
589
596
|
const ICFGNode* icfgNode)
|
|
590
597
|
{
|
|
591
|
-
SVFVar* node = new ConstantIntValVar(curInst, intValue.first, intValue.second,
|
|
598
|
+
SVFVar* node = new ConstantIntValVar(curInst, i, intValue.first, intValue.second, icfgNode);
|
|
592
599
|
return addNode(node, i);
|
|
593
600
|
}
|
|
594
601
|
|
|
@@ -622,47 +629,47 @@ private:
|
|
|
622
629
|
/**
|
|
623
630
|
* Creates and adds a heap object node to the SVFIR
|
|
624
631
|
*/
|
|
625
|
-
inline NodeID addHeapObjNode(const SVFValue* val, const SVFFunction* f
|
|
632
|
+
inline NodeID addHeapObjNode(const SVFValue* val, NodeID i, const SVFFunction* f)
|
|
626
633
|
{
|
|
627
634
|
const MemObj* mem = getMemObj(val);
|
|
628
635
|
assert(mem->getId() == i && "not same object id?");
|
|
629
636
|
memToFieldsMap[i].set(i);
|
|
630
|
-
HeapObjVar *node = new HeapObjVar(
|
|
637
|
+
HeapObjVar *node = new HeapObjVar(i, mem, val->getType(), f);
|
|
631
638
|
return addObjNode(val, node, i);
|
|
632
639
|
}
|
|
633
640
|
|
|
634
641
|
/**
|
|
635
642
|
* Creates and adds a stack object node to the SVFIR
|
|
636
643
|
*/
|
|
637
|
-
inline NodeID addStackObjNode(const SVFValue* val, const SVFFunction* f
|
|
644
|
+
inline NodeID addStackObjNode(const SVFValue* val, NodeID i, const SVFFunction* f)
|
|
638
645
|
{
|
|
639
646
|
const MemObj* mem = getMemObj(val);
|
|
640
647
|
assert(mem->getId() == i && "not same object id?");
|
|
641
648
|
memToFieldsMap[i].set(i);
|
|
642
|
-
StackObjVar *node = new StackObjVar(
|
|
649
|
+
StackObjVar *node = new StackObjVar(i, mem, val->getType(), f);
|
|
643
650
|
return addObjNode(val, node, i);
|
|
644
651
|
}
|
|
645
652
|
|
|
646
|
-
NodeID addFunObjNode(const CallGraphNode* callGraphNode
|
|
653
|
+
NodeID addFunObjNode(NodeID id, const CallGraphNode* callGraphNode);
|
|
647
654
|
|
|
648
655
|
|
|
649
|
-
inline NodeID addConstantFPObjNode(const SVFValue* curInst,
|
|
656
|
+
inline NodeID addConstantFPObjNode(const SVFValue* curInst, NodeID i, double dval)
|
|
650
657
|
{
|
|
651
658
|
const MemObj* mem = getMemObj(curInst);
|
|
652
659
|
NodeID base = mem->getId();
|
|
653
660
|
memToFieldsMap[base].set(mem->getId());
|
|
654
|
-
ConstantFPObjVar* node = new ConstantFPObjVar(curInst,
|
|
661
|
+
ConstantFPObjVar* node = new ConstantFPObjVar(curInst, i, dval, mem);
|
|
655
662
|
return addObjNode(curInst, node, mem->getId());
|
|
656
663
|
}
|
|
657
664
|
|
|
658
665
|
|
|
659
|
-
inline NodeID addConstantIntObjNode(const SVFValue* curInst, const std::pair<s64_t, u64_t>& intValue
|
|
666
|
+
inline NodeID addConstantIntObjNode(const SVFValue* curInst, NodeID i, const std::pair<s64_t, u64_t>& intValue)
|
|
660
667
|
{
|
|
661
668
|
const MemObj* mem = getMemObj(curInst);
|
|
662
669
|
NodeID base = mem->getId();
|
|
663
670
|
memToFieldsMap[base].set(mem->getId());
|
|
664
671
|
ConstantIntObjVar* node =
|
|
665
|
-
new ConstantIntObjVar(curInst, intValue.first, intValue.second,
|
|
672
|
+
new ConstantIntObjVar(curInst, i, intValue.first, intValue.second, mem);
|
|
666
673
|
return addObjNode(curInst, node, mem->getId());
|
|
667
674
|
}
|
|
668
675
|
|
|
@@ -695,15 +702,15 @@ private:
|
|
|
695
702
|
}
|
|
696
703
|
|
|
697
704
|
/// Add a unique return node for a procedure
|
|
698
|
-
inline NodeID addRetNode(const CallGraphNode* callGraphNode
|
|
705
|
+
inline NodeID addRetNode(NodeID i, const CallGraphNode* callGraphNode)
|
|
699
706
|
{
|
|
700
|
-
SVFVar *node = new RetPN(callGraphNode
|
|
707
|
+
SVFVar *node = new RetPN(i, callGraphNode);
|
|
701
708
|
return addRetNode(callGraphNode, node, i);
|
|
702
709
|
}
|
|
703
710
|
/// Add a unique vararg node for a procedure
|
|
704
|
-
inline NodeID addVarargNode(const CallGraphNode* val
|
|
711
|
+
inline NodeID addVarargNode(NodeID i, const CallGraphNode* val)
|
|
705
712
|
{
|
|
706
|
-
SVFVar *node = new VarArgPN(val
|
|
713
|
+
SVFVar *node = new VarArgPN(i, val);
|
|
707
714
|
return addNode(node,i);
|
|
708
715
|
}
|
|
709
716
|
|
|
@@ -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
|
|
@@ -652,8 +724,8 @@ public:
|
|
|
652
724
|
//@}
|
|
653
725
|
|
|
654
726
|
/// Constructor
|
|
655
|
-
HeapObjVar(const
|
|
656
|
-
const
|
|
727
|
+
HeapObjVar(NodeID i, const MemObj* mem, const SVFType* svfType,
|
|
728
|
+
const SVFFunction* fun, PNODEK ty = HeapObjNode);
|
|
657
729
|
|
|
658
730
|
/// Return name of a LLVM value
|
|
659
731
|
inline const std::string getValueName() const
|
|
@@ -713,8 +785,8 @@ public:
|
|
|
713
785
|
//@}
|
|
714
786
|
|
|
715
787
|
/// Constructor
|
|
716
|
-
StackObjVar(const
|
|
717
|
-
const
|
|
788
|
+
StackObjVar(NodeID i, const MemObj* mem, const SVFType* svfType,
|
|
789
|
+
const SVFFunction* fun, PNODEK ty = StackObjNode);
|
|
718
790
|
|
|
719
791
|
/// Return name of a LLVM value
|
|
720
792
|
inline const std::string getValueName() const
|
|
@@ -766,7 +838,7 @@ public:
|
|
|
766
838
|
}
|
|
767
839
|
|
|
768
840
|
/// Constructor
|
|
769
|
-
FunValVar(
|
|
841
|
+
FunValVar(NodeID i, const ICFGNode* icn, const CallGraphNode* cgn,
|
|
770
842
|
PNODEK ty = FunValNode);
|
|
771
843
|
|
|
772
844
|
virtual const std::string toString() const;
|
|
@@ -814,7 +886,7 @@ public:
|
|
|
814
886
|
//@}
|
|
815
887
|
|
|
816
888
|
/// Constructor
|
|
817
|
-
FunObjVar(
|
|
889
|
+
FunObjVar(NodeID i, const MemObj* mem, const CallGraphNode* cgNode,
|
|
818
890
|
PNODEK ty = FunObjNode);
|
|
819
891
|
|
|
820
892
|
inline const CallGraphNode* getCallGraphNode() const
|
|
@@ -997,7 +1069,7 @@ public:
|
|
|
997
1069
|
}
|
|
998
1070
|
|
|
999
1071
|
/// Constructor
|
|
1000
|
-
ConstantFPValVar(const SVFValue* val,
|
|
1072
|
+
ConstantFPValVar(const SVFValue* val, NodeID i, double dv, const ICFGNode* icn,
|
|
1001
1073
|
PNODEK ty = ConstantFPValNode)
|
|
1002
1074
|
: ConstantDataValVar(val, i, icn, ty), dval(dv)
|
|
1003
1075
|
{
|
|
@@ -1056,7 +1128,7 @@ public:
|
|
|
1056
1128
|
}
|
|
1057
1129
|
|
|
1058
1130
|
/// Constructor
|
|
1059
|
-
ConstantIntValVar(const SVFValue* val, s64_t sv, u64_t zv,
|
|
1131
|
+
ConstantIntValVar(const SVFValue* val, NodeID i, s64_t sv, u64_t zv, const ICFGNode* icn,
|
|
1060
1132
|
PNODEK ty = ConstantIntValNode)
|
|
1061
1133
|
: ConstantDataValVar(val, i, icn, ty), zval(zv), sval(sv)
|
|
1062
1134
|
{
|
|
@@ -1255,7 +1327,7 @@ public:
|
|
|
1255
1327
|
//@}
|
|
1256
1328
|
|
|
1257
1329
|
/// Constructor
|
|
1258
|
-
ConstantFPObjVar(const SVFValue* val,
|
|
1330
|
+
ConstantFPObjVar(const SVFValue* val, NodeID i, double dv, const MemObj* m, PNODEK ty = ConstantFPObjNode)
|
|
1259
1331
|
: ConstantDataObjVar(val, i, m, ty), dval(dv)
|
|
1260
1332
|
{
|
|
1261
1333
|
}
|
|
@@ -1330,7 +1402,7 @@ public:
|
|
|
1330
1402
|
//@}
|
|
1331
1403
|
|
|
1332
1404
|
/// Constructor
|
|
1333
|
-
ConstantIntObjVar(const SVFValue* val, s64_t sv, u64_t zv,
|
|
1405
|
+
ConstantIntObjVar(const SVFValue* val, NodeID i, s64_t sv, u64_t zv, const MemObj* m, PNODEK ty = ConstantIntObjNode)
|
|
1334
1406
|
: ConstantDataObjVar(val, i, m, ty), zval(zv), sval(sv)
|
|
1335
1407
|
{
|
|
1336
1408
|
}
|
|
@@ -1433,7 +1505,7 @@ public:
|
|
|
1433
1505
|
|
|
1434
1506
|
|
|
1435
1507
|
/// Constructor
|
|
1436
|
-
RetPN(const CallGraphNode* node
|
|
1508
|
+
RetPN(NodeID i, const CallGraphNode* node);
|
|
1437
1509
|
|
|
1438
1510
|
inline const CallGraphNode* getCallGraphNode() const
|
|
1439
1511
|
{
|
|
@@ -1487,7 +1559,7 @@ public:
|
|
|
1487
1559
|
//@}
|
|
1488
1560
|
|
|
1489
1561
|
/// Constructor
|
|
1490
|
-
VarArgPN(const CallGraphNode* node
|
|
1562
|
+
VarArgPN(NodeID i, const CallGraphNode* node) : ValVar(nullptr, i, VarargNode), callGraphNode(node) {}
|
|
1491
1563
|
|
|
1492
1564
|
virtual const SVFFunction* getFunction() const;
|
|
1493
1565
|
|
|
@@ -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
|
@@ -472,14 +472,14 @@ NodeID SVFIR::addFIObjNode(const MemObj* obj)
|
|
|
472
472
|
return addObjNode(obj->getValue(), node, obj->getId());
|
|
473
473
|
}
|
|
474
474
|
|
|
475
|
-
NodeID SVFIR::addFunObjNode(const CallGraphNode* callGraphNode
|
|
475
|
+
NodeID SVFIR::addFunObjNode(NodeID id, const CallGraphNode* callGraphNode)
|
|
476
476
|
{
|
|
477
477
|
const MemObj* mem = getMemObj(callGraphNode->getFunction());
|
|
478
478
|
assert(mem->getId() == id && "not same object id?");
|
|
479
479
|
//assert(findPAGNode(i) == false && "this node should not be created before");
|
|
480
480
|
NodeID base = mem->getId();
|
|
481
481
|
memToFieldsMap[base].set(mem->getId());
|
|
482
|
-
FunObjVar*node = new FunObjVar(
|
|
482
|
+
FunObjVar*node = new FunObjVar(id, mem, callGraphNode);
|
|
483
483
|
return addObjNode(mem->getValue(), node, mem->getId());
|
|
484
484
|
}
|
|
485
485
|
|
|
@@ -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;
|
|
@@ -157,7 +191,7 @@ const std::string GepValVar::toString() const
|
|
|
157
191
|
return rawstr.str();
|
|
158
192
|
}
|
|
159
193
|
|
|
160
|
-
RetPN::RetPN(const CallGraphNode* node
|
|
194
|
+
RetPN::RetPN(NodeID i, const CallGraphNode* node) : ValVar(i, RetNode), callGraphNode(node)
|
|
161
195
|
{
|
|
162
196
|
isPtr = node->getFunction()->getReturnType()->isPointerTy();
|
|
163
197
|
}
|
|
@@ -198,8 +232,8 @@ const std::string BaseObjVar::toString() const
|
|
|
198
232
|
return rawstr.str();
|
|
199
233
|
}
|
|
200
234
|
|
|
201
|
-
HeapObjVar::HeapObjVar(const
|
|
202
|
-
const
|
|
235
|
+
HeapObjVar::HeapObjVar(NodeID i, const MemObj* mem, const SVFType* svfType,
|
|
236
|
+
const SVFFunction* f, PNODEK ty)
|
|
203
237
|
: BaseObjVar(mem->getValue(), i, mem, ty)
|
|
204
238
|
{
|
|
205
239
|
isPtr = svfType->isPointerTy();
|
|
@@ -219,8 +253,7 @@ const std::string HeapObjVar::toString() const
|
|
|
219
253
|
return rawstr.str();
|
|
220
254
|
}
|
|
221
255
|
|
|
222
|
-
StackObjVar::StackObjVar(const
|
|
223
|
-
const MemObj* mem, PNODEK ty)
|
|
256
|
+
StackObjVar::StackObjVar(NodeID i, const MemObj* mem, const SVFType* svfType, const SVFFunction* f, PNODEK ty)
|
|
224
257
|
: BaseObjVar(mem->getValue(), i, mem, ty)
|
|
225
258
|
{
|
|
226
259
|
isPtr = svfType->isPointerTy();
|
|
@@ -242,8 +275,7 @@ const std::string StackObjVar::toString() const
|
|
|
242
275
|
|
|
243
276
|
|
|
244
277
|
|
|
245
|
-
FunValVar::FunValVar(
|
|
246
|
-
PNODEK ty)
|
|
278
|
+
FunValVar::FunValVar(NodeID i, const ICFGNode* icn, const CallGraphNode* cgn, PNODEK ty)
|
|
247
279
|
: ValVar(cgn->getFunction(), i, ty, icn), callGraphNode(cgn)
|
|
248
280
|
{
|
|
249
281
|
isPtr = cgn->getFunction()->getType()->isPointerTy();
|
|
@@ -392,7 +424,7 @@ const std::string ConstantNullPtrObjVar::toString() const
|
|
|
392
424
|
return rawstr.str();
|
|
393
425
|
}
|
|
394
426
|
|
|
395
|
-
FunObjVar::FunObjVar(
|
|
427
|
+
FunObjVar::FunObjVar(NodeID i, const MemObj* mem, const CallGraphNode* cgNode,
|
|
396
428
|
PNODEK ty)
|
|
397
429
|
: BaseObjVar(mem->getValue(), i, mem, ty), callGraphNode(cgNode)
|
|
398
430
|
{
|
|
@@ -468,4 +500,3 @@ bool SVFVar::isConstDataOrAggDataButNotNullPtr() const
|
|
|
468
500
|
else
|
|
469
501
|
return false;
|
|
470
502
|
}
|
|
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?");
|
|
@@ -243,17 +243,26 @@ void SVFIRBuilder::initialiseNodes()
|
|
|
243
243
|
{
|
|
244
244
|
const CallGraphNode* cgn = llvmModuleSet()->getCallGraphNode(func);
|
|
245
245
|
// add value node representing the function
|
|
246
|
-
pag->addFunValNode(
|
|
246
|
+
pag->addFunValNode(iter->second, icfgNode, cgn);
|
|
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));
|
|
247
256
|
}
|
|
248
257
|
else if (auto fpValue = SVFUtil::dyn_cast<ConstantFP>(llvmValue))
|
|
249
258
|
{
|
|
250
|
-
pag->addConstantFPValNode(iter->first, LLVMUtil::getDoubleValue(fpValue),
|
|
259
|
+
pag->addConstantFPValNode(iter->first, iter->second, LLVMUtil::getDoubleValue(fpValue), icfgNode);
|
|
251
260
|
llvmModuleSet()->addToLLVMVal2SVFVarMap(
|
|
252
261
|
fpValue, pag->getGNode(iter->second));
|
|
253
262
|
}
|
|
254
263
|
else if (auto intValue = SVFUtil::dyn_cast<ConstantInt>(llvmValue))
|
|
255
264
|
{
|
|
256
|
-
pag->addConstantIntValNode(iter->first, LLVMUtil::getIntegerValue(intValue),
|
|
265
|
+
pag->addConstantIntValNode(iter->first, iter->second, LLVMUtil::getIntegerValue(intValue), icfgNode);
|
|
257
266
|
llvmModuleSet()->addToLLVMVal2SVFVarMap(
|
|
258
267
|
intValue, pag->getGNode(iter->second));
|
|
259
268
|
}
|
|
@@ -300,14 +309,14 @@ void SVFIRBuilder::initialiseNodes()
|
|
|
300
309
|
// Check if the value is a function and add a function object node
|
|
301
310
|
if (const Function* func = SVFUtil::dyn_cast<Function>(llvmValue))
|
|
302
311
|
{
|
|
303
|
-
pag->addFunObjNode(llvmModuleSet()->getCallGraphNode(func)
|
|
312
|
+
pag->addFunObjNode(iter->second, llvmModuleSet()->getCallGraphNode(func));
|
|
304
313
|
}
|
|
305
314
|
// Check if the value is a heap object and add a heap object node
|
|
306
315
|
else if (LLVMUtil::isHeapObj(llvmValue))
|
|
307
316
|
{
|
|
308
317
|
const SVFFunction* f =
|
|
309
318
|
SVFUtil::cast<SVFInstruction>(iter->first)->getFunction();
|
|
310
|
-
pag->addHeapObjNode(iter->first,
|
|
319
|
+
pag->addHeapObjNode(iter->first, iter->second, f);
|
|
311
320
|
llvmModuleSet()->addToLLVMVal2SVFVarMap(
|
|
312
321
|
llvmValue, pag->getGNode(iter->second));
|
|
313
322
|
}
|
|
@@ -316,19 +325,19 @@ void SVFIRBuilder::initialiseNodes()
|
|
|
316
325
|
{
|
|
317
326
|
const SVFFunction* f =
|
|
318
327
|
SVFUtil::cast<SVFInstruction>(iter->first)->getFunction();
|
|
319
|
-
pag->addStackObjNode(iter->first,
|
|
328
|
+
pag->addStackObjNode(iter->first, iter->second, f);
|
|
320
329
|
llvmModuleSet()->addToLLVMVal2SVFVarMap(
|
|
321
330
|
llvmValue, pag->getGNode(iter->second));
|
|
322
331
|
}
|
|
323
332
|
else if (auto fpValue = SVFUtil::dyn_cast<ConstantFP>(llvmValue))
|
|
324
333
|
{
|
|
325
|
-
pag->addConstantFPObjNode(iter->first, LLVMUtil::getDoubleValue(fpValue)
|
|
334
|
+
pag->addConstantFPObjNode(iter->first, iter->second, LLVMUtil::getDoubleValue(fpValue));
|
|
326
335
|
llvmModuleSet()->addToLLVMVal2SVFVarMap(
|
|
327
336
|
fpValue, pag->getGNode(iter->second));
|
|
328
337
|
}
|
|
329
338
|
else if (auto intValue = SVFUtil::dyn_cast<ConstantInt>(llvmValue))
|
|
330
339
|
{
|
|
331
|
-
pag->addConstantIntObjNode(iter->first, LLVMUtil::getIntegerValue(intValue)
|
|
340
|
+
pag->addConstantIntObjNode(iter->first, iter->second, LLVMUtil::getIntegerValue(intValue));
|
|
332
341
|
llvmModuleSet()->addToLLVMVal2SVFVarMap(
|
|
333
342
|
intValue, pag->getGNode(iter->second));
|
|
334
343
|
}
|
|
@@ -362,10 +371,9 @@ void SVFIRBuilder::initialiseNodes()
|
|
|
362
371
|
++iter)
|
|
363
372
|
{
|
|
364
373
|
DBOUT(DPAGBuild, outs() << "add ret node " << iter->second << "\n");
|
|
365
|
-
pag->addRetNode(
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
iter->second);
|
|
374
|
+
pag->addRetNode(iter->second,
|
|
375
|
+
llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(
|
|
376
|
+
llvmModuleSet()->getLLVMValue(iter->first))));
|
|
369
377
|
}
|
|
370
378
|
|
|
371
379
|
for (SymbolTableInfo::FunToIDMapTy::iterator iter =
|
|
@@ -373,10 +381,9 @@ void SVFIRBuilder::initialiseNodes()
|
|
|
373
381
|
iter != symTable->varargSyms().end(); ++iter)
|
|
374
382
|
{
|
|
375
383
|
DBOUT(DPAGBuild, outs() << "add vararg node " << iter->second << "\n");
|
|
376
|
-
pag->addVarargNode(
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
iter->second);
|
|
384
|
+
pag->addVarargNode(iter->second,
|
|
385
|
+
llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(
|
|
386
|
+
llvmModuleSet()->getLLVMValue(iter->first))));
|
|
380
387
|
}
|
|
381
388
|
|
|
382
389
|
/// add address edges for constant nodes.
|
|
@@ -65,7 +65,7 @@ const Type* SVFIRBuilder::getBaseTypeAndFlattenedFields(const Value* V, std::vec
|
|
|
65
65
|
{
|
|
66
66
|
SymbolTableBuilder builder(pag->getSymbolInfo());
|
|
67
67
|
builder.collectSym(offset);
|
|
68
|
-
pag->addConstantIntValNode(svfOffset,
|
|
68
|
+
pag->addConstantIntValNode(svfOffset, pag->getSymbolInfo()->getValSym(svfOffset), LLVMUtil::getIntegerValue(offset), nullptr);
|
|
69
69
|
}
|
|
70
70
|
ls.addOffsetVarAndGepTypePair(getPAG()->getGNode(getPAG()->getValueNode(svfOffset)), nullptr);
|
|
71
71
|
fields.push_back(ls);
|