Static Value-Flow Analysis
Loading...
Searching...
No Matches
VFGEdge.h
Go to the documentation of this file.
1//===- VFGEdge.h ----------------------------------------------------------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-2018> <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 * VFGEdge.h
25 *
26 * Created on: 18 Sep. 2018
27 * Author: Yulei Sui
28 */
29
30#ifndef INCLUDE_UTIL_VFGEDGE_H_
31#define INCLUDE_UTIL_VFGEDGE_H_
32
33#include "Graphs/GenericGraph.h"
34
35namespace SVF
36{
37
38class VFGNode;
39
45{
46
47public:
61
63
64public:
71 {
72 }
73
75
76 inline bool isDirectVFGEdge() const
77 {
79 }
80 inline bool isIndirectVFGEdge() const
81 {
83 }
84 inline bool isCallVFGEdge() const
85 {
86 return getEdgeKind() == CallDirVF || getEdgeKind() == CallIndVF;
87 }
88 inline bool isRetVFGEdge() const
89 {
90 return getEdgeKind() == RetDirVF || getEdgeKind() == RetIndVF;
91 }
92 inline bool isCallDirectVFGEdge() const
93 {
94 return getEdgeKind() == CallDirVF;
95 }
96 inline bool isRetDirectVFGEdge() const
97 {
98 return getEdgeKind() == RetDirVF;
99 }
100 inline bool isCallIndirectVFGEdge() const
101 {
102 return getEdgeKind() == CallIndVF;
103 }
104 inline bool isRetIndirectVFGEdge() const
105 {
106 return getEdgeKind() == RetIndVF;
107 }
108 inline bool isIntraVFGEdge() const
109 {
111 }
112 inline bool isThreadMHPIndirectVFGEdge() const
113 {
115 }
121 {
122 return (cs << EdgeKindMaskBits) | k;
123 }
124
126
128 {
129 o << edge.toString();
130 return o;
131 }
133
134 virtual const std::string toString() const;
135};
136
137
142{
143
144public:
150
151 static inline bool classof(const DirectSVFGEdge *)
152 {
153 return true;
154 }
155 static inline bool classof(const VFGEdge *edge)
156 {
157 return edge->getEdgeKind() == IntraDirectVF ||
158 edge->getEdgeKind() == CallDirVF ||
159 edge->getEdgeKind() == RetDirVF;
160 }
161 static inline bool classof(const GenericVFGEdgeTy *edge)
162 {
163 return edge->getEdgeKind() == IntraDirectVF ||
164 edge->getEdgeKind() == CallDirVF ||
165 edge->getEdgeKind() == RetDirVF;
166 }
168
169 virtual const std::string toString() const;
170};
171
172
177{
178
179public:
185
186 static inline bool classof(const IntraDirSVFGEdge*)
187 {
188 return true;
189 }
190 static inline bool classof(const DirectSVFGEdge *edge)
191 {
192 return edge->getEdgeKind() == IntraDirectVF;
193 }
194 static inline bool classof(const VFGEdge *edge)
195 {
196 return edge->getEdgeKind() == IntraDirectVF;
197 }
198 static inline bool classof(const GenericVFGEdgeTy *edge)
199 {
200 return edge->getEdgeKind() == IntraDirectVF;
201 }
203
204 virtual const std::string toString() const;
205};
206
207
212{
213
214private:
216public:
224 {
225 return csId;
226 }
227
229
230 static inline bool classof(const CallDirSVFGEdge *)
231 {
232 return true;
233 }
234 static inline bool classof(const DirectSVFGEdge *edge)
235 {
236 return edge->getEdgeKind() == CallDirVF;
237 }
238 static inline bool classof(const VFGEdge *edge)
239 {
240 return edge->getEdgeKind() == CallDirVF ;
241 }
242 static inline bool classof(const GenericVFGEdgeTy *edge)
243 {
244 return edge->getEdgeKind() == CallDirVF ;
245 }
247
248 virtual const std::string toString() const;
249};
250
255{
256
257private:
259public:
267 {
268 return csId;
269 }
271
272 static inline bool classof(const RetDirSVFGEdge *)
273 {
274 return true;
275 }
276 static inline bool classof(const DirectSVFGEdge *edge)
277 {
278 return edge->getEdgeKind() == RetDirVF;
279 }
280 static inline bool classof(const VFGEdge *edge)
281 {
282 return edge->getEdgeKind() == RetDirVF;
283 }
284 static inline bool classof(const GenericVFGEdgeTy *edge)
285 {
286 return edge->getEdgeKind() == RetDirVF;
287 }
289
290 virtual const std::string toString() const;
291};
292
293} // End namespace SVF
294
295#endif /* INCLUDE_UTIL_VFGEDGE_H_ */
CallSiteID csId
Definition VFGEdge.h:215
CallDirSVFGEdge(VFGNode *s, VFGNode *d, CallSiteID id)
Constructor.
Definition VFGEdge.h:218
static bool classof(const CallDirSVFGEdge *)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition VFGEdge.h:230
static bool classof(const DirectSVFGEdge *edge)
Definition VFGEdge.h:234
static bool classof(const GenericVFGEdgeTy *edge)
Definition VFGEdge.h:242
CallSiteID getCallSiteId() const
Return callsite ID.
Definition VFGEdge.h:223
virtual const std::string toString() const
Definition VFG.cpp:403
static bool classof(const VFGEdge *edge)
Definition VFGEdge.h:238
static bool classof(const DirectSVFGEdge *)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition VFGEdge.h:151
static bool classof(const GenericVFGEdgeTy *edge)
Definition VFGEdge.h:161
DirectSVFGEdge(VFGNode *s, VFGNode *d, GEdgeFlag k)
Constructor.
Definition VFGEdge.h:146
virtual const std::string toString() const
Definition VFG.cpp:387
static bool classof(const VFGEdge *edge)
Definition VFGEdge.h:155
GEdgeKind getEdgeKind() const
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
Edge kind.
static bool classof(const DirectSVFGEdge *edge)
Definition VFGEdge.h:190
virtual const std::string toString() const
Definition VFG.cpp:395
IntraDirSVFGEdge(VFGNode *s, VFGNode *d)
Constructor.
Definition VFGEdge.h:181
static bool classof(const IntraDirSVFGEdge *)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition VFGEdge.h:186
static bool classof(const VFGEdge *edge)
Definition VFGEdge.h:194
static bool classof(const GenericVFGEdgeTy *edge)
Definition VFGEdge.h:198
static bool classof(const GenericVFGEdgeTy *edge)
Definition VFGEdge.h:284
static bool classof(const VFGEdge *edge)
Definition VFGEdge.h:280
CallSiteID csId
Definition VFGEdge.h:258
RetDirSVFGEdge(VFGNode *s, VFGNode *d, CallSiteID id)
Constructor.
Definition VFGEdge.h:261
virtual const std::string toString() const
Definition VFG.cpp:412
CallSiteID getCallSiteId() const
Return callsite ID.
Definition VFGEdge.h:266
static bool classof(const DirectSVFGEdge *edge)
Definition VFGEdge.h:276
static bool classof(const RetDirSVFGEdge *)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition VFGEdge.h:272
@ IntraDirectVF
Definition VFGEdge.h:53
@ IntraIndirectVF
Definition VFGEdge.h:54
@ TheadMHPIndirectVF
Definition VFGEdge.h:59
static GEdgeFlag makeEdgeFlagWithInvokeID(GEdgeKind k, CallSiteID cs)
Compute the unique edgeFlag value from edge kind and CallSiteID.
Definition VFGEdge.h:120
~VFGEdge()
Destructor.
Definition VFGEdge.h:70
bool isRetVFGEdge() const
Definition VFGEdge.h:88
bool isCallVFGEdge() const
Definition VFGEdge.h:84
bool isRetDirectVFGEdge() const
Definition VFGEdge.h:96
GenericNode< VFGNode, VFGEdge >::GEdgeSetTy VFGEdgeSetTy
Definition VFGEdge.h:117
VFGEdgeSetTy SVFGEdgeSetTy
Definition VFGEdge.h:118
bool isIntraVFGEdge() const
Definition VFGEdge.h:108
friend OutStream & operator<<(OutStream &o, const VFGEdge &edge)
Overloading operator << for dumping ICFG node ID.
Definition VFGEdge.h:127
bool isDirectVFGEdge() const
Get methods of the components.
Definition VFGEdge.h:76
virtual const std::string toString() const
Definition VFG.cpp:379
bool isCallDirectVFGEdge() const
Definition VFGEdge.h:92
VFGEdge(VFGNode *s, VFGNode *d, GEdgeFlag k)
Constructor.
Definition VFGEdge.h:66
bool isIndirectVFGEdge() const
Definition VFGEdge.h:80
bool isThreadMHPIndirectVFGEdge() const
Definition VFGEdge.h:112
bool isRetIndirectVFGEdge() const
Definition VFGEdge.h:104
bool isCallIndirectVFGEdge() const
Definition VFGEdge.h:100
VFGEdgeK SVFGEdgeK
Definition VFGEdge.h:62
for isBitcode
Definition BasicTypes.h:68
unsigned CallSiteID
Definition GeneralType.h:58
GenericEdge< VFGNode > GenericVFGEdgeTy
Definition VFGEdge.h:43
std::ostream OutStream
Definition GeneralType.h:45
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74