svf-lib 1.0.2511 → 1.0.2513
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/SVF-linux-x86_64/bin/ae +0 -0
- package/SVF-linux-x86_64/bin/dvf +0 -0
- package/SVF-linux-x86_64/bin/mta +0 -0
- package/SVF-linux-x86_64/bin/saber +0 -0
- package/SVF-linux-x86_64/bin/svf-ex +0 -0
- package/SVF-linux-x86_64/bin/wpa +0 -0
- package/SVF-linux-x86_64/include/AE/Core/AbstractState.h +1 -1
- package/SVF-linux-x86_64/include/DDA/DDAVFSolver.h +4 -4
- package/SVF-linux-x86_64/include/Graphs/SVFG.h +16 -16
- package/SVF-linux-x86_64/include/Graphs/SVFGOPT.h +6 -6
- package/SVF-linux-x86_64/include/Graphs/VFG.h +39 -36
- package/SVF-linux-x86_64/include/Graphs/VFGNode.h +117 -37
- package/SVF-linux-x86_64/include/MemoryModel/AccessPath.h +5 -4
- package/SVF-linux-x86_64/include/SABER/SaberSVFGBuilder.h +1 -1
- package/SVF-linux-x86_64/include/SVFIR/SVFIR.h +24 -14
- package/SVF-linux-x86_64/include/SVFIR/SVFStatements.h +65 -33
- package/SVF-linux-x86_64/lib/libSvfCore.so.3.3 +0 -0
- package/SVF-linux-x86_64/lib/libSvfLLVM.so.3.3 +0 -0
- package/SVF-osx/bin/ae +0 -0
- package/SVF-osx/bin/svf-ex +0 -0
- package/SVF-osx/include/AE/Core/AbstractState.h +1 -1
- package/SVF-osx/include/DDA/DDAVFSolver.h +4 -4
- package/SVF-osx/include/Graphs/SVFG.h +16 -16
- package/SVF-osx/include/Graphs/SVFGOPT.h +6 -6
- package/SVF-osx/include/Graphs/VFG.h +39 -36
- package/SVF-osx/include/Graphs/VFGNode.h +117 -37
- package/SVF-osx/include/MemoryModel/AccessPath.h +5 -4
- package/SVF-osx/include/SABER/SaberSVFGBuilder.h +1 -1
- package/SVF-osx/include/SVFIR/SVFIR.h +24 -14
- package/SVF-osx/include/SVFIR/SVFStatements.h +65 -33
- package/SVF-osx/lib/libSvfCore.3.3.dylib +0 -0
- package/SVF-osx/lib/libSvfLLVM.3.3.dylib +0 -0
- package/package.json +1 -1
|
@@ -38,6 +38,8 @@ namespace SVF
|
|
|
38
38
|
{
|
|
39
39
|
|
|
40
40
|
class SVFVar;
|
|
41
|
+
class ValVar;
|
|
42
|
+
class ObjVar;
|
|
41
43
|
class ICFGNode;
|
|
42
44
|
class IntraICFGNode;
|
|
43
45
|
class CallICFGNode;
|
|
@@ -423,6 +425,11 @@ public:
|
|
|
423
425
|
{
|
|
424
426
|
return true;
|
|
425
427
|
}
|
|
428
|
+
|
|
429
|
+
const ValVar* getLHSVar() const;
|
|
430
|
+
const ObjVar* getRHSVar() const;
|
|
431
|
+
const ValVar* getDstNode() const;
|
|
432
|
+
const ObjVar* getSrcNode() const;
|
|
426
433
|
};
|
|
427
434
|
|
|
428
435
|
/*!
|
|
@@ -507,6 +514,11 @@ public:
|
|
|
507
514
|
/// constructor
|
|
508
515
|
CopyStmt(SVFVar* s, SVFVar* d, CopyKind k) : AssignStmt(s, d, SVFStmt::Copy), copyKind(k) {}
|
|
509
516
|
|
|
517
|
+
const ValVar* getRHSVar() const;
|
|
518
|
+
const ValVar* getLHSVar() const;
|
|
519
|
+
const ValVar* getSrcNode() const;
|
|
520
|
+
const ValVar* getDstNode() const;
|
|
521
|
+
|
|
510
522
|
virtual const std::string toString() const override;
|
|
511
523
|
|
|
512
524
|
private:
|
|
@@ -544,6 +556,11 @@ public:
|
|
|
544
556
|
/// constructor
|
|
545
557
|
StoreStmt(SVFVar* s, SVFVar* d, const ICFGNode* st);
|
|
546
558
|
|
|
559
|
+
const ValVar* getRHSVar() const;
|
|
560
|
+
const ValVar* getLHSVar() const;
|
|
561
|
+
const ValVar* getSrcNode() const;
|
|
562
|
+
const ValVar* getDstNode() const;
|
|
563
|
+
|
|
547
564
|
virtual const std::string toString() const override;
|
|
548
565
|
|
|
549
566
|
};
|
|
@@ -579,6 +596,11 @@ public:
|
|
|
579
596
|
/// constructor
|
|
580
597
|
LoadStmt(SVFVar* s, SVFVar* d) : AssignStmt(s, d, SVFStmt::Load) {}
|
|
581
598
|
|
|
599
|
+
const ValVar* getRHSVar() const;
|
|
600
|
+
const ValVar* getLHSVar() const;
|
|
601
|
+
const ValVar* getSrcNode() const;
|
|
602
|
+
const ValVar* getDstNode() const;
|
|
603
|
+
|
|
582
604
|
virtual const std::string toString() const override;
|
|
583
605
|
};
|
|
584
606
|
|
|
@@ -660,6 +682,11 @@ public:
|
|
|
660
682
|
{
|
|
661
683
|
}
|
|
662
684
|
|
|
685
|
+
const ValVar* getRHSVar() const;
|
|
686
|
+
const ValVar* getLHSVar() const;
|
|
687
|
+
const ValVar* getSrcNode() const;
|
|
688
|
+
const ValVar* getDstNode() const;
|
|
689
|
+
|
|
663
690
|
virtual const std::string toString() const;
|
|
664
691
|
|
|
665
692
|
|
|
@@ -719,6 +746,11 @@ public:
|
|
|
719
746
|
}
|
|
720
747
|
//@}
|
|
721
748
|
|
|
749
|
+
const ValVar* getRHSVar() const;
|
|
750
|
+
const ValVar* getLHSVar() const;
|
|
751
|
+
const ValVar* getSrcNode() const;
|
|
752
|
+
const ValVar* getDstNode() const;
|
|
753
|
+
|
|
722
754
|
virtual const std::string toString() const override;
|
|
723
755
|
};
|
|
724
756
|
|
|
@@ -775,6 +807,11 @@ public:
|
|
|
775
807
|
}
|
|
776
808
|
//@}
|
|
777
809
|
|
|
810
|
+
const ValVar* getRHSVar() const;
|
|
811
|
+
const ValVar* getLHSVar() const;
|
|
812
|
+
const ValVar* getSrcNode() const;
|
|
813
|
+
const ValVar* getDstNode() const;
|
|
814
|
+
|
|
778
815
|
virtual const std::string toString() const override;
|
|
779
816
|
|
|
780
817
|
};
|
|
@@ -786,10 +823,8 @@ class MultiOpndStmt : public SVFStmt
|
|
|
786
823
|
{
|
|
787
824
|
friend class GraphDBClient;
|
|
788
825
|
|
|
789
|
-
|
|
790
|
-
|
|
791
826
|
public:
|
|
792
|
-
typedef std::vector<
|
|
827
|
+
typedef std::vector<ValVar*> OPVars;
|
|
793
828
|
|
|
794
829
|
private:
|
|
795
830
|
MultiOpndStmt(); ///< place holder
|
|
@@ -803,7 +838,7 @@ private:
|
|
|
803
838
|
protected:
|
|
804
839
|
OPVars opVars;
|
|
805
840
|
/// Constructor, only used by subclasses but not external users
|
|
806
|
-
MultiOpndStmt(
|
|
841
|
+
MultiOpndStmt(ValVar* r, const OPVars& opnds, GEdgeFlag k);
|
|
807
842
|
|
|
808
843
|
public:
|
|
809
844
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
@@ -827,7 +862,7 @@ public:
|
|
|
827
862
|
/// `r` is OpVar
|
|
828
863
|
//@{
|
|
829
864
|
/// Operand SVFVars
|
|
830
|
-
inline const
|
|
865
|
+
inline const ValVar* getOpVar(u32_t pos) const
|
|
831
866
|
{
|
|
832
867
|
return opVars.at(pos);
|
|
833
868
|
}
|
|
@@ -897,13 +932,13 @@ public:
|
|
|
897
932
|
//@}
|
|
898
933
|
|
|
899
934
|
/// constructor
|
|
900
|
-
PhiStmt(
|
|
935
|
+
PhiStmt(ValVar* res, const OPVars& opnds, const OpICFGNodeVec& icfgNodes)
|
|
901
936
|
: MultiOpndStmt(res, opnds, SVFStmt::Phi), opICFGNodes(icfgNodes)
|
|
902
937
|
{
|
|
903
938
|
assert(opnds.size() == icfgNodes.size() &&
|
|
904
939
|
"Numbers of operands and their ICFGNodes are not consistent?");
|
|
905
940
|
}
|
|
906
|
-
void addOpVar(
|
|
941
|
+
void addOpVar(ValVar* op, const ICFGNode* inode)
|
|
907
942
|
{
|
|
908
943
|
opVars.push_back(op);
|
|
909
944
|
opICFGNodes.push_back(inode);
|
|
@@ -971,18 +1006,18 @@ public:
|
|
|
971
1006
|
//@}
|
|
972
1007
|
|
|
973
1008
|
/// constructor
|
|
974
|
-
SelectStmt(
|
|
1009
|
+
SelectStmt(ValVar* res, const OPVars& opnds, const SVFVar* cond);
|
|
975
1010
|
virtual const std::string toString() const override;
|
|
976
1011
|
|
|
977
1012
|
inline const SVFVar* getCondition() const
|
|
978
1013
|
{
|
|
979
1014
|
return condition;
|
|
980
1015
|
}
|
|
981
|
-
inline const
|
|
1016
|
+
inline const ValVar* getTrueValue() const
|
|
982
1017
|
{
|
|
983
1018
|
return getOpVar(0);
|
|
984
1019
|
}
|
|
985
|
-
inline const
|
|
1020
|
+
inline const ValVar* getFalseValue() const
|
|
986
1021
|
{
|
|
987
1022
|
return getOpVar(1);
|
|
988
1023
|
}
|
|
@@ -1061,7 +1096,7 @@ public:
|
|
|
1061
1096
|
//@}
|
|
1062
1097
|
|
|
1063
1098
|
/// constructor
|
|
1064
|
-
CmpStmt(
|
|
1099
|
+
CmpStmt(ValVar* res, const OPVars& opnds, u32_t pre);
|
|
1065
1100
|
|
|
1066
1101
|
u32_t getPredicate() const
|
|
1067
1102
|
{
|
|
@@ -1128,7 +1163,7 @@ public:
|
|
|
1128
1163
|
//@}
|
|
1129
1164
|
|
|
1130
1165
|
/// constructor
|
|
1131
|
-
BinaryOPStmt(
|
|
1166
|
+
BinaryOPStmt(ValVar* res, const OPVars& opnds, u32_t oc);
|
|
1132
1167
|
|
|
1133
1168
|
u32_t getOpcode() const
|
|
1134
1169
|
{
|
|
@@ -1180,23 +1215,14 @@ public:
|
|
|
1180
1215
|
//@}
|
|
1181
1216
|
|
|
1182
1217
|
/// constructor
|
|
1183
|
-
UnaryOPStmt(
|
|
1184
|
-
: SVFStmt(s, d, SVFStmt::UnaryOp), opcode(oc)
|
|
1185
|
-
{
|
|
1186
|
-
}
|
|
1218
|
+
UnaryOPStmt(ValVar* s, ValVar* d, u32_t oc);
|
|
1187
1219
|
|
|
1188
1220
|
u32_t getOpcode() const
|
|
1189
1221
|
{
|
|
1190
1222
|
return opcode;
|
|
1191
1223
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
return SVFStmt::getSrcNode();
|
|
1195
|
-
}
|
|
1196
|
-
inline const SVFVar* getRes() const
|
|
1197
|
-
{
|
|
1198
|
-
return SVFStmt::getDstNode();
|
|
1199
|
-
}
|
|
1224
|
+
const ValVar* getOpVar() const;
|
|
1225
|
+
const ValVar* getRes() const;
|
|
1200
1226
|
NodeID getOpVarID() const;
|
|
1201
1227
|
NodeID getResID() const;
|
|
1202
1228
|
|
|
@@ -1223,8 +1249,8 @@ private:
|
|
|
1223
1249
|
NodeID getDstID(); ///< place holder, use getResID() instead
|
|
1224
1250
|
|
|
1225
1251
|
SuccAndCondPairVec successors;
|
|
1226
|
-
const
|
|
1227
|
-
const
|
|
1252
|
+
const ValVar* cond;
|
|
1253
|
+
const ValVar* brInst;
|
|
1228
1254
|
|
|
1229
1255
|
public:
|
|
1230
1256
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
@@ -1244,19 +1270,15 @@ public:
|
|
|
1244
1270
|
//@}
|
|
1245
1271
|
|
|
1246
1272
|
/// constructor
|
|
1247
|
-
BranchStmt(
|
|
1248
|
-
: SVFStmt(c, inst, SVFStmt::Branch), successors(succs), cond(c),
|
|
1249
|
-
brInst(inst)
|
|
1250
|
-
{
|
|
1251
|
-
}
|
|
1273
|
+
BranchStmt(ValVar* inst, ValVar* c, const SuccAndCondPairVec& succs);
|
|
1252
1274
|
|
|
1253
1275
|
/// The branch is unconditional if cond is a null value
|
|
1254
1276
|
bool isUnconditional() const;
|
|
1255
1277
|
/// The branch is conditional if cond is not a null value
|
|
1256
1278
|
bool isConditional() const;
|
|
1257
1279
|
/// Return the condition
|
|
1258
|
-
const
|
|
1259
|
-
const
|
|
1280
|
+
const ValVar* getCondition() const;
|
|
1281
|
+
const ValVar* getBranchInst() const
|
|
1260
1282
|
{
|
|
1261
1283
|
return brInst;
|
|
1262
1284
|
}
|
|
@@ -1327,6 +1349,11 @@ public:
|
|
|
1327
1349
|
{
|
|
1328
1350
|
}
|
|
1329
1351
|
|
|
1352
|
+
const ValVar* getRHSVar() const;
|
|
1353
|
+
const ValVar* getLHSVar() const;
|
|
1354
|
+
const ValVar* getSrcNode() const;
|
|
1355
|
+
const ValVar* getDstNode() const;
|
|
1356
|
+
|
|
1330
1357
|
virtual const std::string toString() const;
|
|
1331
1358
|
|
|
1332
1359
|
};
|
|
@@ -1366,6 +1393,11 @@ public:
|
|
|
1366
1393
|
{
|
|
1367
1394
|
}
|
|
1368
1395
|
|
|
1396
|
+
const ValVar* getRHSVar() const;
|
|
1397
|
+
const ValVar* getLHSVar() const;
|
|
1398
|
+
const ValVar* getSrcNode() const;
|
|
1399
|
+
const ValVar* getDstNode() const;
|
|
1400
|
+
|
|
1369
1401
|
virtual const std::string toString() const;
|
|
1370
1402
|
|
|
1371
1403
|
};
|
|
Binary file
|
|
Binary file
|
package/SVF-osx/bin/ae
CHANGED
|
Binary file
|
package/SVF-osx/bin/svf-ex
CHANGED
|
Binary file
|
|
@@ -78,7 +78,7 @@ public:
|
|
|
78
78
|
AddressValue getGepObjAddrs(u32_t pointer, IntervalValue offset);
|
|
79
79
|
|
|
80
80
|
// initObjVar
|
|
81
|
-
void initObjVar(ObjVar* objVar);
|
|
81
|
+
void initObjVar(const ObjVar* objVar);
|
|
82
82
|
// getElementIndex
|
|
83
83
|
IntervalValue getElementIndex(const GepStmt* gep);
|
|
84
84
|
// getByteOffset
|
|
@@ -344,9 +344,9 @@ protected:
|
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
/// GetDefinition SVFG
|
|
347
|
-
inline const SVFGNode* getDefSVFGNode(const
|
|
347
|
+
inline const SVFGNode* getDefSVFGNode(const ValVar* valVar) const
|
|
348
348
|
{
|
|
349
|
-
return getSVFG()->getDefSVFGNode(
|
|
349
|
+
return getSVFG()->getDefSVFGNode(valVar);
|
|
350
350
|
}
|
|
351
351
|
/// Backward traverse along indirect value flows
|
|
352
352
|
void backtraceAlongIndirectVF(CPtSet& pts, const DPIm& oldDpm)
|
|
@@ -497,7 +497,7 @@ protected:
|
|
|
497
497
|
{
|
|
498
498
|
NodeID funPtr = _pag->getFunPtr(cbn);
|
|
499
499
|
DPIm funPtrDpm(dpm);
|
|
500
|
-
funPtrDpm.setLocVar(getSVFG()->getDefSVFGNode(_pag->
|
|
500
|
+
funPtrDpm.setLocVar(getSVFG()->getDefSVFGNode(_pag->getValVar(funPtr)),funPtr);
|
|
501
501
|
findPT(funPtrDpm);
|
|
502
502
|
}
|
|
503
503
|
}
|
|
@@ -510,7 +510,7 @@ protected:
|
|
|
510
510
|
{
|
|
511
511
|
NodeID funPtr = _pag->getFunPtr(*it);
|
|
512
512
|
DPIm funPtrDpm(dpm);
|
|
513
|
-
funPtrDpm.setLocVar(getSVFG()->getDefSVFGNode(_pag->
|
|
513
|
+
funPtrDpm.setLocVar(getSVFG()->getDefSVFGNode(_pag->getValVar(funPtr)),funPtr);
|
|
514
514
|
findPT(funPtrDpm);
|
|
515
515
|
}
|
|
516
516
|
}
|
|
@@ -74,7 +74,7 @@ class SVFG : public VFG
|
|
|
74
74
|
|
|
75
75
|
public:
|
|
76
76
|
typedef VFGNodeIDToNodeMapTy SVFGNodeIDToNodeMapTy;
|
|
77
|
-
typedef Map<const
|
|
77
|
+
typedef Map<const ValVar*, NodeID> ValVarToDefMapTy;
|
|
78
78
|
typedef Map<const MRVer*, NodeID> MSSAVarToDefMapTy;
|
|
79
79
|
typedef NodeBS ActualINSVFGNodeSet;
|
|
80
80
|
typedef NodeBS ActualOUTSVFGNodeSet;
|
|
@@ -167,16 +167,16 @@ public:
|
|
|
167
167
|
/// Connect SVFG nodes between caller and callee for indirect call site
|
|
168
168
|
virtual void connectCallerAndCallee(const CallICFGNode* cs, const FunObjVar* callee, SVFGEdgeSetTy& edges);
|
|
169
169
|
|
|
170
|
-
/// Given a
|
|
171
|
-
inline const SVFGNode* getDefSVFGNode(const
|
|
170
|
+
/// Given a valVar, return its definition site
|
|
171
|
+
inline const SVFGNode* getDefSVFGNode(const ValVar* valVar) const
|
|
172
172
|
{
|
|
173
|
-
return getSVFGNode(getDef(
|
|
173
|
+
return getSVFGNode(getDef(valVar));
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
/// Given a
|
|
177
|
-
inline bool hasDefSVFGNode(const
|
|
176
|
+
/// Given a valVar, return whether it has definition site
|
|
177
|
+
inline bool hasDefSVFGNode(const ValVar* valVar) const
|
|
178
178
|
{
|
|
179
|
-
return hasDef(
|
|
179
|
+
return hasDef(valVar) && hasSVFGNode(getDef(valVar));
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
/// Given a ValVar and its SVFGNode, find the definition-site ICFGNode
|
|
@@ -323,7 +323,7 @@ protected:
|
|
|
323
323
|
|
|
324
324
|
/// Get inter value flow edges between indirect call site and callee.
|
|
325
325
|
//@{
|
|
326
|
-
virtual inline void getInterVFEdgeAtIndCSFromAPToFP(const
|
|
326
|
+
virtual inline void getInterVFEdgeAtIndCSFromAPToFP(const ValVar* cs_arg, const ValVar* fun_arg, const CallICFGNode*, CallSiteID csId, SVFGEdgeSetTy& edges)
|
|
327
327
|
{
|
|
328
328
|
SVFGNode* actualParam = getSVFGNode(getDef(cs_arg));
|
|
329
329
|
SVFGNode* formalParam = getSVFGNode(getDef(fun_arg));
|
|
@@ -332,7 +332,7 @@ protected:
|
|
|
332
332
|
edges.insert(edge);
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
virtual inline void getInterVFEdgeAtIndCSFromFRToAR(const
|
|
335
|
+
virtual inline void getInterVFEdgeAtIndCSFromFRToAR(const ValVar* fun_ret, const ValVar* cs_ret, CallSiteID csId, SVFGEdgeSetTy& edges)
|
|
336
336
|
{
|
|
337
337
|
SVFGNode* formalRet = getSVFGNode(getDef(fun_ret));
|
|
338
338
|
SVFGNode* actualRet = getSVFGNode(getDef(cs_ret));
|
|
@@ -363,19 +363,19 @@ protected:
|
|
|
363
363
|
//@}
|
|
364
364
|
|
|
365
365
|
|
|
366
|
-
/// Given a
|
|
366
|
+
/// Given a ValVar, set/get its def SVFG node (definition of top level pointers)
|
|
367
367
|
//@{
|
|
368
|
-
inline void setDef(const
|
|
368
|
+
inline void setDef(const ValVar* valVar, const SVFGNode* node)
|
|
369
369
|
{
|
|
370
|
-
VFG::setDef(
|
|
370
|
+
VFG::setDef(valVar, node);
|
|
371
371
|
}
|
|
372
|
-
inline NodeID getDef(const
|
|
372
|
+
inline NodeID getDef(const ValVar* valVar) const
|
|
373
373
|
{
|
|
374
|
-
return VFG::getDef(
|
|
374
|
+
return VFG::getDef(valVar);
|
|
375
375
|
}
|
|
376
|
-
inline bool hasDef(const
|
|
376
|
+
inline bool hasDef(const ValVar* valVar) const
|
|
377
377
|
{
|
|
378
|
-
return VFG::hasDef(
|
|
378
|
+
return VFG::hasDef(valVar);
|
|
379
379
|
}
|
|
380
380
|
//@}
|
|
381
381
|
|
|
@@ -95,7 +95,7 @@ protected:
|
|
|
95
95
|
|
|
96
96
|
/// Connect SVFG nodes between caller and callee for indirect call sites
|
|
97
97
|
//@{
|
|
98
|
-
inline void connectAParamAndFParam(const
|
|
98
|
+
inline void connectAParamAndFParam(const ValVar* cs_arg, const ValVar* fun_arg, const CallICFGNode*, CallSiteID csId, SVFGEdgeSetTy& edges) override
|
|
99
99
|
{
|
|
100
100
|
NodeID phiId = getDef(fun_arg);
|
|
101
101
|
SVFGEdge* edge = addCallEdge(getDef(cs_arg), phiId, csId);
|
|
@@ -107,7 +107,7 @@ protected:
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
/// Connect formal-ret and actual ret
|
|
110
|
-
inline void connectFRetAndARet(const
|
|
110
|
+
inline void connectFRetAndARet(const ValVar* fun_ret, const ValVar* cs_ret, CallSiteID csId, SVFGEdgeSetTy& edges) override
|
|
111
111
|
{
|
|
112
112
|
NodeID phiId = getDef(cs_ret);
|
|
113
113
|
NodeID retdef = getDef(fun_ret);
|
|
@@ -244,7 +244,7 @@ private:
|
|
|
244
244
|
return (inter1 && inter2);
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
inline void addInterPHIOperands(PHISVFGNode* phi, const
|
|
247
|
+
inline void addInterPHIOperands(PHISVFGNode* phi, const ValVar* operand)
|
|
248
248
|
{
|
|
249
249
|
phi->setOpVer(phi->getOpVerNum(), operand);
|
|
250
250
|
}
|
|
@@ -267,10 +267,10 @@ private:
|
|
|
267
267
|
return sNode;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
inline void resetDef(const
|
|
270
|
+
inline void resetDef(const ValVar* valVar, const SVFGNode* node)
|
|
271
271
|
{
|
|
272
|
-
|
|
273
|
-
assert(it !=
|
|
272
|
+
ValVarToDefMapTy::iterator it = ValVarToDefMap.find(valVar);
|
|
273
|
+
assert(it != ValVarToDefMap.end() && "a SVFIR node doesn't have definition before");
|
|
274
274
|
it->second = node->getId();
|
|
275
275
|
}
|
|
276
276
|
|
|
@@ -59,7 +59,7 @@ public:
|
|
|
59
59
|
|
|
60
60
|
typedef OrderedMap<NodeID, VFGNode *> VFGNodeIDToNodeMapTy;
|
|
61
61
|
typedef Set<VFGNode*> VFGNodeSet;
|
|
62
|
-
typedef Map<const
|
|
62
|
+
typedef Map<const ValVar*, NodeID> ValVarToDefMapTy;
|
|
63
63
|
typedef Map<std::pair<NodeID,const CallICFGNode*>, ActualParmVFGNode *> SVFVarToActualParmMapTy;
|
|
64
64
|
typedef Map<const SVFVar*, ActualRetVFGNode *> SVFVarToActualRetMapTy;
|
|
65
65
|
typedef Map<const SVFVar*, FormalParmVFGNode *> SVFVarToFormalParmMapTy;
|
|
@@ -86,7 +86,7 @@ public:
|
|
|
86
86
|
|
|
87
87
|
protected:
|
|
88
88
|
NodeID totalVFGNode;
|
|
89
|
-
|
|
89
|
+
ValVarToDefMapTy ValVarToDefMap; ///< map a pag node to its definition SVG node
|
|
90
90
|
SVFVarToActualParmMapTy SVFVarToActualParmMap; ///< map a SVFVar to an actual parameter
|
|
91
91
|
SVFVarToActualRetMapTy SVFVarToActualRetMap; ///< map a SVFVar to an actual return
|
|
92
92
|
SVFVarToFormalParmMapTy SVFVarToFormalParmMap; ///< map a SVFVar to a formal parameter
|
|
@@ -185,10 +185,10 @@ public:
|
|
|
185
185
|
}
|
|
186
186
|
//@}
|
|
187
187
|
|
|
188
|
-
/// Given a
|
|
189
|
-
inline const VFGNode* getDefVFGNode(const
|
|
188
|
+
/// Given a valVar, return its definition site
|
|
189
|
+
inline const VFGNode* getDefVFGNode(const ValVar* valVar) const
|
|
190
190
|
{
|
|
191
|
-
return getVFGNode(getDef(
|
|
191
|
+
return getVFGNode(getDef(valVar));
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// Given an VFG node, return true if it has a left hand side top level pointer (PAGnode)
|
|
@@ -324,11 +324,11 @@ public:
|
|
|
324
324
|
const FunObjVar* isFunEntryVFGNode(const VFGNode* node) const;
|
|
325
325
|
|
|
326
326
|
/// Whether a SVFVar has a blackhole or const object as its definition
|
|
327
|
-
inline bool hasBlackHoleConstObjAddrAsDef(const
|
|
327
|
+
inline bool hasBlackHoleConstObjAddrAsDef(const ValVar* valVar) const
|
|
328
328
|
{
|
|
329
|
-
if (hasDef(
|
|
329
|
+
if (hasDef(valVar))
|
|
330
330
|
{
|
|
331
|
-
const VFGNode* defNode = getVFGNode(getDef(
|
|
331
|
+
const VFGNode* defNode = getVFGNode(getDef(valVar));
|
|
332
332
|
if (const AddrVFGNode* addr = SVFUtil::dyn_cast<AddrVFGNode>(defNode))
|
|
333
333
|
{
|
|
334
334
|
if (SVFIR::getPAG()->isBlkObjOrConstantObj(addr->getSVFStmt()->getSrcID()))
|
|
@@ -445,7 +445,7 @@ protected:
|
|
|
445
445
|
/// Connect VFG nodes between caller and callee for indirect call site
|
|
446
446
|
//@{
|
|
447
447
|
/// Connect actual-param and formal param
|
|
448
|
-
virtual inline void connectAParamAndFParam(const
|
|
448
|
+
virtual inline void connectAParamAndFParam(const ValVar* csArg, const ValVar* funArg, const CallICFGNode* cbn, CallSiteID csId, VFGEdgeSetTy& edges)
|
|
449
449
|
{
|
|
450
450
|
NodeID actualParam = getActualParmVFGNode(csArg, cbn)->getId();
|
|
451
451
|
NodeID formalParam = getFormalParmVFGNode(funArg)->getId();
|
|
@@ -454,7 +454,7 @@ protected:
|
|
|
454
454
|
edges.insert(edge);
|
|
455
455
|
}
|
|
456
456
|
/// Connect formal-ret and actual ret
|
|
457
|
-
virtual inline void connectFRetAndARet(const
|
|
457
|
+
virtual inline void connectFRetAndARet(const ValVar* funReturn, const ValVar* csReturn, CallSiteID csId, VFGEdgeSetTy& edges)
|
|
458
458
|
{
|
|
459
459
|
NodeID formalRet = getFormalRetVFGNode(funReturn)->getId();
|
|
460
460
|
NodeID actualRet = getActualRetVFGNode(csReturn)->getId();
|
|
@@ -464,30 +464,30 @@ protected:
|
|
|
464
464
|
}
|
|
465
465
|
//@}
|
|
466
466
|
|
|
467
|
-
/// Given a
|
|
467
|
+
/// Given a ValVar, set/get its def VFG node (definition of top level pointers)
|
|
468
468
|
//@{
|
|
469
|
-
inline void setDef(const
|
|
469
|
+
inline void setDef(const ValVar* valVar, const VFGNode* node)
|
|
470
470
|
{
|
|
471
|
-
|
|
472
|
-
if(it ==
|
|
471
|
+
ValVarToDefMapTy::iterator it = ValVarToDefMap.find(valVar);
|
|
472
|
+
if(it == ValVarToDefMap.end())
|
|
473
473
|
{
|
|
474
|
-
|
|
474
|
+
ValVarToDefMap[valVar] = node->getId();
|
|
475
475
|
assert(hasVFGNode(node->getId()) && "not in the map!!");
|
|
476
476
|
}
|
|
477
477
|
else
|
|
478
478
|
{
|
|
479
|
-
assert((it->second == node->getId()) && "a
|
|
479
|
+
assert((it->second == node->getId()) && "a ValVar can only have unique definition ");
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
|
-
inline NodeID getDef(const
|
|
482
|
+
inline NodeID getDef(const ValVar* valVar) const
|
|
483
483
|
{
|
|
484
|
-
|
|
485
|
-
assert(it!=
|
|
484
|
+
ValVarToDefMapTy::const_iterator it = ValVarToDefMap.find(valVar);
|
|
485
|
+
assert(it!=ValVarToDefMap.end() && "ValVar does not have a definition??");
|
|
486
486
|
return it->second;
|
|
487
487
|
}
|
|
488
|
-
inline bool hasDef(const
|
|
488
|
+
inline bool hasDef(const ValVar* valVar) const
|
|
489
489
|
{
|
|
490
|
-
return (
|
|
490
|
+
return (ValVarToDefMap.find(valVar) != ValVarToDefMap.end());
|
|
491
491
|
}
|
|
492
492
|
//@}
|
|
493
493
|
|
|
@@ -544,7 +544,7 @@ protected:
|
|
|
544
544
|
}
|
|
545
545
|
/// Add a Dummy VFG node for null pointer definition
|
|
546
546
|
/// To be noted for black hole pointer it has already has address edge connected
|
|
547
|
-
inline void addNullPtrVFGNode(const
|
|
547
|
+
inline void addNullPtrVFGNode(const ValVar* svfVar)
|
|
548
548
|
{
|
|
549
549
|
NullPtrVFGNode* sNode = new NullPtrVFGNode(totalVFGNode++,svfVar);
|
|
550
550
|
addVFGNode(sNode, pag->getICFG()->getGlobalICFGNode());
|
|
@@ -555,7 +555,7 @@ protected:
|
|
|
555
555
|
{
|
|
556
556
|
AddrVFGNode* sNode = new AddrVFGNode(totalVFGNode++,addr);
|
|
557
557
|
addStmtVFGNode(sNode, addr);
|
|
558
|
-
setDef(addr->getLHSVar(),sNode);
|
|
558
|
+
setDef(SVFUtil::cast<ValVar>(addr->getLHSVar()),sNode);
|
|
559
559
|
}
|
|
560
560
|
/// Add a Copy VFG node
|
|
561
561
|
inline void addCopyVFGNode(const CopyStmt* copy)
|
|
@@ -589,7 +589,7 @@ protected:
|
|
|
589
589
|
/// Add an actual parameter VFG node
|
|
590
590
|
/// To be noted that multiple actual parameters may have same value (SVFVar)
|
|
591
591
|
/// So we need to make a pair <SVFVarID,CallSiteID> to find the right VFGParmNode
|
|
592
|
-
inline void addActualParmVFGNode(const
|
|
592
|
+
inline void addActualParmVFGNode(const ValVar* aparm, const CallICFGNode* cs)
|
|
593
593
|
{
|
|
594
594
|
ActualParmVFGNode* sNode = new ActualParmVFGNode(totalVFGNode++,aparm,cs);
|
|
595
595
|
addVFGNode(sNode, const_cast<CallICFGNode*>(cs));
|
|
@@ -597,7 +597,7 @@ protected:
|
|
|
597
597
|
/// do not set def here, this node is not a variable definition
|
|
598
598
|
}
|
|
599
599
|
/// Add a formal parameter VFG node
|
|
600
|
-
inline void addFormalParmVFGNode(const
|
|
600
|
+
inline void addFormalParmVFGNode(const ValVar* fparm, const FunObjVar* fun, CallPESet& callPEs)
|
|
601
601
|
{
|
|
602
602
|
FormalParmVFGNode* sNode = new FormalParmVFGNode(totalVFGNode++,fparm,fun);
|
|
603
603
|
addVFGNode(sNode, pag->getICFG()->getFunEntryICFGNode(fun));
|
|
@@ -611,7 +611,7 @@ protected:
|
|
|
611
611
|
/// Add a callee Return VFG node
|
|
612
612
|
/// To be noted that here we assume returns of a procedure have already been unified into one
|
|
613
613
|
/// Otherwise, we need to handle formalRet using <SVFVarID,CallSiteID> pair to find FormalRetVFG node same as handling actual parameters
|
|
614
|
-
inline void addFormalRetVFGNode(const
|
|
614
|
+
inline void addFormalRetVFGNode(const ValVar* uniqueFunRet, const FunObjVar* fun, RetPESet& retPEs)
|
|
615
615
|
{
|
|
616
616
|
FormalRetVFGNode *sNode = new FormalRetVFGNode(totalVFGNode++, uniqueFunRet, fun);
|
|
617
617
|
addVFGNode(sNode, pag->getICFG()->getFunExitICFGNode(fun));
|
|
@@ -630,7 +630,7 @@ protected:
|
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
632
|
/// Add a callsite Receive VFG node
|
|
633
|
-
inline void addActualRetVFGNode(const
|
|
633
|
+
inline void addActualRetVFGNode(const ValVar* ret,const CallICFGNode* cs)
|
|
634
634
|
{
|
|
635
635
|
ActualRetVFGNode* sNode = new ActualRetVFGNode(totalVFGNode++,ret,cs);
|
|
636
636
|
addVFGNode(sNode, const_cast<RetICFGNode*>(cs->getRetICFGNode()));
|
|
@@ -640,7 +640,8 @@ protected:
|
|
|
640
640
|
/// Add an llvm PHI VFG node
|
|
641
641
|
inline void addIntraPHIVFGNode(const MultiOpndStmt* edge)
|
|
642
642
|
{
|
|
643
|
-
|
|
643
|
+
const ValVar* res = SVFUtil::cast<ValVar>(edge->getRes());
|
|
644
|
+
IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,res);
|
|
644
645
|
u32_t pos = 0;
|
|
645
646
|
for(auto var : edge->getOpndVars())
|
|
646
647
|
{
|
|
@@ -648,13 +649,14 @@ protected:
|
|
|
648
649
|
pos++;
|
|
649
650
|
}
|
|
650
651
|
addVFGNode(sNode,edge->getICFGNode());
|
|
651
|
-
setDef(
|
|
652
|
-
SVFVarToIntraPHIVFGNodeMap[
|
|
652
|
+
setDef(res,sNode);
|
|
653
|
+
SVFVarToIntraPHIVFGNodeMap[res] = sNode;
|
|
653
654
|
}
|
|
654
655
|
/// Add a Compare VFG node
|
|
655
656
|
inline void addCmpVFGNode(const CmpStmt* edge)
|
|
656
657
|
{
|
|
657
|
-
|
|
658
|
+
const ValVar* res = SVFUtil::cast<ValVar>(edge->getRes());
|
|
659
|
+
CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, res);
|
|
658
660
|
u32_t pos = 0;
|
|
659
661
|
for(auto var : edge->getOpndVars())
|
|
660
662
|
{
|
|
@@ -662,13 +664,14 @@ protected:
|
|
|
662
664
|
pos++;
|
|
663
665
|
}
|
|
664
666
|
addVFGNode(sNode,edge->getICFGNode());
|
|
665
|
-
setDef(
|
|
666
|
-
SVFVarToCmpVFGNodeMap[
|
|
667
|
+
setDef(res,sNode);
|
|
668
|
+
SVFVarToCmpVFGNodeMap[res] = sNode;
|
|
667
669
|
}
|
|
668
670
|
/// Add a BinaryOperator VFG node
|
|
669
671
|
inline void addBinaryOPVFGNode(const BinaryOPStmt* edge)
|
|
670
672
|
{
|
|
671
|
-
|
|
673
|
+
const ValVar* res = SVFUtil::cast<ValVar>(edge->getRes());
|
|
674
|
+
BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++, res);
|
|
672
675
|
u32_t pos = 0;
|
|
673
676
|
for(auto var : edge->getOpndVars())
|
|
674
677
|
{
|
|
@@ -676,8 +679,8 @@ protected:
|
|
|
676
679
|
pos++;
|
|
677
680
|
}
|
|
678
681
|
addVFGNode(sNode,edge->getICFGNode());
|
|
679
|
-
setDef(
|
|
680
|
-
SVFVarToBinaryOPVFGNodeMap[
|
|
682
|
+
setDef(res,sNode);
|
|
683
|
+
SVFVarToBinaryOPVFGNodeMap[res] = sNode;
|
|
681
684
|
}
|
|
682
685
|
/// Add a UnaryOperator VFG node
|
|
683
686
|
inline void addUnaryOPVFGNode(const UnaryOPStmt* edge)
|