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 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};
347
351class CopyStmt: public AssignStmt
352{
353
354private:
356 void operator=(const CopyStmt&);
357public:
359 {
360 COPYVAL, // Value copies (default one)
361 ZEXT, // Zero extend integers
362 SEXT, // Sign extend integers
363 BITCAST, // Type cast
364 TRUNC, // Truncate integers
365 FPTRUNC, // Truncate floating point
366 FPTOUI, // floating point -> UInt
367 FPTOSI, // floating point -> SInt
368 UITOFP, // UInt -> floating point
369 SITOFP, // SInt -> floating point
370 INTTOPTR, // Integer -> Pointer
371 PTRTOINT // Pointer -> Integer
372 };
374
375 static inline bool classof(const CopyStmt*)
376 {
377 return true;
378 }
379 static inline bool classof(const SVFStmt* edge)
380 {
381 return edge->getEdgeKind() == SVFStmt::Copy;
382 }
383 static inline bool classof(const GenericPAGEdgeTy* edge)
384 {
385 return edge->getEdgeKind() == SVFStmt::Copy;
386 }
388
390 inline u32_t getCopyKind() const
391 {
392 return copyKind;
393 }
394
395 inline bool isBitCast() const
396 {
397 return copyKind == BITCAST;
398 }
399
400 inline bool isValueCopy() const
401 {
402 return copyKind == COPYVAL;
403 }
404
405 inline bool isInt2Ptr() const
406 {
407 return copyKind == INTTOPTR;
408 }
409
410 inline bool isPtr2Int() const
411 {
412 return copyKind == PTRTOINT;
413 }
414
415 inline bool isZext() const
416 {
417 return copyKind == ZEXT;
418 }
419
420 inline bool isSext() const
421 {
422 return copyKind == SEXT;
423 }
424
427
428 virtual const std::string toString() const override;
429private:
431};
432
437{
438
439private:
441 void operator=(const StoreStmt&);
442
443public:
445
446 static inline bool classof(const StoreStmt*)
447 {
448 return true;
449 }
450 static inline bool classof(const SVFStmt* edge)
451 {
452 return edge->getEdgeKind() == SVFStmt::Store;
453 }
454 static inline bool classof(const GenericPAGEdgeTy* edge)
455 {
456 return edge->getEdgeKind() == SVFStmt::Store;
457 }
459
461 StoreStmt(SVFVar* s, SVFVar* d, const ICFGNode* st);
462
463 virtual const std::string toString() const override;
464};
465
469class LoadStmt: public AssignStmt
470{
471
472private:
474 void operator=(const LoadStmt&);
475
476public:
478
479 static inline bool classof(const LoadStmt*)
480 {
481 return true;
482 }
483 static inline bool classof(const SVFStmt* edge)
484 {
485 return edge->getEdgeKind() == SVFStmt::Load;
486 }
487 static inline bool classof(const GenericPAGEdgeTy* edge)
488 {
489 return edge->getEdgeKind() == SVFStmt::Load;
490 }
492
495
496 virtual const std::string toString() const override;
497};
498
502class GepStmt: public AssignStmt
503{
504
505private:
506 GepStmt(const GepStmt &);
507 void operator=(const GepStmt &);
508
511public:
513
514 static inline bool classof(const GepStmt*)
515 {
516 return true;
517 }
518 static inline bool classof(const SVFStmt* edge)
519 {
520 return edge->getEdgeKind() == SVFStmt::Gep;
521 }
522 static inline bool classof(const GenericPAGEdgeTy* edge)
523 {
524 return edge->getEdgeKind() == SVFStmt::Gep;
525 }
527
528 inline const AccessPath& getAccessPath() const
529 {
530 return ap;
531 }
537 inline bool isConstantOffset() const
538 {
540 }
541
551
554 {
556 }
559 {
560 assert(isVariantFieldGep()==false && "Can't retrieve the AccessPath if using a variable field index (pointer arithmetic) for struct field access ");
562 }
564 inline bool isVariantFieldGep() const
565 {
566 return variantField;
567 }
568
570 GepStmt(SVFVar* s, SVFVar* d, const AccessPath& ap, bool varfld = false)
572 {
573 }
574
575 virtual const std::string toString() const;
576
577};
578
579
583class CallPE: public AssignStmt
584{
585
586private:
587 CallPE(const CallPE&);
588 void operator=(const CallPE&);
589
592
593public:
595
596 static inline bool classof(const CallPE*)
597 {
598 return true;
599 }
600 static inline bool classof(const SVFStmt* edge)
601 {
602 return edge->getEdgeKind() == SVFStmt::Call ||
603 edge->getEdgeKind() == SVFStmt::ThreadFork;
604 }
605 static inline bool classof(const GenericPAGEdgeTy* edge)
606 {
607 return edge->getEdgeKind() == SVFStmt::Call ||
608 edge->getEdgeKind() == SVFStmt::ThreadFork;
609 }
611
613 CallPE(SVFVar* s, SVFVar* d, const CallICFGNode* i,
615
617
618 inline const CallICFGNode* getCallInst() const
619 {
620 return call;
621 }
622 inline const CallICFGNode* getCallSite() const
623 {
624 return call;
625 }
627 {
628 return entry;
629 }
631
632 virtual const std::string toString() const override;
633};
634
638class RetPE: public AssignStmt
639{
640
641private:
642 RetPE(const RetPE&);
643 void operator=(const RetPE&);
644
647
648public:
650
651 static inline bool classof(const RetPE*)
652 {
653 return true;
654 }
655 static inline bool classof(const SVFStmt* edge)
656 {
657 return edge->getEdgeKind() == SVFStmt::Ret ||
658 edge->getEdgeKind() == SVFStmt::ThreadJoin;
659 }
660 static inline bool classof(const GenericPAGEdgeTy* edge)
661 {
662 return edge->getEdgeKind() == SVFStmt::Ret ||
663 edge->getEdgeKind() == SVFStmt::ThreadJoin;
664 }
666
668 RetPE(SVFVar* s, SVFVar* d, const CallICFGNode* i, const FunExitICFGNode* e,
670
672
673 inline const CallICFGNode* getCallInst() const
674 {
675 return call;
676 }
677 inline const CallICFGNode* getCallSite() const
678 {
679 return call;
680 }
682 {
683 return exit;
684 }
686
687 virtual const std::string toString() const override;
688};
689
690/*
691* Program statements with multiple operands including BinaryOPStmt, CmpStmt and PhiStmt
692*/
693class MultiOpndStmt : public SVFStmt
694{
695
696public:
697 typedef std::vector<SVFVar*> OPVars;
698
699private:
707
708protected:
712
713public:
715
716 static inline bool classof(const MultiOpndStmt*)
717 {
718 return true;
719 }
720 static inline bool classof(const SVFStmt* node)
721 {
722 return node->getEdgeKind() == Phi || node->getEdgeKind() == Select ||
723 node->getEdgeKind() == BinaryOp || node->getEdgeKind() == Cmp;
724 }
725 static inline bool classof(const GenericPAGEdgeTy* node)
726 {
727 return node->getEdgeKind() == Phi || node->getEdgeKind() == Select ||
728 node->getEdgeKind() == BinaryOp || node->getEdgeKind() == Cmp;
729 }
731
733
734
735 inline const SVFVar* getOpVar(u32_t pos) const
736 {
737 return opVars.at(pos);
738 }
740 inline const SVFVar* getRes() const
741 {
742 return SVFStmt::getDstNode();
743 }
744
745 NodeID getOpVarID(u32_t pos) const;
746 NodeID getResID() const;
747
748 inline u32_t getOpVarNum() const
749 {
750 return opVars.size();
751 }
752 inline const OPVars& getOpndVars() const
753 {
754 return opVars;
755 }
756 inline OPVars::const_iterator opVarBegin() const
757 {
758 return opVars.begin();
759 }
760 inline OPVars::const_iterator opVerEnd() const
761 {
762 return opVars.end();
763 }
765};
766
772{
773
774public:
775 typedef std::vector<const ICFGNode*> OpICFGNodeVec;
776
777private:
778 PhiStmt(const PhiStmt&);
779 void operator=(const PhiStmt&);
780
782
783public:
785
786 static inline bool classof(const PhiStmt*)
787 {
788 return true;
789 }
790 static inline bool classof(const SVFStmt* edge)
791 {
792 return edge->getEdgeKind() == SVFStmt::Phi;
793 }
794 static inline bool classof(const MultiOpndStmt* edge)
795 {
796 return edge->getEdgeKind() == SVFStmt::Phi;
797 }
798 static inline bool classof(const GenericPAGEdgeTy* edge)
799 {
800 return edge->getEdgeKind() == SVFStmt::Phi;
801 }
803
805 PhiStmt(SVFVar* s, const OPVars& opnds, const OpICFGNodeVec& icfgNodes)
806 : MultiOpndStmt(s, opnds, SVFStmt::Phi), opICFGNodes(icfgNodes)
807 {
808 assert(opnds.size() == icfgNodes.size() &&
809 "Numbers of operands and their ICFGNodes are not consistent?");
810 }
812 {
813 opVars.push_back(op);
814 opICFGNodes.push_back(inode);
815 assert(opVars.size() == opICFGNodes.size() &&
816 "Numbers of operands and their ICFGNodes are not consistent?");
817 }
818
820 inline const ICFGNode* getOpICFGNode(u32_t op_idx) const
821 {
822 return opICFGNodes.at(op_idx);
823 }
824
827 bool isFunctionRetPhi() const;
828
829 virtual const std::string toString() const override;
830};
831
836{
837
838private:
840 void operator=(const SelectStmt&);
841
843
844public:
846
847 static inline bool classof(const SelectStmt*)
848 {
849 return true;
850 }
851 static inline bool classof(const SVFStmt* edge)
852 {
853 return edge->getEdgeKind() == SVFStmt::Select;
854 }
855 static inline bool classof(const MultiOpndStmt* edge)
856 {
857 return edge->getEdgeKind() == SVFStmt::Select;
858 }
859 static inline bool classof(const GenericPAGEdgeTy* edge)
860 {
861 return edge->getEdgeKind() == SVFStmt::Select;
862 }
864
866 SelectStmt(SVFVar* s, const OPVars& opnds, const SVFVar* cond);
867 virtual const std::string toString() const override;
868
869 inline const SVFVar* getCondition() const
870 {
871 return condition;
872 }
873 inline const SVFVar* getTrueValue() const
874 {
875 return getOpVar(0);
876 }
877 inline const SVFVar* getFalseValue() const
878 {
879 return getOpVar(1);
880 }
881};
882
887{
888
889private:
890 CmpStmt(const CmpStmt&);
891 void operator=(const CmpStmt&);
892
894
895public:
933
935
936 static inline bool classof(const CmpStmt*)
937 {
938 return true;
939 }
940 static inline bool classof(const SVFStmt* edge)
941 {
942 return edge->getEdgeKind() == SVFStmt::Cmp;
943 }
944 static inline bool classof(const MultiOpndStmt* edge)
945 {
946 return edge->getEdgeKind() == SVFStmt::Cmp;
947 }
948 static inline bool classof(const GenericPAGEdgeTy* edge)
949 {
950 return edge->getEdgeKind() == SVFStmt::Cmp;
951 }
953
955 CmpStmt(SVFVar* s, const OPVars& opnds, u32_t pre);
956
958 {
959 return predicate;
960 }
961
962 virtual const std::string toString() const override;
963};
964
969{
970
971private:
973 void operator=(const BinaryOPStmt&);
975
976public:
978 enum OpCode : unsigned
979 {
980 Add = 13, // Sum of integers
981 FAdd = 14, // Sum of floats
982 Sub = 15, // Subtraction of integers
983 FSub = 16, // Subtraction of floats
984 Mul = 17, // Product of integers.
985 FMul = 18, // Product of floats.
986 UDiv = 19, // Unsigned division.
987 SDiv = 20, // Signed division.
988 FDiv = 21, // Float division.
989 URem = 22, // Unsigned remainder
990 SRem = 23, // Signed remainder
991 FRem = 24, // Float remainder
992 Shl = 25, // Shift left (logical)
993 LShr = 26, // Shift right (logical)
994 AShr = 27, // Shift right (arithmetic)
995 And = 28, // Logical and
996 Or = 29, // Logical or
997 Xor = 30 // Logical xor
998 };
999
1001
1002 static inline bool classof(const BinaryOPStmt*)
1003 {
1004 return true;
1005 }
1006 static inline bool classof(const SVFStmt* edge)
1007 {
1008 return edge->getEdgeKind() == SVFStmt::BinaryOp;
1009 }
1010 static inline bool classof(const MultiOpndStmt* edge)
1011 {
1012 return edge->getEdgeKind() == SVFStmt::BinaryOp;
1013 }
1014 static inline bool classof(const GenericPAGEdgeTy* edge)
1015 {
1016 return edge->getEdgeKind() == SVFStmt::BinaryOp;
1017 }
1019
1022
1024 {
1025 return opcode;
1026 }
1027
1028 virtual const std::string toString() const override;
1029};
1030
1035{
1036
1037private:
1039 void operator=(const UnaryOPStmt&);
1044
1046
1047public:
1049 enum OpCode : unsigned
1050 {
1051 FNeg = 12
1053
1055
1056 static inline bool classof(const UnaryOPStmt*)
1057 {
1058 return true;
1059 }
1060 static inline bool classof(const SVFStmt* edge)
1061 {
1062 return edge->getEdgeKind() == SVFStmt::UnaryOp;
1063 }
1064 static inline bool classof(const GenericPAGEdgeTy* edge)
1065 {
1066 return edge->getEdgeKind() == SVFStmt::UnaryOp;
1067 }
1069
1073 {
1074 }
1075
1077 {
1078 return opcode;
1079 }
1080 inline const SVFVar* getOpVar() const
1081 {
1082 return SVFStmt::getSrcNode();
1083 }
1084 inline const SVFVar* getRes() const
1085 {
1086 return SVFStmt::getDstNode();
1087 }
1088 NodeID getOpVarID() const;
1089 NodeID getResID() const;
1090
1091 virtual const std::string toString() const override;
1092};
1093
1097class BranchStmt: public SVFStmt
1098{
1099
1100public:
1101 typedef std::vector<std::pair<const ICFGNode*, s32_t>> SuccAndCondPairVec;
1102
1103private:
1105 void operator=(const BranchStmt&);
1110
1112 const SVFVar* cond;
1114
1115public:
1117
1118 static inline bool classof(const BranchStmt*)
1119 {
1120 return true;
1121 }
1122 static inline bool classof(const SVFStmt* edge)
1123 {
1124 return edge->getEdgeKind() == SVFStmt::Branch;
1125 }
1126 static inline bool classof(const GenericPAGEdgeTy* edge)
1127 {
1128 return edge->getEdgeKind() == SVFStmt::Branch;
1129 }
1131
1134 : SVFStmt(c, inst, SVFStmt::Branch), successors(succs), cond(c),
1135 brInst(inst)
1136 {
1137 }
1138
1140 bool isUnconditional() const;
1142 bool isConditional() const;
1144 const SVFVar* getCondition() const;
1145 const SVFVar* getBranchInst() const
1146 {
1147 return brInst;
1148 }
1149
1153
1157
1161 {
1162 return successors.size();
1163 }
1165 {
1166 return successors;
1167 }
1169 {
1170 return successors.at(i).first;
1171 }
1173 {
1174 return successors.at(i).second;
1175 }
1177 virtual const std::string toString() const override;
1178};
1179
1183class TDForkPE: public CallPE
1184{
1185
1186private:
1188 void operator=(const TDForkPE&);
1189
1190public:
1192
1193 static inline bool classof(const TDForkPE*)
1194 {
1195 return true;
1196 }
1197 static inline bool classof(const SVFStmt* edge)
1198 {
1199 return edge->getEdgeKind() == SVFStmt::ThreadFork;
1200 }
1201 static inline bool classof(const GenericPAGEdgeTy* edge)
1202 {
1203 return edge->getEdgeKind() == SVFStmt::ThreadFork;
1204 }
1206
1209 const FunEntryICFGNode* entry)
1211 {
1212 }
1213
1214 virtual const std::string toString() const;
1215};
1216
1220class TDJoinPE: public RetPE
1221{
1222
1223private:
1225 void operator=(const TDJoinPE&);
1226
1227public:
1229
1230 static inline bool classof(const TDJoinPE*)
1231 {
1232 return true;
1233 }
1234 static inline bool classof(const SVFStmt* edge)
1235 {
1236 return edge->getEdgeKind() == SVFStmt::ThreadJoin;
1237 }
1238 static inline bool classof(const GenericPAGEdgeTy* edge)
1239 {
1240 return edge->getEdgeKind() == SVFStmt::ThreadJoin;
1241 }
1243
1246 const FunExitICFGNode* e)
1247 : RetPE(s, d, i, e, SVFStmt::ThreadJoin)
1248 {
1249 }
1250
1251 virtual const std::string toString() const;
1252};
1253
1254} // End namespace SVF
1255
1256#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 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
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