Static Value-Flow Analysis
Loading...
Searching...
No Matches
VFG.h
Go to the documentation of this file.
1//===- VFG.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 * VFG.h
25 *
26 * Created on: 18 Sep. 2018
27 * Author: Yulei Sui
28 */
29
30#ifndef INCLUDE_UTIL_VFG_H_
31#define INCLUDE_UTIL_VFG_H_
32
33
34#include "SVFIR/SVFIR.h"
35#include "Graphs/CallGraph.h"
36#include "Graphs/VFGNode.h"
37#include "Graphs/VFGEdge.h"
38
39namespace SVF
40{
41
42class PointerAnalysis;
43class VFGStat;
44class CallICFGNode;
45
50class VFG : public GenericVFGTy
51{
52
53public:
59
74
79 typedef VFGEdge::VFGEdgeSetTy::iterator VFGNodeIter;
80 typedef VFGNodeIDToNodeMapTy::iterator iterator;
81 typedef VFGNodeIDToNodeMapTy::const_iterator const_iterator;
85
86
87protected:
101
106
108 void destroy();
109
110public:
113
115 virtual ~VFG()
116 {
117 destroy();
118 }
119
121 inline VFGK getKind() const
122 {
123 return kind;
124 }
125
127 inline bool isPtrOnlySVFG() const
128 {
129 return (kind == PTRONLYSVFG) || (kind == PTRONLYSVFG_OPT);
130 }
131
133 inline SVFIR* getPAG() const
134 {
135 return pag;
136 }
137
139 inline CallGraph* getCallGraph() const
140 {
141 return callgraph;
142 }
143
145 inline VFGNode* getVFGNode(NodeID id) const
146 {
147 return getGNode(id);
148 }
149
151 inline bool hasVFGNode(NodeID id) const
152 {
153 return hasGNode(id);
154 }
157 {
158 return globalVFGNodes;
159 }
160
163
165 void dump(const std::string& file, bool simple = false);
166
168 void view();
169
172
174 virtual void connectCallerAndCallee(const CallICFGNode* cs, const FunObjVar* callee, VFGEdgeSetTy& edges);
175
177
178 inline CallSiteID getCallSiteID(const CallICFGNode* cs, const FunObjVar* func) const
179 {
180 return callgraph->getCallSiteID(cs, func);
181 }
182 inline const CallICFGNode* getCallSite(CallSiteID id) const
183 {
184 return callgraph->getCallSite(id);
185 }
187
189 inline const VFGNode* getDefVFGNode(const PAGNode* pagNode) const
190 {
191 return getVFGNode(getDef(pagNode));
192 }
193
194 // Given an VFG node, return true if it has a left hand side top level pointer (PAGnode)
195 inline bool hasLHSTopLevPtr(const VFGNode* node) const
196 {
197 return node && SVFUtil::isa<AddrVFGNode,
209 NullPtrVFGNode>(node);
210 }
211
212 // Given an VFG node, return its left hand side top level pointer (PAGnode)
213 const PAGNode* getLHSTopLevPtr(const VFGNode* node) const;
214
216
217 inline bool hasStmtVFGNode(const PAGEdge* pagEdge) const
218 {
219 return PAGEdgeToStmtVFGNodeMap.find(pagEdge) != PAGEdgeToStmtVFGNodeMap.end();
220 }
221 inline bool hasIntraPHIVFGNode(const PAGNode* pagNode) const
222 {
224 }
225 inline bool hasBinaryOPVFGNode(const PAGNode* pagNode) const
226 {
228 }
229 inline bool hasUnaryOPVFGNode(const PAGNode* pagNode) const
230 {
232 }
233 inline bool hasBranchVFGNode(const PAGNode* pagNode) const
234 {
236 }
237 inline bool hasCmpVFGNode(const PAGNode* pagNode) const
238 {
240 }
241 inline bool hasActualParmVFGNode(const PAGNode* aparm,const CallICFGNode* cs) const
242 {
243 return PAGNodeToActualParmMap.find(std::make_pair(aparm->getId(),cs)) != PAGNodeToActualParmMap.end();
244 }
245 inline bool hasActualRetVFGNode(const PAGNode* aret) const
246 {
248 }
249 inline bool hasFormalParmVFGNode(const PAGNode* fparm) const
250 {
252 }
253 inline bool hasFormalRetVFGNode(const PAGNode* fret) const
254 {
256 }
258
260
261 inline StmtVFGNode* getStmtVFGNode(const PAGEdge* pagEdge) const
262 {
263 PAGEdgeToStmtVFGNodeMapTy::const_iterator it = PAGEdgeToStmtVFGNodeMap.find(pagEdge);
264 assert(it != PAGEdgeToStmtVFGNodeMap.end() && "StmtVFGNode can not be found??");
265 return it->second;
266 }
268 {
269 PAGNodeToPHIVFGNodeMapTy::const_iterator it = PAGNodeToIntraPHIVFGNodeMap.find(pagNode);
270 assert(it != PAGNodeToIntraPHIVFGNodeMap.end() && "PHIVFGNode can not be found??");
271 return it->second;
272 }
274 {
275 PAGNodeToBinaryOPVFGNodeMapTy::const_iterator it = PAGNodeToBinaryOPVFGNodeMap.find(pagNode);
276 assert(it != PAGNodeToBinaryOPVFGNodeMap.end() && "BinaryOPVFGNode can not be found??");
277 return it->second;
278 }
280 {
281 PAGNodeToUnaryOPVFGNodeMapTy::const_iterator it = PAGNodeToUnaryOPVFGNodeMap.find(pagNode);
282 assert(it != PAGNodeToUnaryOPVFGNodeMap.end() && "UnaryOPVFGNode can not be found??");
283 return it->second;
284 }
286 {
287 PAGNodeToBranchVFGNodeMapTy::const_iterator it = PAGNodeToBranchVFGNodeMap.find(pagNode);
288 assert(it != PAGNodeToBranchVFGNodeMap.end() && "BranchVFGNode can not be found??");
289 return it->second;
290 }
292 {
293 PAGNodeToCmpVFGNodeMapTy::const_iterator it = PAGNodeToCmpVFGNodeMap.find(pagNode);
294 assert(it != PAGNodeToCmpVFGNodeMap.end() && "CmpVFGNode can not be found??");
295 return it->second;
296 }
298 {
299 PAGNodeToActualParmMapTy::const_iterator it = PAGNodeToActualParmMap.find(std::make_pair(aparm->getId(),cs));
300 assert(it!=PAGNodeToActualParmMap.end() && "actual parameter VFG node can not be found??");
301 return it->second;
302 }
304 {
305 PAGNodeToActualRetMapTy::const_iterator it = PAGNodeToActualRetMap.find(aret);
306 assert(it!=PAGNodeToActualRetMap.end() && "actual return VFG node can not be found??");
307 return it->second;
308 }
310 {
311 PAGNodeToFormalParmMapTy::const_iterator it = PAGNodeToFormalParmMap.find(fparm);
312 assert(it!=PAGNodeToFormalParmMap.end() && "formal parameter VFG node can not be found??");
313 return it->second;
314 }
316 {
317 PAGNodeToFormalRetMapTy::const_iterator it = PAGNodeToFormalRetMap.find(fret);
318 assert(it!=PAGNodeToFormalRetMap.end() && "formal return VFG node can not be found??");
319 return it->second;
320 }
322
324 const FunObjVar* isFunEntryVFGNode(const VFGNode* node) const;
325
328 {
329 if (hasDef(pagNode))
330 {
332 if (const AddrVFGNode* addr = SVFUtil::dyn_cast<AddrVFGNode>(defNode))
333 {
334 if (SVFIR::getPAG()->isBlkObjOrConstantObj(addr->getPAGEdge()->getSrcID()))
335 return true;
336 }
337 else if(const CopyVFGNode* copy = SVFUtil::dyn_cast<CopyVFGNode>(defNode))
338 {
339 if (SVFIR::getPAG()->isNullPtr(copy->getPAGEdge()->getSrcID()))
340 return true;
341 }
342 }
343 return false;
344 }
345
348 inline VFGNodeSet& getVFGNodes(const FunObjVar *fun)
349 {
350 return funToVFGNodesMap[fun];
351 }
352 inline bool hasVFGNodes(const FunObjVar *fun) const
353 {
354 return funToVFGNodesMap.find(fun) != funToVFGNodesMap.end();
355 }
356 inline bool VFGNodes(const FunObjVar *fun) const
357 {
358 return funToVFGNodesMap.find(fun) != funToVFGNodesMap.end();
359 }
360 inline VFGNodeSet::const_iterator getVFGNodeBegin(const FunObjVar *fun) const
361 {
362 FunToVFGNodesMapTy::const_iterator it = funToVFGNodesMap.find(fun);
363 assert(it != funToVFGNodesMap.end() && "this function does not have any VFGNode");
364 return it->second.begin();
365 }
366 inline VFGNodeSet::const_iterator getVFGNodeEnd(const FunObjVar *fun) const
367 {
368 FunToVFGNodesMapTy::const_iterator it = funToVFGNodesMap.find(fun);
369 assert(it != funToVFGNodesMap.end() && "this function does not have any VFGNode");
370 return it->second.end();
371 }
374
379
382 {
383 edge->getDstNode()->removeIncomingEdge(edge);
384 edge->getSrcNode()->removeOutgoingEdge(edge);
385 delete edge;
386 }
388 inline void removeVFGNode(VFGNode* node)
389 {
390 removeGNode(node);
391 }
392
394
399
401 inline bool addVFGEdge(VFGEdge* edge)
402 {
403 bool added1 = edge->getDstNode()->addIncomingEdge(edge);
404 bool added2 = edge->getSrcNode()->addOutgoingEdge(edge);
405 bool both_added = added1 & added2;
406 assert(both_added && "VFGEdge not added??");
407 return both_added;
408 }
409
410protected:
411
414 {
415 const FunObjVar *srcfun = srcNode->getFun();
416 const FunObjVar *dstfun = dstNode->getFun();
417 if(srcfun != nullptr && dstfun != nullptr)
418 {
419 assert((srcfun == dstfun) && "src and dst nodes of an intra VFG edge are not in the same function?");
420 }
421 }
422
425 {
426 return addCallEdge(src->getId(),dst->getId(),csId);
427 }
430 {
431 return addRetEdge(src->getId(),dst->getId(),csId);
432 }
433
436 {
437 return addCallEdge(src,dst,csId);
438 }
441 {
442 return addRetEdge(src,dst,csId);
443 }
444
446
447
458 {
461 VFGEdge* edge = addInterEdgeFromFRToAR(formalRet, actualRet,csId);
462 if (edge != nullptr)
463 edges.insert(edge);
464 }
466
468
469 inline void setDef(const PAGNode* pagNode, const VFGNode* node)
470 {
471 PAGNodeToDefMapTy::iterator it = PAGNodeToDefMap.find(pagNode);
472 if(it == PAGNodeToDefMap.end())
473 {
474 PAGNodeToDefMap[pagNode] = node->getId();
475 assert(hasVFGNode(node->getId()) && "not in the map!!");
476 }
477 else
478 {
479 assert((it->second == node->getId()) && "a SVFVar can only have unique definition ");
480 }
481 }
482 inline NodeID getDef(const PAGNode* pagNode) const
483 {
484 PAGNodeToDefMapTy::const_iterator it = PAGNodeToDefMap.find(pagNode);
485 assert(it!=PAGNodeToDefMap.end() && "SVFVar does not have a definition??");
486 return it->second;
487 }
488 inline bool hasDef(const PAGNode* pagNode) const
489 {
490 return (PAGNodeToDefMap.find(pagNode) != PAGNodeToDefMap.end());
491 }
493
495 void addVFGNodes();
496
499 {
500 if (isPtrOnlySVFG())
501 return pag->getPTASVFStmtSet(kind);
502 else
503 return pag->getSVFStmtSet(kind);
504 }
505
506 virtual inline bool isInterestedPAGNode(const SVFVar* node) const
507 {
508 if (isPtrOnlySVFG())
509 return node->isPointer();
510 else
511 return true;
512 }
513
516
519
520 inline bool isPhiCopyEdge(const PAGEdge* copy) const
521 {
522 return pag->isPhiNode(copy->getDstNode());
523 }
524
526 virtual inline void addVFGNode(VFGNode* vfgNode, ICFGNode* icfgNode)
527 {
528 addGNode(vfgNode->getId(), vfgNode);
529 vfgNode->setICFGNode(icfgNode);
530 icfgNode->addVFGNode(vfgNode);
531
532 if(const FunObjVar* fun = icfgNode->getFun())
533 funToVFGNodesMap[fun].insert(vfgNode);
534 else
535 globalVFGNodes.insert(vfgNode);
536 }
537
539 inline void addStmtVFGNode(StmtVFGNode* node, const PAGEdge* pagEdge)
540 {
541 assert(PAGEdgeToStmtVFGNodeMap.find(pagEdge)==PAGEdgeToStmtVFGNodeMap.end() && "should not insert twice!");
542 PAGEdgeToStmtVFGNodeMap[pagEdge] = node;
543 addVFGNode(node, pagEdge->getICFGNode());
544 }
554 inline void addAddrVFGNode(const AddrStmt* addr)
555 {
558 setDef(addr->getLHSVar(),sNode);
559 }
561 inline void addCopyVFGNode(const CopyStmt* copy)
562 {
565 setDef(copy->getLHSVar(),sNode);
566 }
568 inline void addGepVFGNode(const GepStmt* gep)
569 {
572 setDef(gep->getLHSVar(),sNode);
573 }
575 void addLoadVFGNode(const LoadStmt* load)
576 {
578 addStmtVFGNode(sNode, load);
579 setDef(load->getLHSVar(),sNode);
580 }
583 void addStoreVFGNode(const StoreStmt* store)
584 {
586 addStmtVFGNode(sNode, store);
587 }
588
592 inline void addActualParmVFGNode(const PAGNode* aparm, const CallICFGNode* cs)
593 {
595 addVFGNode(sNode, const_cast<CallICFGNode*>(cs));
596 PAGNodeToActualParmMap[std::make_pair(aparm->getId(),cs)] = sNode;
598 }
600 inline void addFormalParmVFGNode(const PAGNode* fparm, const FunObjVar* fun, CallPESet& callPEs)
601 {
604 for(CallPESet::const_iterator it = callPEs.begin(), eit=callPEs.end();
605 it!=eit; ++it)
606 sNode->addCallPE(*it);
607
610 }
614 inline void addFormalRetVFGNode(const PAGNode* uniqueFunRet, const FunObjVar* fun, RetPESet& retPEs)
615 {
618 for (RetPESet::const_iterator it = retPEs.begin(), eit = retPEs.end(); it != eit; ++it)
619 sNode->addRetPE(*it);
620
626 {
627 std::string warn = fun->getName();
628 SVFUtil::writeWrnMsg(warn + " does not have any ret instruction!");
630 }
631 }
633 inline void addActualRetVFGNode(const PAGNode* ret,const CallICFGNode* cs)
634 {
636 addVFGNode(sNode, const_cast<RetICFGNode*>(cs->getRetICFGNode()));
637 setDef(ret,sNode);
639 }
642 {
644 u32_t pos = 0;
645 for(auto var : edge->getOpndVars())
646 {
647 sNode->setOpVerAndBB(pos, var, edge->getICFGNode());
648 pos++;
649 }
650 addVFGNode(sNode,edge->getICFGNode());
651 setDef(edge->getRes(),sNode);
653 }
655 inline void addCmpVFGNode(const CmpStmt* edge)
656 {
657 CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, edge->getRes());
658 u32_t pos = 0;
659 for(auto var : edge->getOpndVars())
660 {
661 sNode->setOpVer(pos, var);
662 pos++;
663 }
664 addVFGNode(sNode,edge->getICFGNode());
665 setDef(edge->getRes(),sNode);
666 PAGNodeToCmpVFGNodeMap[edge->getRes()] = sNode;
667 }
670 {
672 u32_t pos = 0;
673 for(auto var : edge->getOpndVars())
674 {
675 sNode->setOpVer(pos, var);
676 pos++;
677 }
678 addVFGNode(sNode,edge->getICFGNode());
679 setDef(edge->getRes(),sNode);
681 }
684 {
686 sNode->setOpVer(0, edge->getOpVar());
687 addVFGNode(sNode,edge->getICFGNode());
688 setDef(edge->getRes(),sNode);
690 }
692 inline void addBranchVFGNode(const BranchStmt* edge)
693 {
695 addVFGNode(sNode,edge->getICFGNode());
696 setDef(edge->getBranchInst(),sNode);
697 PAGNodeToBranchVFGNodeMap[edge->getBranchInst()] = sNode;
698 }
699};
700
701} // End namespace SVF
702
703namespace SVF
704{
705/* !
706 * GenericGraphTraits specializations for generic graph algorithms.
707 * Provide graph traits for traversing from a constraint node using standard graph traversals.
708 */
709template<> struct GenericGraphTraits<SVF::VFGNode*> : public GenericGraphTraits<SVF::GenericNode<SVF::VFGNode,SVF::VFGEdge>* >
710{
711};
712
714template<>
715struct GenericGraphTraits<Inverse<SVF::VFGNode *> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::VFGNode,SVF::VFGEdge>* > >
716{
717};
718
719template<> struct GenericGraphTraits<SVF::VFG*> : public GenericGraphTraits<SVF::GenericGraph<SVF::VFGNode,SVF::VFGEdge>* >
720{
722};
723
724} // End namespace llvm
725
726#endif /* INCLUDE_UTIL_VFG_H_ */
copy
Definition cJSON.cpp:414
SVFVar * getLHSVar() const
const CallICFGNode * getCallSite(CallSiteID id) const
Definition CallGraph.h:396
CallSiteID getCallSiteID(const CallICFGNode *cs, const FunObjVar *callee) const
Get CallSiteID.
Definition CallGraph.h:377
const RetICFGNode * getRetICFGNode() const
Return callsite.
Definition ICFGNode.h:451
void addGNode(NodeID id, NodeType *node)
Add a Node.
void removeGNode(NodeType *node)
Delete a node.
bool hasGNode(NodeID id) const
Has a node.
NodeType * getGNode(NodeID id) const
Get a node.
virtual const FunObjVar * getFun() const
Return the function of this ICFGNode.
Definition ICFGNode.h:76
void addVFGNode(const VFGNode *vfgNode)
Definition ICFGNode.h:99
FunExitICFGNode * getFunExitICFGNode(const FunObjVar *fun)
Add a function exit node.
Definition ICFG.cpp:249
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
Definition ICFG.cpp:242
GlobalICFGNode * getGlobalICFGNode() const
Definition ICFG.h:236
Set< const SVFStmt * > SVFStmtSet
Definition IRGraph.h:106
SVFStmt::SVFStmtSetTy & getPTASVFStmtSet(SVFStmt::PEDGEK kind)
Get PTA edges set according to its kind.
Definition SVFIR.h:234
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
Definition SVFIR.h:229
bool isPhiNode(const SVFVar *node) const
Whether this SVFVar is a result operand a of phi node.
Definition SVFIR.h:287
ICFG * getICFG() const
Definition SVFIR.h:163
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:116
ICFGNode * getICFGNode() const
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
NodeID getId() const
Get ID.
Definition SVFValue.h:158
virtual const std::string & getName() const
Definition SVFValue.h:184
virtual bool isPointer() const
Check if this variable represents a pointer.
GenericNode< VFGNode, VFGEdge >::GEdgeSetTy VFGEdgeSetTy
Definition VFGEdge.h:117
VFGEdgeSetTy SVFGEdgeSetTy
Definition VFGEdge.h:118
Set< const RetPE * > RetPESet
Definition VFGNode.h:57
Set< const CallPE * > CallPESet
Definition VFGNode.h:56
Definition VFG.h:51
Set< VFGNode * > VFGNodeSet
Definition VFG.h:61
UnaryOPVFGNode * getUnaryOPVFGNode(const PAGNode *pagNode) const
Definition VFG.h:279
CallGraph * getCallGraph() const
Return PTACallGraph.
Definition VFG.h:139
bool hasBinaryOPVFGNode(const PAGNode *pagNode) const
Definition VFG.h:225
VFGEdge::VFGEdgeSetTy VFGEdgeSetTy
Definition VFG.h:77
void updateCallGraph(PointerAnalysis *pta)
Update VFG based on pointer analysis results.
Definition VFG.cpp:935
const CallICFGNode * getCallSite(CallSiteID id) const
Definition VFG.h:182
PAGNodeToBinaryOPVFGNodeMapTy PAGNodeToBinaryOPVFGNodeMap
map a PAGNode to its BinaryOPVFGNode
Definition VFG.h:95
VFGEdge * addInterEdgeFromAPToFP(ActualParmVFGNode *src, FormalParmVFGNode *dst, CallSiteID csId)
Add inter VF edge from actual to formal parameters.
Definition VFG.h:424
Set< const VFGNode * > GlobalVFGNodeSet
Definition VFG.h:83
void removeVFGNode(VFGNode *node)
Remove a VFGNode.
Definition VFG.h:388
void addStoreVFGNode(const StoreStmt *store)
Definition VFG.h:583
VFGEdge * addInterEdgeFromFRToAR(FormalRetVFGNode *src, ActualRetVFGNode *dst, CallSiteID csId)
Add inter VF edge from callee return to callsite receive parameter.
Definition VFG.h:429
void addBranchVFGNode(const BranchStmt *edge)
Add a BranchVFGNode.
Definition VFG.h:692
PAGNodeToFormalRetMapTy PAGNodeToFormalRetMap
map a PAGNode to a formal return
Definition VFG.h:93
virtual SVFStmt::SVFStmtSetTy & getPAGEdgeSet(SVFStmt::PEDGEK kind)
Get PAGEdge set.
Definition VFG.h:498
VFGEdge * addInterEdgeFromFRToAR(NodeID src, NodeID dst, CallSiteID csId)
Add inter VF edge from callee return to callsite receive parameter.
Definition VFG.h:440
void setDef(const PAGNode *pagNode, const VFGNode *node)
Given a PAGNode, set/get its def VFG node (definition of top level pointers)
Definition VFG.h:469
const PAGNode * getLHSTopLevPtr(const VFGNode *node) const
Definition VFG.cpp:1008
FormalParmVFGNode * getFormalParmVFGNode(const PAGNode *fparm) const
Definition VFG.h:309
VFGNodeIDToNodeMapTy::const_iterator const_iterator
Definition VFG.h:81
VFGNodeIDToNodeMapTy::iterator iterator
Definition VFG.h:80
SVFIR * pag
Definition VFG.h:104
ActualRetVFGNode * getActualRetVFGNode(const PAGNode *aret) const
Definition VFG.h:303
bool isPtrOnlySVFG() const
Return true if this VFG only contains pointer related SVFGNodes for pointer analysis.
Definition VFG.h:127
VFGEdge * addRetEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
Definition VFG.cpp:705
PAGNodeToActualRetMapTy PAGNodeToActualRetMap
map a PAGNode to an actual return
Definition VFG.h:91
virtual void connectAParamAndFParam(const PAGNode *csArg, const PAGNode *funArg, const CallICFGNode *cbn, CallSiteID csId, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
Definition VFG.h:448
FormalRetVFGNode * getFormalRetVFGNode(const PAGNode *fret) const
Definition VFG.h:315
VFGEdge::VFGEdgeSetTy::iterator VFGNodeIter
Definition VFG.h:79
bool hasVFGNode(NodeID id) const
Whether has the VFGNode.
Definition VFG.h:151
void addVFGNodes()
Create VFG nodes.
Definition VFG.cpp:447
void addLoadVFGNode(const LoadStmt *load)
Add a Load VFG node.
Definition VFG.h:575
Map< const FunObjVar *, VFGNodeSet > FunToVFGNodesMapTy
Definition VFG.h:73
CallSiteID getCallSiteID(const CallICFGNode *cs, const FunObjVar *func) const
Get callsite given a callsiteID.
Definition VFG.h:178
VFGK kind
Definition VFG.h:105
VFGEdge * addIntraDirectVFEdge(NodeID srcId, NodeID dstId)
Definition VFG.cpp:659
void addVFGInterEdges(const CallICFGNode *cs, const FunObjVar *callee)
Create edges between VFG nodes across functions.
bool hasVFGNodes(const FunObjVar *fun) const
Definition VFG.h:352
void checkIntraEdgeParents(const VFGNode *srcNode, const VFGNode *dstNode)
sanitize Intra edges, verify that both nodes belong to the same function.
Definition VFG.h:413
PAGEdgeToStmtVFGNodeMapTy PAGEdgeToStmtVFGNodeMap
map a PAGEdge to its StmtVFGNode
Definition VFG.h:99
void addCopyVFGNode(const CopyStmt *copy)
Add a Copy VFG node.
Definition VFG.h:561
bool hasFormalRetVFGNode(const PAGNode *fret) const
Definition VFG.h:253
void addGepVFGNode(const GepStmt *gep)
Add a Gep VFG node.
Definition VFG.h:568
Map< const PAGNode *, FormalRetVFGNode * > PAGNodeToFormalRetMapTy
Definition VFG.h:66
IntraPHIVFGNode * getIntraPHIVFGNode(const PAGNode *pagNode) const
Definition VFG.h:267
PAGNodeToPHIVFGNodeMapTy PAGNodeToIntraPHIVFGNodeMap
map a PAGNode to its PHIVFGNode
Definition VFG.h:94
void addNullPtrVFGNode(const PAGNode *pagNode)
Definition VFG.h:547
CmpVFGNode * getCmpVFGNode(const PAGNode *pagNode) const
Definition VFG.h:291
void addActualRetVFGNode(const PAGNode *ret, const CallICFGNode *cs)
Add a callsite Receive VFG node.
Definition VFG.h:633
void addUnaryOPVFGNode(const UnaryOPStmt *edge)
Add a UnaryOperator VFG node.
Definition VFG.h:683
virtual ~VFG()
Destructor.
Definition VFG.h:115
void addFormalParmVFGNode(const PAGNode *fparm, const FunObjVar *fun, CallPESet &callPEs)
Add a formal parameter VFG node.
Definition VFG.h:600
SVFIR * getPAG() const
Return SVFIR.
Definition VFG.h:133
void addActualParmVFGNode(const PAGNode *aparm, const CallICFGNode *cs)
Definition VFG.h:592
void addCmpVFGNode(const CmpStmt *edge)
Add a Compare VFG node.
Definition VFG.h:655
GlobalVFGNodeSet globalVFGNodes
set of global store VFG nodes
Definition VFG.h:102
Map< std::pair< NodeID, const CallICFGNode * >, ActualParmVFGNode * > PAGNodeToActualParmMapTy
Definition VFG.h:63
void addStmtVFGNode(StmtVFGNode *node, const PAGEdge *pagEdge)
Add a VFG node for program statement.
Definition VFG.h:539
Map< const PAGNode *, FormalParmVFGNode * > PAGNodeToFormalParmMapTy
Definition VFG.h:65
Map< const PAGNode *, BranchVFGNode * > PAGNodeToBranchVFGNodeMapTy
Definition VFG.h:71
bool hasCmpVFGNode(const PAGNode *pagNode) const
Definition VFG.h:237
NodeID getDef(const PAGNode *pagNode) const
Definition VFG.h:482
VFGNodeSet::const_iterator getVFGNodeEnd(const FunObjVar *fun) const
Definition VFG.h:366
Map< const PAGNode *, BinaryOPVFGNode * > PAGNodeToBinaryOPVFGNodeMapTy
Definition VFG.h:69
const VFGNode * getDefVFGNode(const PAGNode *pagNode) const
Given a pagNode, return its definition site.
Definition VFG.h:189
bool addVFGEdge(VFGEdge *edge)
Add VFG edge.
Definition VFG.h:401
virtual bool isInterestedPAGNode(const SVFVar *node) const
Definition VFG.h:506
bool hasLHSTopLevPtr(const VFGNode *node) const
Definition VFG.h:195
VFGNodeSet & getVFGNodes(const FunObjVar *fun)
Definition VFG.h:348
BinaryOPVFGNode * getBinaryOPVFGNode(const PAGNode *pagNode) const
Definition VFG.h:273
bool hasBlackHoleConstObjAddrAsDef(const PAGNode *pagNode) const
Whether a PAGNode has a blackhole or const object as its definition.
Definition VFG.h:327
PAGNodeToActualParmMapTy PAGNodeToActualParmMap
map a PAGNode to an actual parameter
Definition VFG.h:90
ActualParmVFGNode * getActualParmVFGNode(const PAGNode *aparm, const CallICFGNode *cs) const
Definition VFG.h:297
bool hasStmtVFGNode(const PAGEdge *pagEdge) const
Existence checks for VFGNodes.
Definition VFG.h:217
bool isPhiCopyEdge(const PAGEdge *copy) const
Definition VFG.h:520
SVFIR::SVFStmtSet SVFStmtSet
Definition VFG.h:82
VFGNode * getVFGNode(NodeID id) const
Get a VFG node.
Definition VFG.h:145
BranchVFGNode * getBranchVFGNode(const PAGNode *pagNode) const
Definition VFG.h:285
const FunObjVar * isFunEntryVFGNode(const VFGNode *node) const
Whether a node is function entry VFGNode.
Definition VFG.cpp:1045
Map< const PAGNode *, ActualRetVFGNode * > PAGNodeToActualRetMapTy
Definition VFG.h:64
PAGNodeToCmpVFGNodeMapTy PAGNodeToCmpVFGNodeMap
map a PAGNode to its CmpVFGNode
Definition VFG.h:98
FunToVFGNodesMapTy funToVFGNodesMap
map a function to its VFGNodes;
Definition VFG.h:100
Map< const PAGNode *, CmpVFGNode * > PAGNodeToCmpVFGNodeMapTy
Definition VFG.h:72
StmtVFGNode * getStmtVFGNode(const PAGEdge *pagEdge) const
Get an VFGNode.
Definition VFG.h:261
VFGNodeSet::const_iterator getVFGNodeBegin(const FunObjVar *fun) const
Definition VFG.h:360
bool hasFormalParmVFGNode(const PAGNode *fparm) const
Definition VFG.h:249
VFGEdge * addCallEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
Definition VFG.cpp:685
bool hasUnaryOPVFGNode(const PAGNode *pagNode) const
Definition VFG.h:229
GlobalVFGNodeSet & getGlobalVFGNodes()
Return global stores.
Definition VFG.h:156
Set< const PAGNode * > PAGNodeSet
Definition VFG.h:84
Map< const PAGEdge *, StmtVFGNode * > PAGEdgeToStmtVFGNodeMapTy
Definition VFG.h:67
virtual void connectFRetAndARet(const PAGNode *funReturn, const PAGNode *csReturn, CallSiteID csId, VFGEdgeSetTy &edges)
Connect formal-ret and actual ret.
Definition VFG.h:457
bool hasDef(const PAGNode *pagNode) const
Definition VFG.h:488
Map< const PAGNode *, NodeID > PAGNodeToDefMapTy
Definition VFG.h:62
FormalRetVFGNode::RetPESet RetPESet
Definition VFG.h:76
bool hasActualParmVFGNode(const PAGNode *aparm, const CallICFGNode *cs) const
Definition VFG.h:241
VFGK
VFG kind.
Definition VFG.h:56
@ FULLSVFG
Definition VFG.h:57
@ PTRONLYSVFG_OPT
Definition VFG.h:57
@ FULLSVFG_OPT
Definition VFG.h:57
@ PTRONLYSVFG
Definition VFG.h:57
VFGEdge * hasIntraVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
Whether we has a SVFG edge.
Definition VFG.cpp:859
PAGNodeToUnaryOPVFGNodeMapTy PAGNodeToUnaryOPVFGNodeMap
map a PAGNode to its UnaryOPVFGNode
Definition VFG.h:96
void addBinaryOPVFGNode(const BinaryOPStmt *edge)
Add a BinaryOperator VFG node.
Definition VFG.h:669
PAGNodeToDefMapTy PAGNodeToDefMap
map a pag node to its definition SVG node
Definition VFG.h:89
VFGEdge::SVFGEdgeSetTy SVFGEdgeSetTy
Definition VFG.h:78
void addAddrVFGNode(const AddrStmt *addr)
Add an Address VFG node.
Definition VFG.h:554
OrderedMap< NodeID, VFGNode * > VFGNodeIDToNodeMapTy
Definition VFG.h:60
NodeID totalVFGNode
Definition VFG.h:88
VFGEdge * addInterEdgeFromAPToFP(NodeID src, NodeID dst, CallSiteID csId)
Add inter VF edge from actual to formal parameters.
Definition VFG.h:435
Map< const PAGNode *, UnaryOPVFGNode * > PAGNodeToUnaryOPVFGNodeMapTy
Definition VFG.h:70
PAGNodeToFormalParmMapTy PAGNodeToFormalParmMap
map a PAGNode to a formal parameter
Definition VFG.h:92
bool hasIntraPHIVFGNode(const PAGNode *pagNode) const
Definition VFG.h:221
VFGK getKind() const
Get VFG kind.
Definition VFG.h:121
VFGEdge * hasInterVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind, CallSiteID csId)
Definition VFG.cpp:894
virtual void addVFGNode(VFGNode *vfgNode, ICFGNode *icfgNode)
Add a VFG node.
Definition VFG.h:526
FormalParmVFGNode::CallPESet CallPESet
Definition VFG.h:75
void connectDirectVFGEdges()
Create edges between VFG nodes within a function.
Definition VFG.cpp:726
VFGEdge * getIntraVFGEdge(const VFGNode *src, const VFGNode *dst, VFGEdge::VFGEdgeK kind)
Get a SVFG edge according to src and dst.
Definition VFG.cpp:912
void view()
Dump graph into dot file.
Definition VFG.cpp:929
VFGEdge * hasThreadVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
Definition VFG.cpp:877
void removeVFGEdge(VFGEdge *edge)
Remove a SVFG edge.
Definition VFG.h:381
void dump(const std::string &file, bool simple=false)
Dump graph into dot file.
Definition VFG.cpp:921
Map< const PAGNode *, IntraPHIVFGNode * > PAGNodeToPHIVFGNodeMapTy
Definition VFG.h:68
bool VFGNodes(const FunObjVar *fun) const
Definition VFG.h:356
virtual void connectCallerAndCallee(const CallICFGNode *cs, const FunObjVar *callee, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
Definition VFG.cpp:957
void addFormalRetVFGNode(const PAGNode *uniqueFunRet, const FunObjVar *fun, RetPESet &retPEs)
Definition VFG.h:614
void destroy()
Clean up memory.
Definition VFG.cpp:438
bool hasActualRetVFGNode(const PAGNode *aret) const
Definition VFG.h:245
PAGNodeToBranchVFGNodeMapTy PAGNodeToBranchVFGNodeMap
map a PAGNode to its BranchVFGNode
Definition VFG.h:97
CallGraph * callgraph
Definition VFG.h:103
void addIntraPHIVFGNode(const MultiOpndStmt *edge)
Add an llvm PHI VFG node.
Definition VFG.h:641
bool hasBranchVFGNode(const PAGNode *pagNode) const
Definition VFG.h:233
LLVM_NODISCARD bool isa(const Y &Val)
Definition Casting.h:241
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition SVFUtil.cpp:68
for isBitcode
Definition BasicTypes.h:68
unsigned CallSiteID
Definition GeneralType.h:58
u32_t NodeID
Definition GeneralType.h:56
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
GenericGraph< VFGNode, VFGEdge > GenericVFGTy
Definition VFG.h:49
unsigned u32_t
Definition GeneralType.h:47