Static Value-Flow Analysis
Loading...
Searching...
No Matches
SVFStatements.h
Go to the documentation of this file.
1//===- SVFStatements.h -- SVF statements-------------------------------------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-> <Yulei Sui>
6//
7
8// This program is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Affero General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===----------------------------------------------------------------------===//
22
23
24/*
25 * SVFStatements.h
26 *
27 * Created on: Nov 10, 2013
28 * Author: Yulei Sui
29 */
30
31#ifndef INCLUDE_SVFIR_SVFSTATEMENT_H_
32#define INCLUDE_SVFIR_SVFSTATEMENT_H_
33
34#include "Graphs/GenericGraph.h"
36
37namespace SVF
38{
39
40class SVFVar;
41class ICFGNode;
42class IntraICFGNode;
43class CallICFGNode;
44class FunEntryICFGNode;
45class FunExitICFGNode;
46class SVFBasicBlock;
47
48/*
49 * SVFIR program statements (PAGEdges)
50 */
53{
54
55public:
78
79private:
80 const SVFVar* value;
84
85protected:
88 : GenericPAGEdgeTy({}, {}, k), value{}, basicBlock{}, icfgNode{}
89 {
90 }
91
92public:
94
96 SVFStmt(SVFVar* s, SVFVar* d, GEdgeFlag k, bool real = true);
99
101
102 static inline bool classof(const SVFStmt*)
103 {
104 return true;
105 }
106 static inline bool classof(const GenericPAGEdgeTy* edge)
107 {
108 return edge->getEdgeKind() == SVFStmt::Addr ||
109 edge->getEdgeKind() == SVFStmt::Copy ||
110 edge->getEdgeKind() == SVFStmt::Store ||
111 edge->getEdgeKind() == SVFStmt::Load ||
112 edge->getEdgeKind() == SVFStmt::Call ||
113 edge->getEdgeKind() == SVFStmt::Ret ||
114 edge->getEdgeKind() == SVFStmt::Gep ||
115 edge->getEdgeKind() == SVFStmt::Phi ||
116 edge->getEdgeKind() == SVFStmt::Select ||
117 edge->getEdgeKind() == SVFStmt::Cmp ||
118 edge->getEdgeKind() == SVFStmt::BinaryOp ||
119 edge->getEdgeKind() == SVFStmt::UnaryOp ||
120 edge->getEdgeKind() == SVFStmt::Branch ||
121 edge->getEdgeKind() == SVFStmt::ThreadFork ||
122 edge->getEdgeKind() == SVFStmt::ThreadJoin;
123 }
125
127 inline EdgeID getEdgeID() const
128 {
129 return edgeId;
130 }
132 virtual bool isPTAEdge() const;
133
135
136
137 inline void setValue(const SVFVar* val)
138 {
139 value = val;
140 }
141 inline const SVFVar* getValue() const
142 {
143 return value;
144 }
145
146 inline void setBB(const SVFBasicBlock* bb)
147 {
148 basicBlock = bb;
149 }
150 inline const SVFBasicBlock* getBB() const
151 {
152 return basicBlock;
153 }
154 inline void setICFGNode(ICFGNode* node)
155 {
156 icfgNode = node;
157 }
158 inline ICFGNode* getICFGNode() const
159 {
160 return icfgNode;
161 }
163
167 const SVFVar* var)
168 {
170 if (it_inserted.second)
172 u64_t label = it_inserted.first->second;
173 return (label << EdgeKindMaskBits) | k;
174 }
175
179 const ICFGNode* cs)
180 {
182 if (it_inserted.second)
184 u64_t label = it_inserted.first->second;
185 return (label << EdgeKindMaskBits) | k;
186 }
187
191 const ICFGNode* store)
192 {
193 auto it_inserted = inst2LabelMap.emplace(store, storeEdgeLabelCounter);
194 if (it_inserted.second)
196 u64_t label = it_inserted.first->second;
197 return (label << EdgeKindMaskBits) | k;
198 }
199
200 virtual const std::string toString() const;
201
203
206 {
207 o << edge.toString();
208 return o;
209 }
211
216
217private:
225};
226
227/*
228 Parent class of Addr, Copy, Store, Load, Call, Ret, NormalGep, VariantGep, ThreadFork, ThreadJoin
229 connecting RHS expression and LHS expression with an assignment (e.g., LHSExpr = RHSExpr)
230 Only one operand on the right hand side of an assignment
231*/
232class AssignStmt : public SVFStmt
233{
234
235private:
238 void operator=(const AssignStmt &);
243
244protected:
247
248public:
250
251 static inline bool classof(const AssignStmt*)
252 {
253 return true;
254 }
255 static inline bool classof(const SVFStmt* edge)
256 {
257 return edge->getEdgeKind() == SVFStmt::Addr ||
258 edge->getEdgeKind() == SVFStmt::Copy ||
259 edge->getEdgeKind() == SVFStmt::Store ||
260 edge->getEdgeKind() == SVFStmt::Load ||
261 edge->getEdgeKind() == SVFStmt::Call ||
262 edge->getEdgeKind() == SVFStmt::Ret ||
263 edge->getEdgeKind() == SVFStmt::Gep ||
264 edge->getEdgeKind() == SVFStmt::ThreadFork ||
265 edge->getEdgeKind() == SVFStmt::ThreadJoin;
266 }
267 static inline bool classof(const GenericPAGEdgeTy* edge)
268 {
269 return edge->getEdgeKind() == SVFStmt::Addr ||
270 edge->getEdgeKind() == SVFStmt::Copy ||
271 edge->getEdgeKind() == SVFStmt::Store ||
272 edge->getEdgeKind() == SVFStmt::Load ||
273 edge->getEdgeKind() == SVFStmt::Call ||
274 edge->getEdgeKind() == SVFStmt::Ret ||
275 edge->getEdgeKind() == SVFStmt::Gep ||
276 edge->getEdgeKind() == SVFStmt::ThreadFork ||
277 edge->getEdgeKind() == SVFStmt::ThreadJoin;
278 }
280
281 inline SVFVar* getRHSVar() const
282 {
283 return SVFStmt::getSrcNode();
284 }
285 inline SVFVar* getLHSVar() const
286 {
287 return SVFStmt::getDstNode();
288 }
289 inline NodeID getRHSVarID() const
290 {
291 return SVFStmt::getSrcID();
292 }
293 inline NodeID getLHSVarID() const
294 {
295 return SVFStmt::getDstID();
296 }
297
298 virtual const std::string toString() const = 0;
299};
300
304class AddrStmt: public AssignStmt
305{
306
307private:
309 void operator=(const AddrStmt&);
310
311 std::vector<SVFVar*> arrSize;
312
313public:
315
316 static inline bool classof(const AddrStmt*)
317 {
318 return true;
319 }
320 static inline bool classof(const SVFStmt* edge)
321 {
322 return edge->getEdgeKind() == SVFStmt::Addr;
323 }
324 static inline bool classof(const GenericPAGEdgeTy* edge)
325 {
326 return edge->getEdgeKind() == SVFStmt::Addr;
327 }
329
332
333 virtual const std::string toString() const override;
334
335 inline void addArrSize(SVFVar* size) //TODO:addSizeVar
336 {
337 arrSize.push_back(size);
338 }
339
341 inline const std::vector<SVFVar*>& getArrSize() const //TODO:getSizeVars
342 {
343 return arrSize;
344 }
345
346 virtual bool isPTAEdge() const override
347 {
348 return true;
349 }
350};
351
355class CopyStmt: public AssignStmt
356{
357
358private:
360 void operator=(const CopyStmt&);
361public:
363 {
364 COPYVAL, // Value copies (default one)
365 ZEXT, // Zero extend integers
366 SEXT, // Sign extend integers
367 BITCAST, // Type cast
368 TRUNC, // Truncate integers
369 FPTRUNC, // Truncate floating point
370 FPTOUI, // floating point -> UInt
371 FPTOSI, // floating point -> SInt
372 UITOFP, // UInt -> floating point
373 SITOFP, // SInt -> floating point
374 INTTOPTR, // Integer -> Pointer
375 PTRTOINT // Pointer -> Integer
376 };
378
379 static inline bool classof(const CopyStmt*)
380 {
381 return true;
382 }
383 static inline bool classof(const SVFStmt* edge)
384 {
385 return edge->getEdgeKind() == SVFStmt::Copy;
386 }
387 static inline bool classof(const GenericPAGEdgeTy* edge)
388 {
389 return edge->getEdgeKind() == SVFStmt::Copy;
390 }
392
394 inline u32_t getCopyKind() const
395 {
396 return copyKind;
397 }
398
399 inline bool isBitCast() const
400 {
401 return copyKind == BITCAST;
402 }
403
404 inline bool isValueCopy() const
405 {
406 return copyKind == COPYVAL;
407 }
408
409 inline bool isInt2Ptr() const
410 {
411 return copyKind == INTTOPTR;
412 }
413
414 inline bool isPtr2Int() const
415 {
416 return copyKind == PTRTOINT;
417 }
418
419 inline bool isZext() const
420 {
421 return copyKind == ZEXT;
422 }
423
424 inline bool isSext() const
425 {
426 return copyKind == SEXT;
427 }
428
431
432 virtual const std::string toString() const override;
433private:
435};
436
441{
442
443private:
445 void operator=(const StoreStmt&);
446
447public:
449
450 static inline bool classof(const StoreStmt*)
451 {
452 return true;
453 }
454 static inline bool classof(const SVFStmt* edge)
455 {
456 return edge->getEdgeKind() == SVFStmt::Store;
457 }
458 static inline bool classof(const GenericPAGEdgeTy* edge)
459 {
460 return edge->getEdgeKind() == SVFStmt::Store;
461 }
463
465 StoreStmt(SVFVar* s, SVFVar* d, const ICFGNode* st);
466
467 virtual const std::string toString() const override;
468};
469
473class LoadStmt: public AssignStmt
474{
475
476private:
478 void operator=(const LoadStmt&);
479
480public:
482
483 static inline bool classof(const LoadStmt*)
484 {
485 return true;
486 }
487 static inline bool classof(const SVFStmt* edge)
488 {
489 return edge->getEdgeKind() == SVFStmt::Load;
490 }
491 static inline bool classof(const GenericPAGEdgeTy* edge)
492 {
493 return edge->getEdgeKind() == SVFStmt::Load;
494 }
496
499
500 virtual const std::string toString() const override;
501};
502
506class GepStmt: public AssignStmt
507{
508
509private:
510 GepStmt(const GepStmt &);
511 void operator=(const GepStmt &);
512
515public:
517
518 static inline bool classof(const GepStmt*)
519 {
520 return true;
521 }
522 static inline bool classof(const SVFStmt* edge)
523 {
524 return edge->getEdgeKind() == SVFStmt::Gep;
525 }
526 static inline bool classof(const GenericPAGEdgeTy* edge)
527 {
528 return edge->getEdgeKind() == SVFStmt::Gep;
529 }
531
532 inline const AccessPath& getAccessPath() const
533 {
534 return ap;
535 }
541 inline bool isConstantOffset() const
542 {
544 }
545
555
558 {
560 }
563 {
564 assert(isVariantFieldGep()==false && "Can't retrieve the AccessPath if using a variable field index (pointer arithmetic) for struct field access ");
566 }
568 inline bool isVariantFieldGep() const
569 {
570 return variantField;
571 }
572
574 GepStmt(SVFVar* s, SVFVar* d, const AccessPath& ap, bool varfld = false)
576 {
577 }
578
579 virtual const std::string toString() const;
580
581};
582
583
587class CallPE: public AssignStmt
588{
589
590private:
591 CallPE(const CallPE&);
592 void operator=(const CallPE&);
593
596
597public:
599
600 static inline bool classof(const CallPE*)
601 {
602 return true;
603 }
604 static inline bool classof(const SVFStmt* edge)
605 {
606 return edge->getEdgeKind() == SVFStmt::Call ||
607 edge->getEdgeKind() == SVFStmt::ThreadFork;
608 }
609 static inline bool classof(const GenericPAGEdgeTy* edge)
610 {
611 return edge->getEdgeKind() == SVFStmt::Call ||
612 edge->getEdgeKind() == SVFStmt::ThreadFork;
613 }
615
617 CallPE(SVFVar* s, SVFVar* d, const CallICFGNode* i,
619
621
622 inline const CallICFGNode* getCallInst() const
623 {
624 return call;
625 }
626 inline const CallICFGNode* getCallSite() const
627 {
628 return call;
629 }
631 {
632 return entry;
633 }
635
636 virtual const std::string toString() const override;
637};
638
642class RetPE: public AssignStmt
643{
644
645private:
646 RetPE(const RetPE&);
647 void operator=(const RetPE&);
648
651
652public:
654
655 static inline bool classof(const RetPE*)
656 {
657 return true;
658 }
659 static inline bool classof(const SVFStmt* edge)
660 {
661 return edge->getEdgeKind() == SVFStmt::Ret ||
662 edge->getEdgeKind() == SVFStmt::ThreadJoin;
663 }
664 static inline bool classof(const GenericPAGEdgeTy* edge)
665 {
666 return edge->getEdgeKind() == SVFStmt::Ret ||
667 edge->getEdgeKind() == SVFStmt::ThreadJoin;
668 }
670
672 RetPE(SVFVar* s, SVFVar* d, const CallICFGNode* i, const FunExitICFGNode* e,
674
676
677 inline const CallICFGNode* getCallInst() const
678 {
679 return call;
680 }
681 inline const CallICFGNode* getCallSite() const
682 {
683 return call;
684 }
686 {
687 return exit;
688 }
690
691 virtual const std::string toString() const override;
692};
693
694/*
695* Program statements with multiple operands including BinaryOPStmt, CmpStmt and PhiStmt
696*/
697class MultiOpndStmt : public SVFStmt
698{
699
700public:
701 typedef std::vector<SVFVar*> OPVars;
702
703private:
711
712protected:
716
717public:
719
720 static inline bool classof(const MultiOpndStmt*)
721 {
722 return true;
723 }
724 static inline bool classof(const SVFStmt* node)
725 {
726 return node->getEdgeKind() == Phi || node->getEdgeKind() == Select ||
727 node->getEdgeKind() == BinaryOp || node->getEdgeKind() == Cmp;
728 }
729 static inline bool classof(const GenericPAGEdgeTy* node)
730 {
731 return node->getEdgeKind() == Phi || node->getEdgeKind() == Select ||
732 node->getEdgeKind() == BinaryOp || node->getEdgeKind() == Cmp;
733 }
735
737
738
739 inline const SVFVar* getOpVar(u32_t pos) const
740 {
741 return opVars.at(pos);
742 }
744 inline const SVFVar* getRes() const
745 {
746 return SVFStmt::getDstNode();
747 }
748
749 NodeID getOpVarID(u32_t pos) const;
750 NodeID getResID() const;
751
752 inline u32_t getOpVarNum() const
753 {
754 return opVars.size();
755 }
756 inline const OPVars& getOpndVars() const
757 {
758 return opVars;
759 }
760 inline OPVars::const_iterator opVarBegin() const
761 {
762 return opVars.begin();
763 }
764 inline OPVars::const_iterator opVerEnd() const
765 {
766 return opVars.end();
767 }
769};
770
776{
777
778public:
779 typedef std::vector<const ICFGNode*> OpICFGNodeVec;
780
781private:
782 PhiStmt(const PhiStmt&);
783 void operator=(const PhiStmt&);
784
786
787public:
789
790 static inline bool classof(const PhiStmt*)
791 {
792 return true;
793 }
794 static inline bool classof(const SVFStmt* edge)
795 {
796 return edge->getEdgeKind() == SVFStmt::Phi;
797 }
798 static inline bool classof(const MultiOpndStmt* edge)
799 {
800 return edge->getEdgeKind() == SVFStmt::Phi;
801 }
802 static inline bool classof(const GenericPAGEdgeTy* edge)
803 {
804 return edge->getEdgeKind() == SVFStmt::Phi;
805 }
807
809 PhiStmt(SVFVar* s, const OPVars& opnds, const OpICFGNodeVec& icfgNodes)
810 : MultiOpndStmt(s, opnds, SVFStmt::Phi), opICFGNodes(icfgNodes)
811 {
812 assert(opnds.size() == icfgNodes.size() &&
813 "Numbers of operands and their ICFGNodes are not consistent?");
814 }
816 {
817 opVars.push_back(op);
818 opICFGNodes.push_back(inode);
819 assert(opVars.size() == opICFGNodes.size() &&
820 "Numbers of operands and their ICFGNodes are not consistent?");
821 }
822
824 inline const ICFGNode* getOpICFGNode(u32_t op_idx) const
825 {
826 return opICFGNodes.at(op_idx);
827 }
828
831 bool isFunctionRetPhi() const;
832
833 virtual const std::string toString() const override;
834};
835
840{
841
842private:
844 void operator=(const SelectStmt&);
845
847
848public:
850
851 static inline bool classof(const SelectStmt*)
852 {
853 return true;
854 }
855 static inline bool classof(const SVFStmt* edge)
856 {
857 return edge->getEdgeKind() == SVFStmt::Select;
858 }
859 static inline bool classof(const MultiOpndStmt* edge)
860 {
861 return edge->getEdgeKind() == SVFStmt::Select;
862 }
863 static inline bool classof(const GenericPAGEdgeTy* edge)
864 {
865 return edge->getEdgeKind() == SVFStmt::Select;
866 }
868
870 SelectStmt(SVFVar* s, const OPVars& opnds, const SVFVar* cond);
871 virtual const std::string toString() const override;
872
873 inline const SVFVar* getCondition() const
874 {
875 return condition;
876 }
877 inline const SVFVar* getTrueValue() const
878 {
879 return getOpVar(0);
880 }
881 inline const SVFVar* getFalseValue() const
882 {
883 return getOpVar(1);
884 }
885};
886
891{
892
893private:
894 CmpStmt(const CmpStmt&);
895 void operator=(const CmpStmt&);
896
898
899public:
937
939
940 static inline bool classof(const CmpStmt*)
941 {
942 return true;
943 }
944 static inline bool classof(const SVFStmt* edge)
945 {
946 return edge->getEdgeKind() == SVFStmt::Cmp;
947 }
948 static inline bool classof(const MultiOpndStmt* edge)
949 {
950 return edge->getEdgeKind() == SVFStmt::Cmp;
951 }
952 static inline bool classof(const GenericPAGEdgeTy* edge)
953 {
954 return edge->getEdgeKind() == SVFStmt::Cmp;
955 }
957
959 CmpStmt(SVFVar* s, const OPVars& opnds, u32_t pre);
960
962 {
963 return predicate;
964 }
965
966 virtual const std::string toString() const override;
967};
968
973{
974
975private:
977 void operator=(const BinaryOPStmt&);
979
980public:
982 enum OpCode : unsigned
983 {
984 Add = 13, // Sum of integers
985 FAdd = 14, // Sum of floats
986 Sub = 15, // Subtraction of integers
987 FSub = 16, // Subtraction of floats
988 Mul = 17, // Product of integers.
989 FMul = 18, // Product of floats.
990 UDiv = 19, // Unsigned division.
991 SDiv = 20, // Signed division.
992 FDiv = 21, // Float division.
993 URem = 22, // Unsigned remainder
994 SRem = 23, // Signed remainder
995 FRem = 24, // Float remainder
996 Shl = 25, // Shift left (logical)
997 LShr = 26, // Shift right (logical)
998 AShr = 27, // Shift right (arithmetic)
999 And = 28, // Logical and
1000 Or = 29, // Logical or
1001 Xor = 30 // Logical xor
1003
1005
1006 static inline bool classof(const BinaryOPStmt*)
1007 {
1008 return true;
1009 }
1010 static inline bool classof(const SVFStmt* edge)
1011 {
1012 return edge->getEdgeKind() == SVFStmt::BinaryOp;
1013 }
1014 static inline bool classof(const MultiOpndStmt* edge)
1015 {
1016 return edge->getEdgeKind() == SVFStmt::BinaryOp;
1017 }
1018 static inline bool classof(const GenericPAGEdgeTy* edge)
1019 {
1020 return edge->getEdgeKind() == SVFStmt::BinaryOp;
1021 }
1023
1026
1028 {
1029 return opcode;
1030 }
1031
1032 virtual const std::string toString() const override;
1033};
1034
1039{
1040
1041private:
1043 void operator=(const UnaryOPStmt&);
1048
1050
1051public:
1053 enum OpCode : unsigned
1054 {
1055 FNeg = 12
1057
1059
1060 static inline bool classof(const UnaryOPStmt*)
1061 {
1062 return true;
1063 }
1064 static inline bool classof(const SVFStmt* edge)
1065 {
1066 return edge->getEdgeKind() == SVFStmt::UnaryOp;
1067 }
1068 static inline bool classof(const GenericPAGEdgeTy* edge)
1069 {
1070 return edge->getEdgeKind() == SVFStmt::UnaryOp;
1071 }
1073
1077 {
1078 }
1079
1081 {
1082 return opcode;
1083 }
1084 inline const SVFVar* getOpVar() const
1085 {
1086 return SVFStmt::getSrcNode();
1087 }
1088 inline const SVFVar* getRes() const
1089 {
1090 return SVFStmt::getDstNode();
1091 }
1092 NodeID getOpVarID() const;
1093 NodeID getResID() const;
1094
1095 virtual const std::string toString() const override;
1096};
1097
1101class BranchStmt: public SVFStmt
1102{
1103
1104public:
1105 typedef std::vector<std::pair<const ICFGNode*, s32_t>> SuccAndCondPairVec;
1106
1107private:
1109 void operator=(const BranchStmt&);
1114
1116 const SVFVar* cond;
1118
1119public:
1121
1122 static inline bool classof(const BranchStmt*)
1123 {
1124 return true;
1125 }
1126 static inline bool classof(const SVFStmt* edge)
1127 {
1128 return edge->getEdgeKind() == SVFStmt::Branch;
1129 }
1130 static inline bool classof(const GenericPAGEdgeTy* edge)
1131 {
1132 return edge->getEdgeKind() == SVFStmt::Branch;
1133 }
1135
1138 : SVFStmt(c, inst, SVFStmt::Branch), successors(succs), cond(c),
1139 brInst(inst)
1140 {
1141 }
1142
1144 bool isUnconditional() const;
1146 bool isConditional() const;
1148 const SVFVar* getCondition() const;
1149 const SVFVar* getBranchInst() const
1150 {
1151 return brInst;
1152 }
1153
1157
1161
1165 {
1166 return successors.size();
1167 }
1169 {
1170 return successors;
1171 }
1173 {
1174 return successors.at(i).first;
1175 }
1177 {
1178 return successors.at(i).second;
1179 }
1181 virtual const std::string toString() const override;
1182};
1183
1187class TDForkPE: public CallPE
1188{
1189
1190private:
1192 void operator=(const TDForkPE&);
1193
1194public:
1196
1197 static inline bool classof(const TDForkPE*)
1198 {
1199 return true;
1200 }
1201 static inline bool classof(const SVFStmt* edge)
1202 {
1203 return edge->getEdgeKind() == SVFStmt::ThreadFork;
1204 }
1205 static inline bool classof(const GenericPAGEdgeTy* edge)
1206 {
1207 return edge->getEdgeKind() == SVFStmt::ThreadFork;
1208 }
1210
1213 const FunEntryICFGNode* entry)
1215 {
1216 }
1217
1218 virtual const std::string toString() const;
1219};
1220
1224class TDJoinPE: public RetPE
1225{
1226
1227private:
1229 void operator=(const TDJoinPE&);
1230
1231public:
1233
1234 static inline bool classof(const TDJoinPE*)
1235 {
1236 return true;
1237 }
1238 static inline bool classof(const SVFStmt* edge)
1239 {
1240 return edge->getEdgeKind() == SVFStmt::ThreadJoin;
1241 }
1242 static inline bool classof(const GenericPAGEdgeTy* edge)
1243 {
1244 return edge->getEdgeKind() == SVFStmt::ThreadJoin;
1245 }
1247
1250 const FunExitICFGNode* e)
1251 : RetPE(s, d, i, e, SVFStmt::ThreadJoin)
1252 {
1253 }
1254
1255 virtual const std::string toString() const;
1256};
1257
1258} // End namespace SVF
1259
1260#endif /* INCLUDE_SVFIR_SVFSTATEMENT_H_ */
std::vector< IdxOperandPair > IdxOperandPairs
Definition AccessPath.h:62
bool isConstantOffset() const
Return TRUE if this is a constant location set.
APOffset computeConstantByteOffset() const
APOffset getConstantStructFldIdx() const
Get methods.
Definition AccessPath.h:97
const IdxOperandPairs & getIdxOperandPairVec() const
Definition AccessPath.h:105
APOffset computeConstantOffset() const
For example,.
void operator=(const AddrStmt &)
place holder
AddrStmt(const AddrStmt &)
place holder
void addArrSize(SVFVar *size)
get array size of the allocated memory
static bool classof(const AddrStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
AddrStmt(SVFVar *s, SVFVar *d)
constructor
static bool classof(const GenericPAGEdgeTy *edge)
virtual bool isPTAEdge() const override
Whether src and dst nodes are both of pointer type.
virtual const std::string toString() const override
std::vector< SVFVar * > arrSize
Array size of the allocated memory.
const std::vector< SVFVar * > & getArrSize() const
static bool classof(const SVFStmt *edge)
SVFVar * getSrcNode()
not allowed, use getRHSVar() instead
SVFVar * getDstNode()
not allowed, use getLHSVar() instead
AssignStmt(const AssignStmt &)
place holder
NodeID getRHSVarID() const
static bool classof(const AssignStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const GenericPAGEdgeTy *edge)
NodeID getLHSVarID() const
NodeID getDstID()
not allowed, use getLHSVarID() instead
NodeID getSrcID()
not allowed, use getRHSVarID() instead
SVFVar * getLHSVar() const
virtual const std::string toString() const =0
AssignStmt()
place holder
SVFVar * getRHSVar() const
void operator=(const AssignStmt &)
place holder
static bool classof(const SVFStmt *edge)
AssignStmt(SVFVar *s, SVFVar *d, GEdgeFlag k)
constructor
virtual const std::string toString() const override
OpCode
OpCode for BinaryOPStmt, enum value is same to llvm BinaryOperator (llvm/IR/Instruction....
static bool classof(const MultiOpndStmt *edge)
void operator=(const BinaryOPStmt &)
place holder
BinaryOPStmt(const BinaryOPStmt &)
place holder
static bool classof(const BinaryOPStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const SVFStmt *edge)
static bool classof(const GenericPAGEdgeTy *edge)
u32_t getOpcode() const
u32_t getNumSuccessors() const
bool isUnconditional() const
The branch is unconditional if cond is a null value.
const ICFGNode * getSuccessor(u32_t i) const
const SVFVar * brInst
SuccAndCondPairVec successors
void operator=(const BranchStmt &)
place holder
static bool classof(const SVFStmt *edge)
BranchStmt(SVFVar *inst, SVFVar *c, const SuccAndCondPairVec &succs)
constructor
std::vector< std::pair< const ICFGNode *, s32_t > > SuccAndCondPairVec
BranchStmt(const BranchStmt &)
place holder
bool isConditional() const
The branch is conditional if cond is not a null value.
static bool classof(const BranchStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
s64_t getSuccessorCondValue(u32_t i) const
SVFVar * getDstNode()
place holder, not allowed
const SVFVar * getCondition() const
Return the condition.
NodeID getSrcID()
place holder, use getOpVarID(pos) instead
const SVFVar * getBranchInst() const
SVFVar * getSrcNode()
place holder, not allowed
const SuccAndCondPairVec & getSuccessors() const
NodeID getDstID()
place holder, use getResID() instead
const SVFVar * cond
static bool classof(const GenericPAGEdgeTy *edge)
virtual const std::string toString() const override
static bool classof(const GenericPAGEdgeTy *edge)
static bool classof(const SVFStmt *edge)
CallPE(const CallPE &)
place holder
const CallICFGNode * getCallSite() const
const FunEntryICFGNode * getFunEntryICFGNode() const
static bool classof(const CallPE *)
the function exit statement calling to
const FunEntryICFGNode * entry
the callsite statement calling from
void operator=(const CallPE &)
place holder
const CallICFGNode * call
const CallICFGNode * getCallInst() const
Get method for the call instruction.
virtual const std::string toString() const override
static bool classof(const SVFStmt *edge)
virtual const std::string toString() const override
static bool classof(const MultiOpndStmt *edge)
void operator=(const CmpStmt &)
place holder
u32_t getPredicate() const
CmpStmt(const CmpStmt &)
place holder
Predicate
OpCode for CmpStmt, enum value is same to llvm CmpInst.
@ ICMP_SGT
signed greater than
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ ICMP_UGE
unsigned greater or equal
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ ICMP_ULE
unsigned less or equal
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ ICMP_NE
not equal
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
@ ICMP_ULT
unsigned less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ ICMP_SLT
signed less than
@ ICMP_UGT
unsigned greater than
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ ICMP_SGE
signed greater or equal
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ ICMP_SLE
signed less or equal
static bool classof(const CmpStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const GenericPAGEdgeTy *edge)
static bool classof(const GenericPAGEdgeTy *edge)
static bool classof(const CopyStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
CopyStmt(SVFVar *s, SVFVar *d, CopyKind k)
constructor
u32_t getCopyKind() const
Return the kind of the copy statement.
bool isZext() const
bool isPtr2Int() const
static bool classof(const SVFStmt *edge)
bool isBitCast() const
void operator=(const CopyStmt &)
place holder
CopyStmt(const CopyStmt &)
place holder
bool isValueCopy() const
virtual const std::string toString() const override
bool isInt2Ptr() const
bool isSext() const
NodeType * getSrcNode() const
NodeType * getDstNode() const
GEdgeKind getEdgeKind() const
NodeID getDstID() const
NodeID getSrcID() const
get methods of the components
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
Edge kind.
bool isVariantFieldGep() const
Gep statement with a variant field index (pointer arithmetic) for struct field access.
APOffset accumulateConstantOffset() const
Return accumulated constant offset (when accessing array or struct) if this offset is a constant.
APOffset accumulateConstantByteOffset() const
const AccessPath::IdxOperandPairs getOffsetVarAndGepTypePairVec() const
static bool classof(const GepStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
APOffset getConstantStructFldIdx() const
Field index of the gep statement if it access the field of a struct.
GepStmt(const GepStmt &)
place holder
GepStmt(SVFVar *s, SVFVar *d, const AccessPath &ap, bool varfld=false)
constructor
static bool classof(const SVFStmt *edge)
const AccessPath & getAccessPath() const
void operator=(const GepStmt &)
place holder
bool isConstantOffset() const
Return TRUE if this is a constant location set.
static bool classof(const GenericPAGEdgeTy *edge)
virtual const std::string toString() const
AccessPath ap
Access path of the GEP edge.
bool variantField
Gep statement with a variant field index (pointer arithmetic) for struct field access (e....
static bool classof(const LoadStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
LoadStmt(const LoadStmt &)
place holder
virtual const std::string toString() const override
LoadStmt(SVFVar *s, SVFVar *d)
constructor
static bool classof(const GenericPAGEdgeTy *edge)
static bool classof(const SVFStmt *edge)
void operator=(const LoadStmt &)
place holder
const OPVars & getOpndVars() const
const SVFVar * getRes() const
Result SVFVar.
NodeID getDstID()
not allowed, use getResID() instead
NodeID getOpVarID(u32_t pos) const
static bool classof(const SVFStmt *node)
MultiOpndStmt()
place holder
MultiOpndStmt(const MultiOpndStmt &)
place holder
NodeID getResID() const
SVFVar * getSrcNode()
not allowed, use getOpVar(idx) instead
static bool classof(const MultiOpndStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
const SVFVar * getOpVar(u32_t pos) const
Operand SVFVars.
OPVars::const_iterator opVarBegin() const
SVFVar * getDstNode()
not allowed, use getRes() instead
NodeID getSrcID()
not allowed, use getOpVarID(idx) instead
std::vector< SVFVar * > OPVars
static bool classof(const GenericPAGEdgeTy *node)
OPVars::const_iterator opVerEnd() const
u32_t getOpVarNum() const
void operator=(const MultiOpndStmt &)
place holder
virtual const std::string toString() const override
const ICFGNode * getOpICFGNode(u32_t op_idx) const
Return the corresponding ICFGNode of this operand.
void operator=(const PhiStmt &)
place holder
std::vector< const ICFGNode * > OpICFGNodeVec
OpICFGNodeVec opICFGNodes
PhiStmt(const PhiStmt &)
place holder
bool isFunctionRetPhi() const
static bool classof(const GenericPAGEdgeTy *edge)
static bool classof(const PhiStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const SVFStmt *edge)
PhiStmt(SVFVar *s, const OPVars &opnds, const OpICFGNodeVec &icfgNodes)
constructor
void addOpVar(SVFVar *op, const ICFGNode *inode)
static bool classof(const MultiOpndStmt *edge)
RetPE(const RetPE &)
place holder
const CallICFGNode * getCallSite() const
static bool classof(const GenericPAGEdgeTy *edge)
static bool classof(const RetPE *)
the function exit statement returned from
const CallICFGNode * getCallInst() const
Get method for call instruction at caller.
virtual const std::string toString() const override
const FunExitICFGNode * exit
the callsite statement returning to
const FunExitICFGNode * getFunExitICFGNode() const
static bool classof(const SVFStmt *edge)
const CallICFGNode * call
void operator=(const RetPE &)
place holder
static bool classof(const GenericPAGEdgeTy *edge)
ICFGNode * getICFGNode() const
virtual bool isPTAEdge() const
Whether src and dst nodes are both of pointer type.
void setBB(const SVFBasicBlock *bb)
friend OutStream & operator<<(OutStream &o, const SVFStmt &edge)
Overloading operator << for dumping SVFVar value.
const SVFVar * getValue() const
void setValue(const SVFVar *val)
Get/set methods for llvm instruction.
Map< EdgeID, SVFStmtSetTy > PAGEdgeToSetMapTy
static u64_t callEdgeLabelCounter
Call site Instruction counter.
static Var2LabelMap var2LabelMap
Second operand of MultiOpndStmt to label map.
SVFStmtSetTy PAGEdgeSetTy
static GEdgeFlag makeEdgeFlagWithAddionalOpnd(GEdgeKind k, const SVFVar *var)
const SVFBasicBlock * getBB() const
static GEdgeFlag makeEdgeFlagWithCallInst(GEdgeKind k, const ICFGNode *cs)
SVFStmt(GEdgeFlag k)
Private constructor for reading SVFIR from file without side-effect.
ICFGNode * icfgNode
ICFGNode.
static u64_t storeEdgeLabelCounter
Store Instruction counter.
EdgeID edgeId
Edge ID.
Map< const ICFGNode *, u32_t > Inst2LabelMap
const SVFBasicBlock * basicBlock
LLVM BasicBlock.
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
PAGEdgeToSetMapTy KindToSVFStmtMapTy
static u64_t multiOpndLabelCounter
MultiOpndStmt counter.
~SVFStmt()
Destructor.
static Inst2LabelMap inst2LabelMap
Call site Instruction to label map.
static bool classof(const SVFStmt *)
ClassOf.
virtual const std::string toString() const
Map< const SVFVar *, u32_t > Var2LabelMap
static GEdgeFlag makeEdgeFlagWithStoreInst(GEdgeKind k, const ICFGNode *store)
const SVFVar * value
LLVM value.
void setICFGNode(ICFGNode *node)
static u32_t totalEdgeNum
Total edge number.
EdgeID getEdgeID() const
Return Edge ID.
static bool classof(const MultiOpndStmt *edge)
const SVFVar * getCondition() const
const SVFVar * condition
const SVFVar * getTrueValue() const
static bool classof(const SVFStmt *edge)
virtual const std::string toString() const override
const SVFVar * getFalseValue() const
static bool classof(const SelectStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const GenericPAGEdgeTy *edge)
SelectStmt(const SelectStmt &)
place holder
void operator=(const SelectStmt &)
place holder
StoreStmt(const StoreStmt &)
place holder
static bool classof(const SVFStmt *edge)
virtual const std::string toString() const override
static bool classof(const GenericPAGEdgeTy *edge)
void operator=(const StoreStmt &)
place holder
static bool classof(const StoreStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
void operator=(const TDForkPE &)
place holder
static bool classof(const SVFStmt *edge)
static bool classof(const TDForkPE *)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const GenericPAGEdgeTy *edge)
virtual const std::string toString() const
TDForkPE(const TDForkPE &)
place holder
TDForkPE(SVFVar *s, SVFVar *d, const CallICFGNode *i, const FunEntryICFGNode *entry)
constructor
static bool classof(const SVFStmt *edge)
static bool classof(const GenericPAGEdgeTy *edge)
void operator=(const TDJoinPE &)
place holder
TDJoinPE(const TDJoinPE &)
place holder
virtual const std::string toString() const
static bool classof(const TDJoinPE *)
Methods for support type inquiry through isa, cast, and dyn_cast:
TDJoinPE(SVFVar *s, SVFVar *d, const CallICFGNode *i, const FunExitICFGNode *e)
Constructor.
virtual const std::string toString() const override
static bool classof(const SVFStmt *edge)
UnaryOPStmt(SVFVar *s, SVFVar *d, u32_t oc)
constructor
NodeID getSrcID()
place holder, use getOpVarID(pos) instead
const SVFVar * getOpVar() const
void operator=(const UnaryOPStmt &)
place holder
SVFVar * getSrcNode()
place holder, use getOpVar() instead
NodeID getOpVarID() const
SVFVar * getDstNode()
place holder, use getRes() instead
UnaryOPStmt(const UnaryOPStmt &)
place holder
NodeID getDstID()
place holder, use getResID() instead
static bool classof(const UnaryOPStmt *)
Methods for support type inquiry through isa, cast, and dyn_cast:
const SVFVar * getRes() const
OpCode
OpCode for UnaryOPStmt, enum value is same to llvm::UnaryOperator.
static bool classof(const GenericPAGEdgeTy *edge)
NodeID getResID() const
u32_t getOpcode() const
for isBitcode
Definition BasicTypes.h:68
unsigned long long u64_t
Definition GeneralType.h:49
u32_t NodeID
Definition GeneralType.h:56
s64_t APOffset
Definition GeneralType.h:60
std::ostream OutStream
Definition GeneralType.h:46
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
GenericEdge< SVFVar > GenericPAGEdgeTy
unsigned u32_t
Definition GeneralType.h:47
signed long long s64_t
Definition GeneralType.h:50
u32_t EdgeID
Definition GeneralType.h:57