svf-tools 1.0.1028 → 1.0.1030
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/DDA/DDAVFSolver.h +5 -7
- package/svf/include/Graphs/ConsG.h +2 -2
- package/svf/include/Graphs/IRGraph.h +5 -18
- package/svf/include/MemoryModel/PointerAnalysis.h +7 -7
- package/svf/include/SVFIR/SVFFileSystem.h +0 -12
- package/svf/include/SVFIR/SVFIR.h +84 -106
- package/svf/include/SVFIR/SVFVariables.h +237 -83
- package/svf/include/SVFIR/SymbolTableInfo.h +18 -136
- package/svf/lib/AE/Core/AbstractState.cpp +5 -6
- package/svf/lib/AE/Svfexe/AEDetector.cpp +6 -8
- package/svf/lib/AE/Svfexe/AbsExtAPI.cpp +6 -6
- package/svf/lib/CFL/CFLGraphBuilder.cpp +2 -2
- package/svf/lib/DDA/ContextDDA.cpp +11 -15
- package/svf/lib/Graphs/ThreadCallGraph.cpp +2 -2
- package/svf/lib/MSSA/MemRegion.cpp +7 -5
- package/svf/lib/MemoryModel/PointerAnalysis.cpp +3 -3
- package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +17 -10
- package/svf/lib/SABER/SaberSVFGBuilder.cpp +6 -4
- package/svf/lib/SVFIR/PAGBuilderFromFile.cpp +1 -2
- package/svf/lib/SVFIR/SVFFileSystem.cpp +1 -205
- package/svf/lib/SVFIR/SVFIR.cpp +21 -44
- package/svf/lib/SVFIR/SVFVariables.cpp +7 -16
- package/svf/lib/SVFIR/SymbolTableInfo.cpp +13 -165
- package/svf/lib/Util/SVFStat.cpp +1 -1
- package/svf/lib/WPA/AndersenSFR.cpp +4 -2
- package/svf/lib/WPA/FlowSensitive.cpp +7 -4
- package/svf/lib/WPA/FlowSensitiveStat.cpp +3 -3
- package/svf/lib/WPA/VersionedFlowSensitive.cpp +2 -1
- package/svf/lib/WPA/VersionedFlowSensitiveStat.cpp +3 -3
- package/svf-llvm/include/SVF-LLVM/LLVMModule.h +4 -4
- package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +1 -1
- package/svf-llvm/include/SVF-LLVM/SymbolTableBuilder.h +2 -2
- package/svf-llvm/lib/LLVMModule.cpp +2 -2
- package/svf-llvm/lib/SVFIRBuilder.cpp +41 -60
- package/svf-llvm/lib/SymbolTableBuilder.cpp +23 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1030",
|
|
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": {
|
|
@@ -473,8 +473,6 @@ protected:
|
|
|
473
473
|
NodeID id = getPtrNodeID(var);
|
|
474
474
|
const BaseObjVar* baseObj = _pag->getBaseObject(id);
|
|
475
475
|
assert(baseObj && "base object is null??");
|
|
476
|
-
const MemObj* obj = _pag->getObject(id);
|
|
477
|
-
assert(obj && "object not found!!");
|
|
478
476
|
if(SVFUtil::isa<StackObjVar>(baseObj))
|
|
479
477
|
{
|
|
480
478
|
if(const SVFFunction* svffun = _pag->getGNode(id)->getFunction())
|
|
@@ -645,14 +643,14 @@ protected:
|
|
|
645
643
|
|
|
646
644
|
inline bool isArrayCondMemObj(const CVar& var) const
|
|
647
645
|
{
|
|
648
|
-
const
|
|
649
|
-
assert(
|
|
650
|
-
return
|
|
646
|
+
const BaseObjVar* obj = _pag->getBaseObject(getPtrNodeID(var));
|
|
647
|
+
assert(obj && "base object is null??");
|
|
648
|
+
return obj->isArray();
|
|
651
649
|
}
|
|
652
650
|
inline bool isFieldInsenCondMemObj(const CVar& var) const
|
|
653
651
|
{
|
|
654
|
-
const
|
|
655
|
-
return
|
|
652
|
+
const BaseObjVar* baseObj = _pag->getBaseObject(getPtrNodeID(var));
|
|
653
|
+
return baseObj->isFieldInsensitive();
|
|
656
654
|
}
|
|
657
655
|
//@}
|
|
658
656
|
private:
|
|
@@ -323,8 +323,8 @@ public:
|
|
|
323
323
|
}
|
|
324
324
|
inline bool isSingleFieldObj(NodeID id) const
|
|
325
325
|
{
|
|
326
|
-
const
|
|
327
|
-
return (
|
|
326
|
+
const BaseObjVar* baseObj = pag->getBaseObject(id);
|
|
327
|
+
return (baseObj->getMaxFieldOffsetLimit() == 1);
|
|
328
328
|
}
|
|
329
329
|
/// Get a field of a memory object
|
|
330
330
|
inline NodeID getGepObjVar(NodeID id, const APOffset& apOffset)
|
|
@@ -65,10 +65,11 @@ protected:
|
|
|
65
65
|
SymbolTableInfo* symInfo;
|
|
66
66
|
|
|
67
67
|
/// Add a node into the graph
|
|
68
|
-
inline NodeID addNode(SVFVar* node
|
|
68
|
+
inline NodeID addNode(SVFVar* node)
|
|
69
69
|
{
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
assert(node && "cannot add a null node");
|
|
71
|
+
addGNode(node->getId(),node);
|
|
72
|
+
return node->getId();
|
|
72
73
|
}
|
|
73
74
|
/// Add an edge into the graph
|
|
74
75
|
bool addEdge(SVFVar* src, SVFVar* dst, SVFStmt* edge);
|
|
@@ -94,12 +95,6 @@ protected:
|
|
|
94
95
|
inserted.first->second.emplace(edge);
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
|
-
/// get MemObj according to LLVM value
|
|
98
|
-
inline const MemObj* getMemObj(const SVFValue* val) const
|
|
99
|
-
{
|
|
100
|
-
return symInfo->getObj(symInfo->getObjSym(val));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
98
|
public:
|
|
104
99
|
IRGraph(bool buildFromFile)
|
|
105
100
|
: fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0)
|
|
@@ -174,14 +169,6 @@ public:
|
|
|
174
169
|
{
|
|
175
170
|
return symInfo->nullPtrSymID();
|
|
176
171
|
}
|
|
177
|
-
inline const MemObj* getBlackHoleObj() const
|
|
178
|
-
{
|
|
179
|
-
return symInfo->getBlkObj();
|
|
180
|
-
}
|
|
181
|
-
inline const MemObj* getConstantObj() const
|
|
182
|
-
{
|
|
183
|
-
return symInfo->getConstantObj();
|
|
184
|
-
}
|
|
185
172
|
|
|
186
173
|
inline u32_t getValueNodeNum() const
|
|
187
174
|
{
|
|
@@ -189,7 +176,7 @@ public:
|
|
|
189
176
|
}
|
|
190
177
|
inline u32_t getObjectNodeNum() const
|
|
191
178
|
{
|
|
192
|
-
return symInfo->
|
|
179
|
+
return symInfo->idToObjTypeInfoMap().size();
|
|
193
180
|
}
|
|
194
181
|
inline u32_t getNodeNumAfterPAGBuild() const
|
|
195
182
|
{
|
|
@@ -309,9 +309,9 @@ public:
|
|
|
309
309
|
|
|
310
310
|
inline bool isArrayMemObj(NodeID id) const
|
|
311
311
|
{
|
|
312
|
-
const
|
|
313
|
-
assert(
|
|
314
|
-
return
|
|
312
|
+
const BaseObjVar* obj = pag->getBaseObject(id);
|
|
313
|
+
assert(obj && "base object is null??");
|
|
314
|
+
return obj->isArray();
|
|
315
315
|
}
|
|
316
316
|
//@}
|
|
317
317
|
|
|
@@ -339,13 +339,13 @@ public:
|
|
|
339
339
|
}
|
|
340
340
|
inline void setObjFieldInsensitive(NodeID id)
|
|
341
341
|
{
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
BaseObjVar* baseObj = const_cast<BaseObjVar*>(pag->getBaseObject(id));
|
|
343
|
+
baseObj->setFieldInsensitive();
|
|
344
344
|
}
|
|
345
345
|
inline bool isFieldInsensitive(NodeID id) const
|
|
346
346
|
{
|
|
347
|
-
const
|
|
348
|
-
return
|
|
347
|
+
const BaseObjVar* baseObj = pag->getBaseObject(id);
|
|
348
|
+
return baseObj->isFieldInsensitive();
|
|
349
349
|
}
|
|
350
350
|
///@}
|
|
351
351
|
|
|
@@ -129,8 +129,6 @@ class SVFMetadataAsValue;
|
|
|
129
129
|
|
|
130
130
|
class SVFLoopAndDomInfo; // Part of SVFFunction
|
|
131
131
|
|
|
132
|
-
// Classes created upon buildSymbolTableInfo
|
|
133
|
-
class MemObj;
|
|
134
132
|
|
|
135
133
|
// Classes created upon ICFG construction
|
|
136
134
|
class ICFGNode;
|
|
@@ -422,7 +420,6 @@ private:
|
|
|
422
420
|
|
|
423
421
|
cJSON* toJson(const AccessPath& ap);
|
|
424
422
|
cJSON* toJson(const SVFLoop* loop);
|
|
425
|
-
cJSON* toJson(const MemObj* memObj);
|
|
426
423
|
cJSON* toJson(const ObjTypeInfo* objTypeInfo); // Only owned by MemObj
|
|
427
424
|
cJSON* toJson(const SVFLoopAndDomInfo* ldInfo); // Only owned by SVFFunction
|
|
428
425
|
cJSON* toJson(const StInfo* stInfo);
|
|
@@ -528,7 +525,6 @@ private:
|
|
|
528
525
|
|
|
529
526
|
// Other classes
|
|
530
527
|
cJSON* contentToJson(const SVFLoop* loop);
|
|
531
|
-
cJSON* contentToJson(const MemObj* memObj); // Owned by SymbolTable->objMap
|
|
532
528
|
cJSON* contentToJson(const StInfo* stInfo);
|
|
533
529
|
///@}
|
|
534
530
|
|
|
@@ -899,13 +895,8 @@ class SymbolTableInfoReader
|
|
|
899
895
|
|
|
900
896
|
private:
|
|
901
897
|
const cJSON* symTabFieldJson = nullptr;
|
|
902
|
-
ReaderIDToObjMap<MemObj> memObjMap;
|
|
903
898
|
|
|
904
899
|
public:
|
|
905
|
-
inline MemObj* getMemObjPtr(unsigned id) const
|
|
906
|
-
{
|
|
907
|
-
return memObjMap.getPtr(id);
|
|
908
|
-
}
|
|
909
900
|
|
|
910
901
|
template <typename MemObjCreator>
|
|
911
902
|
void createObjs(const cJSON* symTabJson, MemObjCreator memObjCreator)
|
|
@@ -915,7 +906,6 @@ public:
|
|
|
915
906
|
|
|
916
907
|
const cJSON* const allMemObj = symTabJson->child;
|
|
917
908
|
CHECK_JSON_KEY(allMemObj);
|
|
918
|
-
memObjMap.createObjs(allMemObj, memObjCreator);
|
|
919
909
|
|
|
920
910
|
symTabFieldJson = allMemObj->next;
|
|
921
911
|
}
|
|
@@ -1104,7 +1094,6 @@ private:
|
|
|
1104
1094
|
|
|
1105
1095
|
void readJson(const cJSON* obj, AccessPath& ap);
|
|
1106
1096
|
void readJson(const cJSON* obj, SVFLoop*& loop);
|
|
1107
|
-
void readJson(const cJSON* obj, MemObj*& memObj);
|
|
1108
1097
|
void readJson(const cJSON* obj,
|
|
1109
1098
|
ObjTypeInfo*& objTypeInfo); // Only owned by MemObj
|
|
1110
1099
|
void readJson(const cJSON* obj,
|
|
@@ -1257,7 +1246,6 @@ private:
|
|
|
1257
1246
|
void fill(const cJSON*& fieldJson, TDForkPE* stmt);
|
|
1258
1247
|
void fill(const cJSON*& fieldJson, TDJoinPE* stmt);
|
|
1259
1248
|
|
|
1260
|
-
void fill(const cJSON*& fieldJson, MemObj* memObj);
|
|
1261
1249
|
void fill(const cJSON*& fieldJson, StInfo* stInfo);
|
|
1262
1250
|
// ICFG
|
|
1263
1251
|
void virtFill(const cJSON*& fieldJson, ICFGNode* node);
|
|
@@ -393,15 +393,6 @@ public:
|
|
|
393
393
|
/// return whole allocated memory object if this node is a gep obj node
|
|
394
394
|
/// return nullptr is this node is not a ObjVar type
|
|
395
395
|
//@{
|
|
396
|
-
inline const MemObj* getObject(NodeID id) const
|
|
397
|
-
{
|
|
398
|
-
const SVFVar* node = getGNode(id);
|
|
399
|
-
if (const ObjVar* objPN = SVFUtil::dyn_cast<ObjVar>(node))
|
|
400
|
-
return getObject(objPN);
|
|
401
|
-
else
|
|
402
|
-
return nullptr;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
396
|
inline const BaseObjVar* getBaseObject(NodeID id) const
|
|
406
397
|
{
|
|
407
398
|
const SVFVar* node = getGNode(id);
|
|
@@ -421,20 +412,15 @@ public:
|
|
|
421
412
|
else
|
|
422
413
|
return SVFUtil::dyn_cast<ValVar>(node);
|
|
423
414
|
}
|
|
424
|
-
|
|
425
|
-
inline const MemObj*getObject(const ObjVar* node) const
|
|
426
|
-
{
|
|
427
|
-
return node->getMemObj();
|
|
428
|
-
}
|
|
429
415
|
//@}
|
|
430
416
|
|
|
431
417
|
/// Get a field SVFIR Object node according to base mem obj and offset
|
|
432
|
-
NodeID getGepObjVar(const
|
|
418
|
+
NodeID getGepObjVar(const BaseObjVar* baseObj, const APOffset& ap);
|
|
433
419
|
/// Get a field obj SVFIR node according to a mem obj and a given offset
|
|
434
420
|
NodeID getGepObjVar(NodeID id, const APOffset& ap) ;
|
|
435
421
|
/// Get a field-insensitive obj SVFIR node according to a mem obj
|
|
436
422
|
//@{
|
|
437
|
-
inline NodeID getFIObjVar(const
|
|
423
|
+
inline NodeID getFIObjVar(const BaseObjVar* obj) const
|
|
438
424
|
{
|
|
439
425
|
return obj->getId();
|
|
440
426
|
}
|
|
@@ -464,7 +450,7 @@ public:
|
|
|
464
450
|
}
|
|
465
451
|
inline bool isConstantObj(NodeID id) const
|
|
466
452
|
{
|
|
467
|
-
const
|
|
453
|
+
const BaseObjVar* obj = getBaseObject(id);
|
|
468
454
|
assert(obj && "not an object node?");
|
|
469
455
|
return SymbolTableInfo::isConstantObj(id) ||
|
|
470
456
|
obj->isConstDataOrConstGlobal();
|
|
@@ -476,20 +462,13 @@ public:
|
|
|
476
462
|
/// Get a base pointer node given a field pointer
|
|
477
463
|
inline NodeID getBaseObjVar(NodeID id) const
|
|
478
464
|
{
|
|
479
|
-
return
|
|
480
|
-
}
|
|
481
|
-
inline const MemObj* getBaseObj(NodeID id) const
|
|
482
|
-
{
|
|
483
|
-
const SVFVar* node = pag->getGNode(id);
|
|
484
|
-
assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
|
|
485
|
-
const ObjVar* obj = SVFUtil::cast<ObjVar>(node);
|
|
486
|
-
return obj->getMemObj();
|
|
465
|
+
return getBaseObject(id)->getId();
|
|
487
466
|
}
|
|
488
467
|
//@}
|
|
489
468
|
|
|
490
469
|
/// Get all fields of an object
|
|
491
470
|
//@{
|
|
492
|
-
NodeBS& getAllFieldsObjVars(const
|
|
471
|
+
NodeBS& getAllFieldsObjVars(const BaseObjVar* obj);
|
|
493
472
|
NodeBS& getAllFieldsObjVars(NodeID id);
|
|
494
473
|
NodeBS getFieldsAfterCollapse(NodeID id);
|
|
495
474
|
//@}
|
|
@@ -569,157 +548,152 @@ private:
|
|
|
569
548
|
inline NodeID addValNode(const SVFValue* val, NodeID i, const ICFGNode* icfgNode)
|
|
570
549
|
{
|
|
571
550
|
SVFVar *node = new ValVar(val,i, ValVar::ValNode, icfgNode);
|
|
572
|
-
return addValNode(val, node
|
|
551
|
+
return addValNode(val, node);
|
|
573
552
|
}
|
|
574
553
|
|
|
575
554
|
NodeID addFunValNode(NodeID i, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode)
|
|
576
555
|
{
|
|
577
556
|
FunValVar* node = new FunValVar(i, icfgNode, callGraphNode);
|
|
578
|
-
return addValNode(nullptr, node
|
|
557
|
+
return addValNode(nullptr, node);
|
|
579
558
|
}
|
|
580
559
|
|
|
581
560
|
NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode, bool isUncalled = false)
|
|
582
561
|
{
|
|
583
562
|
ArgValVar* node =
|
|
584
563
|
new ArgValVar(i, argNo, icfgNode, callGraphNode, isUncalled);
|
|
585
|
-
return addValNode(nullptr, node
|
|
564
|
+
return addValNode(nullptr, node);
|
|
586
565
|
}
|
|
587
566
|
|
|
588
567
|
inline NodeID addConstantFPValNode(const SVFValue* curInst, const NodeID i, double dval,
|
|
589
568
|
const ICFGNode* icfgNode)
|
|
590
569
|
{
|
|
591
570
|
SVFVar* node = new ConstantFPValVar(curInst, i, dval, icfgNode);
|
|
592
|
-
return addNode(node
|
|
571
|
+
return addNode(node);
|
|
593
572
|
}
|
|
594
573
|
|
|
595
574
|
inline NodeID addConstantIntValNode(const SVFValue* curInst, NodeID i, const std::pair<s64_t, u64_t>& intValue,
|
|
596
575
|
const ICFGNode* icfgNode)
|
|
597
576
|
{
|
|
598
577
|
SVFVar* node = new ConstantIntValVar(curInst, i, intValue.first, intValue.second, icfgNode);
|
|
599
|
-
return addNode(node
|
|
578
|
+
return addNode(node);
|
|
600
579
|
}
|
|
601
580
|
|
|
602
581
|
inline NodeID addConstantNullPtrValNode(const SVFValue* curInst, const NodeID i, const ICFGNode* icfgNode)
|
|
603
582
|
{
|
|
604
583
|
SVFVar* node = new ConstantNullPtrValVar(curInst, i, icfgNode);
|
|
605
|
-
return addNode(node
|
|
584
|
+
return addNode(node);
|
|
606
585
|
}
|
|
607
586
|
|
|
608
587
|
inline NodeID addGlobalValueValNode(const SVFValue* curInst, const NodeID i, const ICFGNode* icfgNode)
|
|
609
588
|
{
|
|
610
589
|
SVFVar* node = new GlobalValVar(curInst, i, icfgNode);
|
|
611
|
-
return addNode(node
|
|
590
|
+
return addNode(node);
|
|
612
591
|
}
|
|
613
592
|
|
|
614
593
|
inline NodeID addConstantDataValNode(const SVFValue* curInst, const NodeID i, const ICFGNode* icfgNode)
|
|
615
594
|
{
|
|
616
595
|
SVFVar* node = new ConstantDataValVar(curInst, i, icfgNode);
|
|
617
|
-
return addNode(node
|
|
596
|
+
return addNode(node);
|
|
618
597
|
}
|
|
619
598
|
|
|
620
599
|
|
|
621
600
|
/// Add a memory obj node
|
|
622
|
-
inline NodeID addObjNode(const SVFValue* val, NodeID i)
|
|
601
|
+
inline NodeID addObjNode(const SVFValue* val, NodeID i, ObjTypeInfo* ti)
|
|
623
602
|
{
|
|
624
|
-
|
|
625
|
-
assert(mem->getId() == i && "not same object id?");
|
|
626
|
-
return addFIObjNode(mem);
|
|
603
|
+
return addFIObjNode(val, i, ti);
|
|
627
604
|
}
|
|
628
605
|
|
|
629
606
|
/**
|
|
630
607
|
* Creates and adds a heap object node to the SVFIR
|
|
631
608
|
*/
|
|
632
|
-
inline NodeID addHeapObjNode(const SVFValue* val, NodeID i, const SVFFunction* f)
|
|
609
|
+
inline NodeID addHeapObjNode(const SVFValue* val, NodeID i, ObjTypeInfo* ti, const SVFFunction* f)
|
|
633
610
|
{
|
|
634
|
-
const MemObj* mem = getMemObj(val);
|
|
635
|
-
assert(mem->getId() == i && "not same object id?");
|
|
636
611
|
memToFieldsMap[i].set(i);
|
|
637
|
-
HeapObjVar *
|
|
638
|
-
return addObjNode(val,
|
|
612
|
+
HeapObjVar *heapObj = new HeapObjVar(val, i, ti, f);
|
|
613
|
+
return addObjNode(val, heapObj);
|
|
639
614
|
}
|
|
640
615
|
|
|
641
616
|
/**
|
|
642
617
|
* Creates and adds a stack object node to the SVFIR
|
|
643
618
|
*/
|
|
644
|
-
inline NodeID addStackObjNode(const SVFValue* val, NodeID i, const SVFFunction* f)
|
|
619
|
+
inline NodeID addStackObjNode(const SVFValue* val, NodeID i, ObjTypeInfo* ti, const SVFFunction* f)
|
|
645
620
|
{
|
|
646
|
-
const MemObj* mem = getMemObj(val);
|
|
647
|
-
assert(mem->getId() == i && "not same object id?");
|
|
648
621
|
memToFieldsMap[i].set(i);
|
|
649
|
-
StackObjVar *
|
|
650
|
-
return addObjNode(val,
|
|
622
|
+
StackObjVar *stackObj = new StackObjVar(val, i, ti, f);
|
|
623
|
+
return addObjNode(val, stackObj);
|
|
651
624
|
}
|
|
652
625
|
|
|
653
|
-
NodeID addFunObjNode(NodeID id, const CallGraphNode* callGraphNode)
|
|
626
|
+
NodeID addFunObjNode(const SVFValue* val, NodeID id, ObjTypeInfo* ti, const CallGraphNode* callGraphNode)
|
|
627
|
+
{
|
|
628
|
+
memToFieldsMap[id].set(id);
|
|
629
|
+
FunObjVar* funObj = new FunObjVar(val, id, ti, callGraphNode);
|
|
630
|
+
return addObjNode(val, funObj);
|
|
631
|
+
}
|
|
654
632
|
|
|
655
633
|
|
|
656
|
-
inline NodeID addConstantFPObjNode(const SVFValue* curInst, NodeID i, double dval)
|
|
634
|
+
inline NodeID addConstantFPObjNode(const SVFValue* curInst, NodeID i, ObjTypeInfo* ti, double dval)
|
|
657
635
|
{
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
ConstantFPObjVar* node = new ConstantFPObjVar(curInst, i, dval, mem);
|
|
662
|
-
return addObjNode(curInst, node, mem->getId());
|
|
636
|
+
memToFieldsMap[i].set(i);
|
|
637
|
+
ConstantFPObjVar* conObj = new ConstantFPObjVar(curInst, i, dval, ti);
|
|
638
|
+
return addObjNode(curInst, conObj);
|
|
663
639
|
}
|
|
664
640
|
|
|
665
641
|
|
|
666
|
-
inline NodeID addConstantIntObjNode(const SVFValue* curInst, NodeID i, const std::pair<s64_t, u64_t>& intValue)
|
|
642
|
+
inline NodeID addConstantIntObjNode(const SVFValue* curInst, NodeID i, ObjTypeInfo* ti, const std::pair<s64_t, u64_t>& intValue)
|
|
667
643
|
{
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
new ConstantIntObjVar(curInst, i, intValue.first, intValue.second, mem);
|
|
673
|
-
return addObjNode(curInst, node, mem->getId());
|
|
644
|
+
memToFieldsMap[i].set(i);
|
|
645
|
+
ConstantIntObjVar* conObj =
|
|
646
|
+
new ConstantIntObjVar(curInst, i, intValue.first, intValue.second, ti);
|
|
647
|
+
return addObjNode(curInst, conObj);
|
|
674
648
|
}
|
|
675
649
|
|
|
676
650
|
|
|
677
|
-
inline NodeID addConstantNullPtrObjNode(const SVFValue* curInst, const NodeID i)
|
|
651
|
+
inline NodeID addConstantNullPtrObjNode(const SVFValue* curInst, const NodeID i, ObjTypeInfo* ti)
|
|
678
652
|
{
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
ConstantNullPtrObjVar* node = new ConstantNullPtrObjVar(curInst, mem->getId(), mem);
|
|
683
|
-
return addObjNode(mem->getValue(), node, mem->getId());
|
|
653
|
+
memToFieldsMap[i].set(i);
|
|
654
|
+
ConstantNullPtrObjVar* conObj = new ConstantNullPtrObjVar(curInst, i, ti);
|
|
655
|
+
return addObjNode(curInst, conObj);
|
|
684
656
|
}
|
|
685
657
|
|
|
686
|
-
inline NodeID addGlobalValueObjNode(const SVFValue* curInst, const NodeID i)
|
|
658
|
+
inline NodeID addGlobalValueObjNode(const SVFValue* curInst, const NodeID i, ObjTypeInfo* ti)
|
|
687
659
|
{
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
GlobalObjVar* node = new GlobalObjVar(curInst, mem->getId(), mem);
|
|
692
|
-
return addObjNode(mem->getValue(), node, mem->getId());
|
|
660
|
+
memToFieldsMap[i].set(i);
|
|
661
|
+
GlobalObjVar* gObj = new GlobalObjVar(curInst, i, ti);
|
|
662
|
+
return addObjNode(curInst, gObj);
|
|
693
663
|
}
|
|
694
664
|
|
|
695
|
-
inline NodeID addConstantDataObjNode(const SVFValue* curInst, const NodeID i)
|
|
665
|
+
inline NodeID addConstantDataObjNode(const SVFValue* curInst, const NodeID i, ObjTypeInfo* ti)
|
|
696
666
|
{
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
ConstantDataObjVar* node = new ConstantDataObjVar(curInst, mem->getId(), mem);
|
|
701
|
-
return addObjNode(mem->getValue(), node, mem->getId());
|
|
667
|
+
memToFieldsMap[i].set(i);
|
|
668
|
+
ConstantDataObjVar* conObj = new ConstantDataObjVar(curInst, i, ti);
|
|
669
|
+
return addObjNode(curInst, conObj);
|
|
702
670
|
}
|
|
703
671
|
|
|
704
672
|
/// Add a unique return node for a procedure
|
|
705
673
|
inline NodeID addRetNode(NodeID i, const CallGraphNode* callGraphNode)
|
|
706
674
|
{
|
|
707
675
|
SVFVar *node = new RetPN(i, callGraphNode);
|
|
708
|
-
return addRetNode(callGraphNode, node
|
|
676
|
+
return addRetNode(callGraphNode, node);
|
|
709
677
|
}
|
|
710
678
|
/// Add a unique vararg node for a procedure
|
|
711
679
|
inline NodeID addVarargNode(NodeID i, const CallGraphNode* val)
|
|
712
680
|
{
|
|
713
681
|
SVFVar *node = new VarArgPN(i, val);
|
|
714
|
-
return addNode(node
|
|
682
|
+
return addNode(node);
|
|
715
683
|
}
|
|
716
684
|
|
|
717
685
|
/// Add a temp field value node, this method can only invoked by getGepValVar
|
|
718
686
|
NodeID addGepValNode(const SVFValue* curInst,const SVFValue* val, const AccessPath& ap, NodeID i, const SVFType* type);
|
|
719
687
|
/// Add a field obj node, this method can only invoked by getGepObjVar
|
|
720
|
-
NodeID addGepObjNode(const
|
|
688
|
+
NodeID addGepObjNode(const BaseObjVar* baseObj, const APOffset& apOffset, const NodeID gepId);
|
|
721
689
|
/// Add a field-insensitive node, this method can only invoked by getFIGepObjNode
|
|
722
|
-
NodeID addFIObjNode(const
|
|
690
|
+
NodeID addFIObjNode(const SVFValue* val, NodeID i, ObjTypeInfo* ti)
|
|
691
|
+
{
|
|
692
|
+
memToFieldsMap[i].set(i);
|
|
693
|
+
BaseObjVar* baseObj = new BaseObjVar(val, i, ti);
|
|
694
|
+
return addObjNode(val, baseObj);
|
|
695
|
+
}
|
|
696
|
+
|
|
723
697
|
|
|
724
698
|
//@}
|
|
725
699
|
|
|
@@ -727,28 +701,30 @@ private:
|
|
|
727
701
|
//@{
|
|
728
702
|
inline NodeID addDummyValNode(NodeID i)
|
|
729
703
|
{
|
|
730
|
-
return addValNode(nullptr, new DummyValVar(i)
|
|
704
|
+
return addValNode(nullptr, new DummyValVar(i));
|
|
731
705
|
}
|
|
732
706
|
inline NodeID addDummyObjNode(NodeID i, const SVFType* type)
|
|
733
707
|
{
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
708
|
+
if (symInfo->idToObjTypeInfoMap().find(i) == symInfo->idToObjTypeInfoMap().end())
|
|
709
|
+
{
|
|
710
|
+
ObjTypeInfo* ti = symInfo->createObjTypeInfo(type);
|
|
711
|
+
symInfo->idToObjTypeInfoMap()[i] = ti;
|
|
712
|
+
return addObjNode(nullptr, new DummyObjVar(i, ti));
|
|
713
|
+
}
|
|
714
|
+
else
|
|
715
|
+
{
|
|
716
|
+
return addObjNode(nullptr, new DummyObjVar(i, symInfo->getObjTypeInfo(i)));
|
|
717
|
+
}
|
|
740
718
|
}
|
|
719
|
+
|
|
741
720
|
inline NodeID addBlackholeObjNode()
|
|
742
721
|
{
|
|
743
722
|
return addObjNode(
|
|
744
|
-
nullptr, new DummyObjVar(getBlackHoleNode(),
|
|
745
|
-
getBlackHoleNode());
|
|
723
|
+
nullptr, new DummyObjVar(getBlackHoleNode(), symInfo->getObjTypeInfo(getBlackHoleNode())));
|
|
746
724
|
}
|
|
747
725
|
inline NodeID addConstantObjNode()
|
|
748
726
|
{
|
|
749
|
-
return addObjNode(nullptr,
|
|
750
|
-
new DummyObjVar(getConstantNode(), getConstantObj()),
|
|
751
|
-
getConstantNode());
|
|
727
|
+
return addObjNode(nullptr, new DummyObjVar(getConstantNode(), symInfo->getObjTypeInfo(getConstantNode())));
|
|
752
728
|
}
|
|
753
729
|
inline NodeID addBlackholePtrNode()
|
|
754
730
|
{
|
|
@@ -757,30 +733,32 @@ private:
|
|
|
757
733
|
//@}
|
|
758
734
|
|
|
759
735
|
/// Add a value (pointer) node
|
|
760
|
-
inline NodeID addValNode(const SVFValue*, SVFVar *node
|
|
736
|
+
inline NodeID addValNode(const SVFValue*, SVFVar *node)
|
|
761
737
|
{
|
|
762
|
-
assert(
|
|
738
|
+
assert(node && "node cannot be nullptr.");
|
|
739
|
+
assert(hasGNode(node->getId()) == false &&
|
|
763
740
|
"This NodeID clashes here. Please check NodeIDAllocator. Switch "
|
|
764
741
|
"Strategy::DBUG to SEQ or DENSE");
|
|
765
|
-
return addNode(node
|
|
742
|
+
return addNode(node);
|
|
766
743
|
}
|
|
767
744
|
/// Add a memory obj node
|
|
768
|
-
inline NodeID addObjNode(const SVFValue*, SVFVar *node
|
|
745
|
+
inline NodeID addObjNode(const SVFValue*, SVFVar *node)
|
|
769
746
|
{
|
|
770
|
-
assert(
|
|
747
|
+
assert(node && "node cannot be nullptr.");
|
|
748
|
+
assert(hasGNode(node->getId()) == false &&
|
|
771
749
|
"This NodeID clashes here. Please check NodeIDAllocator. Switch "
|
|
772
750
|
"Strategy::DBUG to SEQ or DENSE");
|
|
773
|
-
return addNode(node
|
|
751
|
+
return addNode(node);
|
|
774
752
|
}
|
|
775
753
|
/// Add a unique return node for a procedure
|
|
776
|
-
inline NodeID addRetNode(const CallGraphNode*, SVFVar *node
|
|
754
|
+
inline NodeID addRetNode(const CallGraphNode*, SVFVar *node)
|
|
777
755
|
{
|
|
778
|
-
return addNode(node
|
|
756
|
+
return addNode(node);
|
|
779
757
|
}
|
|
780
758
|
/// Add a unique vararg node for a procedure
|
|
781
|
-
inline NodeID addVarargNode(const SVFFunction*, SVFVar *node
|
|
759
|
+
inline NodeID addVarargNode(const SVFFunction*, SVFVar *node)
|
|
782
760
|
{
|
|
783
|
-
return addNode(node
|
|
761
|
+
return addNode(node);
|
|
784
762
|
}
|
|
785
763
|
|
|
786
764
|
/// Add global PAGEdges (not in a procedure)
|