Static Value-Flow Analysis
Loading...
Searching...
No Matches
ConsGNode.h
Go to the documentation of this file.
1//===- ConsGNode.h -- Constraint graph node-----------------------------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-2017> <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 * ConsGNode.h
25 *
26 * Created on: Mar 19, 2014
27 * Author: Yulei Sui
28 */
29
30#ifndef CONSGNODE_H_
31#define CONSGNODE_H_
32
33namespace SVF
34{
35
41{
42
43public:
44 typedef ConstraintEdge::ConstraintEdgeSetTy::iterator iterator;
45 typedef ConstraintEdge::ConstraintEdgeSetTy::const_iterator const_iterator;
47
48private:
51
54
59
62
65
68
69public:
73
78
80
81 inline bool isPWCNode() const
82 {
83 return _isPWCNode;
84 }
85 inline void setPWCNode()
86 {
87 _isPWCNode = true;
88 }
90
93 {
95 }
97 {
98 return (kind == ConstraintEdge::Load || kind == ConstraintEdge::Store);
99 }
100
102
104 {
105 return directInEdges;
106 }
108 {
109 return directOutEdges;
110 }
112 {
113 return copyInEdges;
114 }
116 {
117 return copyOutEdges;
118 }
120 {
121 return gepInEdges;
122 }
124 {
125 return gepOutEdges;
126 }
128 {
129 return loadInEdges;
130 }
132 {
133 return loadOutEdges;
134 }
136 {
137 return storeInEdges;
138 }
140 {
141 return storeOutEdges;
142 }
144 {
145 return addressInEdges;
146 }
148 {
149 return addressOutEdges;
150 }
152
154
163
172
174 {
175 return addressOutEdges.begin();
176 }
178 {
179 return addressOutEdges.end();
180 }
182 {
183 return addressInEdges.begin();
184 }
186 {
187 return addressInEdges.end();
188 }
189
191 {
192 return loadOutEdges.begin();
193 }
195 {
196 return loadOutEdges.end();
197 }
199 {
200 return loadInEdges.begin();
201 }
203 {
204 return loadInEdges.end();
205 }
206
208 {
209 return storeOutEdges.begin();
210 }
212 {
213 return storeOutEdges.end();
214 }
216 {
217 return storeInEdges.begin();
218 }
220 {
221 return storeInEdges.end();
222 }
224
226
253 {
254 loadInEdges.insert(inEdge);
256 }
263 {
264 assert(inEdge->getDstID() == this->getId());
265 bool added1 = directInEdges.insert(inEdge).second;
267 bool both_added = added1 & added2;
268 assert(both_added && "edge not added, duplicated adding!!");
269 return both_added;
270 }
277 {
278 bool added1 = loadOutEdges.insert(outEdge).second;
280 bool both_added = added1 & added2;
281 assert(both_added && "edge not added, duplicated adding!!");
282 return both_added;
283 }
285 {
286 bool added1 = storeOutEdges.insert(outEdge).second;
288 bool both_added = added1 & added2;
289 assert(both_added && "edge not added, duplicated adding!!");
290 return both_added;
291 }
293 {
294 assert(outEdge->getSrcID() == this->getId());
295 bool added1 = directOutEdges.insert(outEdge).second;
297 bool both_added = added1 & added2;
298 assert(both_added && "edge not added, duplicated adding!!");
299 return both_added;
300 }
302
304 //{@
306 {
309 bool removed = (num1 > 0) & (num2 > 0);
310 assert(removed && "edge not in the set, can not remove!!!");
311 return removed;
312 }
313
315 {
318 bool removed = (num1 > 0) & (num2 > 0);
319 assert(removed && "edge not in the set, can not remove!!!");
320 return removed;
321 }
322
324 {
325 if (SVFUtil::isa<GepCGEdge>(outEdge))
326 gepOutEdges.erase(outEdge);
327 else
328 copyOutEdges.erase(outEdge);
331 bool removed = (num1 > 0) & (num2 > 0);
332 assert(removed && "edge not in the set, can not remove!!!");
333 return removed;
334 }
335
337 {
338 if (SVFUtil::isa<GepCGEdge>(inEdge))
339 gepInEdges.erase(inEdge);
340 else
341 copyInEdges.erase(inEdge);
344 bool removed = (num1 > 0) & (num2 > 0);
345 assert(removed && "edge not in the set, can not remove!!!");
346 return removed;
347 }
348
350 {
353 bool removed = (num1 > 0) & (num2 > 0);
354 assert(removed && "edge not in the set, can not remove!!!");
355 return removed;
356 }
357
359 {
360 u32_t num1 = loadInEdges.erase(inEdge);
362 bool removed = (num1 > 0) & (num2 > 0);
363 assert(removed && "edge not in the set, can not remove!!!");
364 return removed;
365 }
366
368 {
371 bool removed = (num1 > 0) & (num2 > 0);
372 assert(removed && "edge not in the set, can not remove!!!");
373 return removed;
374 }
375
377 {
378 u32_t num1 = storeInEdges.erase(inEdge);
380 bool removed = (num1 > 0) & (num2 > 0);
381 assert(removed && "edge not in the set, can not remove!!!");
382 return removed;
383 }
385
386 virtual const std::string toString() const;
387
389
391 {
392 o << node.toString();
393 return o;
394 }
396
398
399 static inline bool classof(const ConstraintNode *)
400 {
401 return true;
402 }
403
404 static inline bool classof(const GenericICFGNodeTy* node)
405 {
406 return node->getNodeKind() == ConstraintNodeKd;
407 }
408
409 static inline bool classof(const SVFBaseNode* node)
410 {
411 return node->getNodeKind() == ConstraintNodeKd;
412 }
414};
415
416} // End namespace SVF
417
418#endif /* CONSGNODE_H_ */
#define false
Definition cJSON.cpp:70
GenericNode< ConstraintNode, ConstraintEdge >::GEdgeSetTy ConstraintEdgeSetTy
Constraint edge type.
Definition ConsGEdge.h:85
const ConstraintEdge::ConstraintEdgeSetTy & getAddrInEdges() const
Definition ConsGNode.h:143
const_iterator incomingLoadsEnd() const
Definition ConsGNode.h:202
bool isPWCNode() const
Whether a node involves in PWC, if so, all its points-to elements should become field-insensitive.
Definition ConsGNode.h:81
ConstraintEdge::ConstraintEdgeSetTy copyOutEdges
Definition ConsGNode.h:61
const_iterator outgoingLoadsEnd() const
Definition ConsGNode.h:194
bool isdirectEdge(ConstraintEdge::ConstraintEdgeK kind)
Direct and Indirect SVFIR edges.
Definition ConsGNode.h:92
bool addOutgoingStoreEdge(StoreCGEdge *outEdge)
Definition ConsGNode.h:284
const_iterator incomingAddrsBegin() const
Definition ConsGNode.h:181
ConstraintEdge::ConstraintEdgeSetTy::iterator iterator
Definition ConsGNode.h:44
iterator directInEdgeEnd()
Definition ConsG.cpp:690
void addIncomingStoreEdge(StoreCGEdge *inEdge)
Definition ConsGNode.h:257
ConstraintEdge::ConstraintEdgeSetTy addressInEdges
all incoming address edge of this node
Definition ConsGNode.h:66
void addOutgoingCopyEdge(CopyCGEdge *outEdge)
Definition ConsGNode.h:237
bool removeOutgoingStoreEdge(StoreCGEdge *outEdge)
Definition ConsGNode.h:367
bool removeIncomingStoreEdge(StoreCGEdge *inEdge)
Definition ConsGNode.h:376
bool addOutgoingDirectEdge(ConstraintEdge *outEdge)
Definition ConsGNode.h:292
ConstraintEdge::ConstraintEdgeSetTy & outgoingAddrEdges()
Definition ConsGNode.h:168
ConstraintEdge::ConstraintEdgeSetTy & incomingAddrEdges()
Definition ConsGNode.h:164
const ConstraintEdge::ConstraintEdgeSetTy & getStoreInEdges() const
Definition ConsGNode.h:135
bool addIncomingDirectEdge(ConstraintEdge *inEdge)
Definition ConsGNode.h:262
const ConstraintEdge::ConstraintEdgeSetTy & getGepOutEdges() const
Definition ConsGNode.h:123
static bool classof(const ConstraintNode *)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition ConsGNode.h:399
ConstraintEdge::ConstraintEdgeSetTy gepInEdges
Definition ConsGNode.h:63
ConstraintEdge::ConstraintEdgeSetTy copyInEdges
Definition ConsGNode.h:60
const ConstraintEdge::ConstraintEdgeSetTy & getDirectInEdges() const
Return constraint edges.
Definition ConsGNode.h:103
ConstraintEdge::ConstraintEdgeSetTy directInEdges
Definition ConsGNode.h:57
ConstraintEdge::ConstraintEdgeSetTy gepOutEdges
Definition ConsGNode.h:64
const_iterator incomingStoresBegin() const
Definition ConsGNode.h:215
bool removeIncomingAddrEdge(AddrCGEdge *inEdge)
Definition ConsGNode.h:314
friend OutStream & operator<<(OutStream &o, const ConstraintNode &node)
Overloading operator << for dumping node.
Definition ConsGNode.h:390
virtual const std::string toString() const
Definition ConsG.cpp:731
const_iterator outgoingStoresEnd() const
Definition ConsGNode.h:211
const ConstraintEdge::ConstraintEdgeSetTy & getStoreOutEdges() const
Definition ConsGNode.h:139
bool removeOutgoingDirectEdge(ConstraintEdge *outEdge)
Definition ConsGNode.h:323
bool removeIncomingDirectEdge(ConstraintEdge *inEdge)
Definition ConsGNode.h:336
const ConstraintEdge::ConstraintEdgeSetTy & getLoadInEdges() const
Definition ConsGNode.h:127
bool removeOutgoingLoadEdge(LoadCGEdge *outEdge)
Definition ConsGNode.h:349
const_iterator incomingLoadsBegin() const
Definition ConsGNode.h:198
static bool classof(const GenericICFGNodeTy *node)
Definition ConsGNode.h:404
const_iterator outgoingAddrsBegin() const
Definition ConsGNode.h:173
ConstraintEdge::ConstraintEdgeSetTy loadOutEdges
all outgoing load edge of this node
Definition ConsGNode.h:50
NodeBS strides
For stride-based field representation.
Definition ConsGNode.h:71
bool isIndirectEdge(ConstraintEdge::ConstraintEdgeK kind)
Definition ConsGNode.h:96
ConstraintEdge::ConstraintEdgeSetTy storeOutEdges
all outgoing store edge of this node
Definition ConsGNode.h:53
const_iterator incomingStoresEnd() const
Definition ConsGNode.h:219
const ConstraintEdge::ConstraintEdgeSetTy & getGepInEdges() const
Definition ConsGNode.h:119
iterator directInEdgeBegin()
Definition ConsG.cpp:682
const_iterator outgoingStoresBegin() const
Definition ConsGNode.h:207
void addIncomingLoadEdge(LoadCGEdge *inEdge)
Definition ConsGNode.h:252
bool removeIncomingLoadEdge(LoadCGEdge *inEdge)
Definition ConsGNode.h:358
ConstraintEdge::ConstraintEdgeSetTy storeInEdges
all incoming store edge of this node
Definition ConsGNode.h:52
iterator directOutEdgeEnd()
Definition ConsG.cpp:674
bool addOutgoingLoadEdge(LoadCGEdge *outEdge)
Definition ConsGNode.h:276
void addIncomingGepEdge(GepCGEdge *inEdge)
Definition ConsGNode.h:232
ConstraintEdge::ConstraintEdgeSetTy::const_iterator const_iterator
Definition ConsGNode.h:45
bool removeOutgoingAddrEdge(AddrCGEdge *outEdge)
Remove constraint graph edges.
Definition ConsGNode.h:305
void addOutgoingGepEdge(GepCGEdge *outEdge)
Definition ConsGNode.h:242
const ConstraintEdge::ConstraintEdgeSetTy & getLoadOutEdges() const
Definition ConsGNode.h:131
static bool classof(const SVFBaseNode *node)
Definition ConsGNode.h:409
const ConstraintEdge::ConstraintEdgeSetTy & getCopyOutEdges() const
Definition ConsGNode.h:115
const_iterator outgoingAddrsEnd() const
Definition ConsGNode.h:177
void addIncomingCopyEdge(CopyCGEdge *inEdge)
Add constraint graph edges.
Definition ConsGNode.h:227
const ConstraintEdge::ConstraintEdgeSetTy & getDirectOutEdges() const
Definition ConsGNode.h:107
const ConstraintEdge::ConstraintEdgeSetTy & getCopyInEdges() const
Definition ConsGNode.h:111
iterator directOutEdgeBegin()
Iterators.
Definition ConsG.cpp:666
const_iterator incomingAddrsEnd() const
Definition ConsGNode.h:185
void addIncomingAddrEdge(AddrCGEdge *inEdge)
Definition ConsGNode.h:247
ConstraintEdge::ConstraintEdgeSetTy addressOutEdges
all outgoing address edge of this node
Definition ConsGNode.h:67
void addOutgoingAddrEdge(AddrCGEdge *outEdge)
Definition ConsGNode.h:271
const_iterator outgoingLoadsBegin() const
Definition ConsGNode.h:190
ConstraintEdge::ConstraintEdgeSetTy loadInEdges
all incoming load edge of this node
Definition ConsGNode.h:49
ConstraintNode(NodeID i)
Definition ConsGNode.h:74
const ConstraintEdge::ConstraintEdgeSetTy & getAddrOutEdges() const
Definition ConsGNode.h:147
ConstraintEdge::ConstraintEdgeSetTy directOutEdges
Definition ConsGNode.h:58
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
GNodeK getNodeKind() const
Get node kind.
for isBitcode
Definition BasicTypes.h:68
u32_t NodeID
Definition GeneralType.h:55
GenericNode< ConstraintNode, ConstraintEdge > GenericConsNodeTy
Definition ConsGNode.h:39
std::ostream OutStream
Definition GeneralType.h:45
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
unsigned u32_t
Definition GeneralType.h:46