Static Value-Flow Analysis
Loading...
Searching...
No Matches
ConsG.cpp
Go to the documentation of this file.
1//===- ConsG.cpp -- Constraint graph representation-----------------------------//
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 * ConstraintGraph.cpp
25 *
26 * Created on: Oct 14, 2013
27 * Author: Yulei Sui
28 */
29
30#include "Graphs/ConsG.h"
31#include "Graphs/GraphPrinter.h"
32#include "Util/GeneralType.h"
33#include "Util/Options.h"
34
35using namespace SVF;
36using namespace SVFUtil;
37
38
43{
44
45 // initialize nodes
46 for(SVFIR::iterator it = pag->begin(), eit = pag->end(); it!=eit; ++it)
47 {
48 addConstraintNode(new ConstraintNode(it->first), it->first);
49 }
50
51 // initialize edges
53 for (SVFStmt::SVFStmtSetTy::iterator iter = addrs.begin(), eiter =
54 addrs.end(); iter != eiter; ++iter)
55 {
56 const AddrStmt* edge = SVFUtil::cast<AddrStmt>(*iter);
57 addAddrCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
58 }
59
61 for (SVFStmt::SVFStmtSetTy::iterator iter = copys.begin(), eiter =
62 copys.end(); iter != eiter; ++iter)
63 {
64 const CopyStmt* edge = SVFUtil::cast<CopyStmt>(*iter);
65 if(edge->isBitCast() || edge->isValueCopy())
66 addCopyCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
67 }
68
70 for (SVFStmt::SVFStmtSetTy::iterator iter = phis.begin(), eiter =
71 phis.end(); iter != eiter; ++iter)
72 {
73 const PhiStmt* edge = SVFUtil::cast<PhiStmt>(*iter);
74 for(const auto opVar : edge->getOpndVars())
75 addCopyCGEdge(opVar->getId(),edge->getResID());
76 }
77
79 for (SVFStmt::SVFStmtSetTy::iterator iter = selects.begin(), eiter =
80 selects.end(); iter != eiter; ++iter)
81 {
82 const SelectStmt* edge = SVFUtil::cast<SelectStmt>(*iter);
83 for(const auto opVar : edge->getOpndVars())
84 addCopyCGEdge(opVar->getId(),edge->getResID());
85 }
86
88 for (SVFStmt::SVFStmtSetTy::iterator iter = calls.begin(), eiter =
89 calls.end(); iter != eiter; ++iter)
90 {
91 const CallPE* callPE = SVFUtil::cast<CallPE>(*iter);
92 for(u32_t i = 0; i < callPE->getOpVarNum(); i++)
93 addCopyCGEdge(callPE->getOpVarID(i), callPE->getResID());
94 }
95
97 for (SVFStmt::SVFStmtSetTy::iterator iter = rets.begin(), eiter =
98 rets.end(); iter != eiter; ++iter)
99 {
100 const RetPE* edge = SVFUtil::cast<RetPE>(*iter);
101 addCopyCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
102 }
103
105 for (SVFStmt::SVFStmtSetTy::iterator iter = tdfks.begin(), eiter =
106 tdfks.end(); iter != eiter; ++iter)
107 {
108 const TDForkPE* forkPE = SVFUtil::cast<TDForkPE>(*iter);
109 for(u32_t i = 0; i < forkPE->getOpVarNum(); i++)
110 addCopyCGEdge(forkPE->getOpVarID(i), forkPE->getResID());
111 }
112
114 for (SVFStmt::SVFStmtSetTy::iterator iter = tdjns.begin(), eiter =
115 tdjns.end(); iter != eiter; ++iter)
116 {
117 const TDJoinPE* edge = SVFUtil::cast<TDJoinPE>(*iter);
118 addCopyCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
119 }
120
122 for (SVFStmt::SVFStmtSetTy::iterator iter = ngeps.begin(), eiter =
123 ngeps.end(); iter != eiter; ++iter)
124 {
125 GepStmt* edge = SVFUtil::cast<GepStmt>(*iter);
126 if(edge->isVariantFieldGep())
127 addVariantGepCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
128 else
129 addNormalGepCGEdge(edge->getRHSVarID(),edge->getLHSVarID(),edge->getAccessPath());
130 }
131
133 for (SVFStmt::SVFStmtSetTy::iterator iter = loads.begin(), eiter =
134 loads.end(); iter != eiter; ++iter)
135 {
136 LoadStmt* edge = SVFUtil::cast<LoadStmt>(*iter);
137 addLoadCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
138 }
139
141 for (SVFStmt::SVFStmtSetTy::iterator iter = stores.begin(), eiter =
142 stores.end(); iter != eiter; ++iter)
143 {
144 StoreStmt* edge = SVFUtil::cast<StoreStmt>(*iter);
145 addStoreCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
146 }
147
149}
150
155{
158 for(auto cs_pair : pag->getIndirectCallsites())
159 {
160 const RetICFGNode* retBlockNode = cs_pair.first->getRetICFGNode();
163 }
164
166 for (auto it = this->begin(); it != this->end(); ++it)
167 {
168 if (it->second->hasIncomingEdge() || it->second->hasOutgoingEdge())
169 continue;
170 if (pag->getSVFVar(it->first)->isPointer())
171 continue;
172 if (retFromIndCalls.find(it->first)!=retFromIndCalls.end())
173 continue;
174 nodesToRemove.insert(it->second);
175 }
176
177 for (auto node : nodesToRemove)
179}
180
187
192 : ConstraintEdge(s,d,Addr,id)
193{
194 // Retarget addr edges may lead s to be a dummy node
195 const SVFVar* node = SVFIR::getPAG()->getSVFVar(s->getId());
196 (void)node; // Suppress warning of unused variable under release build
198 {
199 assert(!SVFUtil::isa<DummyValVar>(node) && "a dummy node??");
200 }
201}
202
207{
211 return nullptr;
213
214 bool inserted = AddrCGEdgeSet.insert(edge).second;
215 (void)inserted; // Suppress warning of unused variable under release build
216 assert(inserted && "new AddrCGEdge not added??");
217
218 srcNode->addOutgoingAddrEdge(edge);
219 dstNode->addIncomingAddrEdge(edge);
220 return edge;
221}
222
227{
228
232 return nullptr;
233
235
236 bool inserted = directEdgeSet.insert(edge).second;
237 (void)inserted; // Suppress warning of unused variable under release build
238 assert(inserted && "new CopyCGEdge not added??");
239
240 srcNode->addOutgoingCopyEdge(edge);
241 dstNode->addIncomingCopyEdge(edge);
242 return edge;
243}
244
245
250{
254 return nullptr;
255
258
259 bool inserted = directEdgeSet.insert(edge).second;
260 (void)inserted; // Suppress warning of unused variable under release build
261 assert(inserted && "new NormalGepCGEdge not added??");
262
263 srcNode->addOutgoingGepEdge(edge);
264 dstNode->addIncomingGepEdge(edge);
265 return edge;
266}
267
272{
276 return nullptr;
277
279
280 bool inserted = directEdgeSet.insert(edge).second;
281 (void)inserted; // Suppress warning of unused variable under release build
282 assert(inserted && "new VariantGepCGEdge not added??");
283
284 srcNode->addOutgoingGepEdge(edge);
285 dstNode->addIncomingGepEdge(edge);
286 return edge;
287}
288
293{
297 return nullptr;
298
300
301 bool inserted = LoadCGEdgeSet.insert(edge).second;
302 (void)inserted; // Suppress warning of unused variable under release build
303 assert(inserted && "new LoadCGEdge not added??");
304
305 srcNode->addOutgoingLoadEdge(edge);
306 dstNode->addIncomingLoadEdge(edge);
307 return edge;
308}
309
314{
318 return nullptr;
319
321
322 bool inserted = StoreCGEdgeSet.insert(edge).second;
323 (void)inserted; // Suppress warning of unused variable under release build
324 assert(inserted && "new StoreCGEdge not added??");
325
326 srcNode->addOutgoingStoreEdge(edge);
327 dstNode->addIncomingStoreEdge(edge);
328 return edge;
329}
330
331
340{
341 NodeID newDstNodeID = newDstNode->getId();
342 NodeID srcId = edge->getSrcID();
343 if(LoadCGEdge* load = SVFUtil::dyn_cast<LoadCGEdge>(edge))
344 {
345 removeLoadEdge(load);
347 }
348 else if(StoreCGEdge* store = SVFUtil::dyn_cast<StoreCGEdge>(edge))
349 {
350 removeStoreEdge(store);
352 }
353 else if(CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(edge))
354 {
357 }
358 else if(NormalGepCGEdge* gep = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
359 {
360 const AccessPath ap = gep->getAccessPath();
363 }
364 else if(VariantGepCGEdge* gep = SVFUtil::dyn_cast<VariantGepCGEdge>(edge))
365 {
368 }
369 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
370 {
372 }
373 else
374 assert(false && "no other edge type!!");
375}
376
384{
385 NodeID newSrcNodeID = newSrcNode->getId();
386 NodeID dstId = edge->getDstID();
387 if(LoadCGEdge* load = SVFUtil::dyn_cast<LoadCGEdge>(edge))
388 {
389 removeLoadEdge(load);
391 }
392 else if(StoreCGEdge* store = SVFUtil::dyn_cast<StoreCGEdge>(edge))
393 {
394 removeStoreEdge(store);
396 }
397 else if(CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(edge))
398 {
401 }
402 else if(NormalGepCGEdge* gep = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
403 {
404 const AccessPath ap = gep->getAccessPath();
407 }
408 else if(VariantGepCGEdge* gep = SVFUtil::dyn_cast<VariantGepCGEdge>(edge))
409 {
412 }
413 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
414 {
416 }
417 else
418 assert(false && "no other edge type!!");
419}
420
425{
428 u32_t num = AddrCGEdgeSet.erase(edge);
429 (void)num; // Suppress warning of unused variable under release build
430 assert(num && "edge not in the set, can not remove!!!");
431 delete edge;
432}
433
438{
441 u32_t num = LoadCGEdgeSet.erase(edge);
442 (void)num; // Suppress warning of unused variable under release build
443 assert(num && "edge not in the set, can not remove!!!");
444 delete edge;
445}
446
451{
454 u32_t num = StoreCGEdgeSet.erase(edge);
455 (void)num; // Suppress warning of unused variable under release build
456 assert(num && "edge not in the set, can not remove!!!");
457 delete edge;
458}
459
464{
465
468 u32_t num = directEdgeSet.erase(edge);
469 (void)num; // Suppress warning of unused variable under release build
470 assert(num && "edge not in the set, can not remove!!!");
471 delete edge;
472}
473
479{
480 std::vector<ConstraintEdge*> sccEdges;
481 std::vector<ConstraintEdge*> nonSccEdges;
482 for (ConstraintNode::const_iterator it = node->InEdgeBegin(), eit = node->InEdgeEnd(); it != eit;
483 ++it)
484 {
486 if(sccRepNode(subInEdge->getSrcID()) != rep->getId())
487 nonSccEdges.push_back(subInEdge);
488 else
489 {
490 sccEdges.push_back(subInEdge);
491 }
492 }
493 // if this edge is outside scc, then re-target edge dst to rep
494 while(!nonSccEdges.empty())
495 {
497 nonSccEdges.pop_back();
499 }
500
501 bool criticalGepInsideSCC = false;
502 // if this edge is inside scc, then remove this edge and two end nodes
503 while(!sccEdges.empty())
504 {
505 ConstraintEdge* edge = sccEdges.back();
506 sccEdges.pop_back();
508 if(SVFUtil::isa<CopyCGEdge>(edge))
510 else if (SVFUtil::isa<GepCGEdge>(edge))
511 {
512 // If the GEP is critical (i.e. may have a non-zero offset),
513 // then it brings impact on field-sensitivity.
515 {
517 }
519 }
520 else if(SVFUtil::isa<LoadCGEdge, StoreCGEdge>(edge))
522 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
523 {
525 }
526 else
527 assert(false && "no such edge");
528 }
530}
531
537{
538
539 std::vector<ConstraintEdge*> sccEdges;
540 std::vector<ConstraintEdge*> nonSccEdges;
541
542 for (ConstraintNode::const_iterator it = node->OutEdgeBegin(), eit = node->OutEdgeEnd(); it != eit;
543 ++it)
544 {
546 if(sccRepNode(subOutEdge->getDstID()) != rep->getId())
547 nonSccEdges.push_back(subOutEdge);
548 else
549 {
550 sccEdges.push_back(subOutEdge);
551 }
552 }
553 // if this edge is outside scc, then re-target edge src to rep
554 while(!nonSccEdges.empty())
555 {
557 nonSccEdges.pop_back();
559 }
560 bool criticalGepInsideSCC = false;
561 // if this edge is inside scc, then remove this edge and two end nodes
562 while(!sccEdges.empty())
563 {
564 ConstraintEdge* edge = sccEdges.back();
565 sccEdges.pop_back();
567 if(SVFUtil::isa<CopyCGEdge>(edge))
569 else if (SVFUtil::isa<GepCGEdge>(edge))
570 {
571 // If the GEP is critical (i.e. may have a non-zero offset),
572 // then it brings impact on field-sensitivity.
574 {
576 }
578 }
579 else if(SVFUtil::isa<LoadCGEdge, StoreCGEdge>(edge))
581 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
582 {
584 }
585 else
586 assert(false && "no such edge");
587 }
589}
590
591
596{
598}
599
604{
605
606 outs() << "-----------------ConstraintGraph--------------------------------------\n";
607
609 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = addrs.begin(),
610 eiter = addrs.end(); iter != eiter; ++iter)
611 {
612 outs() << (*iter)->getSrcID() << " -- Addr --> " << (*iter)->getDstID()
613 << "\n";
614 }
615
617 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = directs.begin(),
618 eiter = directs.end(); iter != eiter; ++iter)
619 {
620 if (CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(*iter))
621 {
622 outs() << copy->getSrcID() << " -- Copy --> " << copy->getDstID()
623 << "\n";
624 }
625 else if (NormalGepCGEdge* ngep = SVFUtil::dyn_cast<NormalGepCGEdge>(*iter))
626 {
627 outs() << ngep->getSrcID() << " -- NormalGep (" << ngep->getConstantFieldIdx()
628 << ") --> " << ngep->getDstID() << "\n";
629 }
630 else if (VariantGepCGEdge* vgep = SVFUtil::dyn_cast<VariantGepCGEdge>(*iter))
631 {
632 outs() << vgep->getSrcID() << " -- VarintGep --> "
633 << vgep->getDstID() << "\n";
634 }
635 else
636 assert(false && "wrong constraint edge kind!");
637 }
638
640 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = loads.begin(),
641 eiter = loads.end(); iter != eiter; ++iter)
642 {
643 outs() << (*iter)->getSrcID() << " -- Load --> " << (*iter)->getDstID()
644 << "\n";
645 }
646
648 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = stores.begin(),
649 eiter = stores.end(); iter != eiter; ++iter)
650 {
651 outs() << (*iter)->getSrcID() << " -- Store --> " << (*iter)->getDstID()
652 << "\n";
653 }
654
655 outs()
656 << "--------------------------------------------------------------\n";
657
658}
659
664{
665 SVF::ViewGraph(this, "Constraint Graph");
666}
667
669
671{
672 if (Options::DetectPWC())
673 return directOutEdges.begin();
674 else
675 return copyOutEdges.begin();
676}
677
679{
680 if (Options::DetectPWC())
681 return directOutEdges.end();
682 else
683 return copyOutEdges.end();
684}
685
687{
688 if (Options::DetectPWC())
689 return directInEdges.begin();
690 else
691 return copyInEdges.begin();
692}
693
695{
696 if (Options::DetectPWC())
697 return directInEdges.end();
698 else
699 return copyInEdges.end();
700}
701
703{
704 if (Options::DetectPWC())
705 return directOutEdges.begin();
706 else
707 return copyOutEdges.begin();
708}
709
711{
712 if (Options::DetectPWC())
713 return directOutEdges.end();
714 else
715 return copyOutEdges.end();
716}
717
719{
720 if (Options::DetectPWC())
721 return directInEdges.begin();
722 else
723 return copyInEdges.begin();
724}
725
727{
728 if (Options::DetectPWC())
729 return directInEdges.end();
730 else
731 return copyInEdges.end();
732}
734
735const std::string ConstraintNode::toString() const
736{
737 return SVFIR::getPAG()->getSVFVar(getId())->toString();
738}
739
743namespace SVF
744{
745template<>
747{
748
750 DOTGraphTraits(bool isSimple = false) :
751 DOTGraphTraits<SVFIR*>(isSimple)
752 {
753 }
754
756 static std::string getGraphName(ConstraintGraph*)
757 {
758 return "ConstraintG";
759 }
760
762 {
763 if (Options::ShowHiddenNode()) return false;
764 else return (n->getInEdges().empty() && n->getOutEdges().empty());
765 }
766
769 static std::string getNodeLabel(NodeType *n, ConstraintGraph*)
770 {
771 const SVFVar* node = SVFIR::getPAG()->getSVFVar(n->getId());
773 bool nameDisplay = true;
774 std::string str;
775 std::stringstream rawstr(str);
776
777 if (briefDisplay)
778 {
779 if (SVFUtil::isa<ValVar>(node))
780 {
781 if (nameDisplay)
782 rawstr << node->getId() << ":" << node->getName();
783 else
784 rawstr << node->getId();
785 }
786 else
787 rawstr << node->getId();
788 }
789 else
790 {
791 // print the whole value
792 if (!SVFUtil::isa<DummyValVar>(node) && !SVFUtil::isa<DummyObjVar>(node))
793 rawstr << node->toString();
794 else
795 rawstr << node->getId() << ":";
796
797 }
798
799 return rawstr.str();
800 }
801
803 {
804 const SVFVar* node = SVFIR::getPAG()->getSVFVar(n->getId());
805 if (SVFUtil::isa<ValVar>(node))
806 {
807 if(SVFUtil::isa<GepValVar>(node))
808 return "shape=hexagon";
809 else if (SVFUtil::isa<DummyValVar>(node))
810 return "shape=diamond";
811 else
812 return "shape=box";
813 }
814 else if (SVFUtil::isa<ObjVar>(node))
815 {
816 if(SVFUtil::isa<GepObjVar>(node))
817 return "shape=doubleoctagon";
818 else if(SVFUtil::isa<BaseObjVar>(node))
819 return "shape=box3d";
820 else if (SVFUtil::isa<DummyObjVar>(node))
821 return "shape=tab";
822 else
823 return "shape=component";
824 }
825 else if (SVFUtil::isa<RetValPN>(node))
826 {
827 return "shape=Mrecord";
828 }
829 else if (SVFUtil::isa<VarArgValPN>(node))
830 {
831 return "shape=octagon";
832 }
833 else
834 {
835 assert(0 && "no such kind!!");
836 }
837 return "";
838 }
839
840 template<class EdgeIter>
842 {
843 ConstraintEdge* edge = *(EI.getCurrent());
844 assert(edge && "No edge found!!");
845 if (edge->getEdgeKind() == ConstraintEdge::Addr)
846 {
847 return "color=green";
848 }
849 else if (edge->getEdgeKind() == ConstraintEdge::Copy)
850 {
851 return "color=black";
852 }
853 else if (edge->getEdgeKind() == ConstraintEdge::NormalGep
854 || edge->getEdgeKind() == ConstraintEdge::VariantGep)
855 {
856 return "color=\"purple:purple\"";
857 }
858 else if (edge->getEdgeKind() == ConstraintEdge::Store)
859 {
860 return "color=blue";
861 }
862 else if (edge->getEdgeKind() == ConstraintEdge::Load)
863 {
864 return "color=red";
865 }
866 else
867 {
868 assert(0 && "No such kind edge!!");
869 }
870 return "";
871 }
872
873 template<class EdgeIter>
875 {
876 return "";
877 }
878};
879} // End namespace llvm
copy vgep
Definition PAGGrammar.txt:9
copy
Definition cJSON.cpp:414
cJSON * n
Definition cJSON.cpp:2558
const char *const name
Definition cJSON.h:264
AddrCGEdge()
place holder
GenericNode< ConstraintNode, ConstraintEdge >::GEdgeSetTy ConstraintEdgeSetTy
Constraint edge type.
Definition ConsGEdge.h:85
bool moveInEdgesToRepNode(ConstraintNode *node, ConstraintNode *rep)
Definition ConsG.cpp:478
ConstraintEdge::ConstraintEdgeSetTy StoreCGEdgeSet
Definition ConsG.h:64
ConstraintEdge::ConstraintEdgeSetTy directEdgeSet
Definition ConsG.h:62
ConstraintEdge::ConstraintEdgeSetTy LoadCGEdgeSet
Definition ConsG.h:63
LoadCGEdge * addLoadCGEdge(NodeID src, NodeID dst)
Add Load edge.
Definition ConsG.cpp:292
void view()
View graph from the debugger.
Definition ConsG.cpp:663
NodeID sccRepNode(NodeID id) const
SCC rep/sub nodes methods.
Definition ConsG.h:230
ConstraintEdge::ConstraintEdgeSetTy & getStoreCGEdges()
Get Store edges.
Definition ConsG.h:206
ConstraintEdge::ConstraintEdgeSetTy & getDirectCGEdges()
Get Copy/call/ret/gep edges.
Definition ConsG.h:196
void reTargetDstOfEdge(ConstraintEdge *edge, ConstraintNode *newDstNode)
Used for cycle elimination.
Definition ConsG.cpp:339
AddrCGEdge * addAddrCGEdge(NodeID src, NodeID dst)
Add a SVFIR edge into Edge map.
Definition ConsG.cpp:206
ConstraintEdge::ConstraintEdgeSetTy AddrCGEdgeSet
Definition ConsG.h:61
void addConstraintNode(ConstraintNode *node, NodeID id)
Definition ConsG.h:109
bool hasEdge(ConstraintNode *src, ConstraintNode *dst, ConstraintEdge::ConstraintEdgeK kind)
Definition ConsG.h:125
ConstraintEdge::ConstraintEdgeSetTy & getLoadCGEdges()
Get Load edges.
Definition ConsG.h:201
CopyCGEdge * addCopyCGEdge(NodeID src, NodeID dst)
Add Copy edge.
Definition ConsG.cpp:226
StoreCGEdge * addStoreCGEdge(NodeID src, NodeID dst)
Add Store edge.
Definition ConsG.cpp:313
VariantGepCGEdge * addVariantGepCGEdge(NodeID src, NodeID dst)
Definition ConsG.cpp:271
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Definition ConsG.h:72
void removeConstraintNode(ConstraintNode *node)
Definition ConsG.h:118
void removeDirectEdge(ConstraintEdge *edge)
Remove direct edge from their src and dst edge sets.
Definition ConsG.cpp:463
bool moveOutEdgesToRepNode(ConstraintNode *node, ConstraintNode *rep)
Definition ConsG.cpp:536
void removeLoadEdge(LoadCGEdge *edge)
Remove load edge from their src and dst edge sets.
Definition ConsG.cpp:437
ConstraintNode * getConstraintNode(NodeID id) const
Get/add/remove constraint node.
Definition ConsG.h:104
void print()
Print CG into terminal.
Definition ConsG.cpp:603
void reTargetSrcOfEdge(ConstraintEdge *edge, ConstraintNode *newSrcNode)
Remove edge from old src target, change edge dst id and add modified edge into new src.
Definition ConsG.cpp:383
void removeStoreEdge(StoreCGEdge *edge)
Remove store edge from their src and dst edge sets.
Definition ConsG.cpp:450
NormalGepCGEdge * addNormalGepCGEdge(NodeID src, NodeID dst, const AccessPath &ap)
Add Gep edge.
Definition ConsG.cpp:249
ConstraintEdge::ConstraintEdgeSetTy & getAddrCGEdges()
Get SVFIR edge.
Definition ConsG.h:191
void removeAddrEdge(AddrCGEdge *edge)
Remove addr edge from their src and dst edge sets.
Definition ConsG.cpp:424
bool isZeroOffsettedGepCGEdge(ConstraintEdge *edge) const
Check if a given edge is a NormalGepCGEdge with 0 offset.
Definition ConsG.h:289
void dump(std::string name)
Dump graph into dot file.
Definition ConsG.cpp:595
ConstraintEdge::ConstraintEdgeSetTy copyOutEdges
Definition ConsGNode.h:61
ConstraintEdge::ConstraintEdgeSetTy::iterator iterator
Definition ConsGNode.h:44
iterator directInEdgeEnd()
Definition ConsG.cpp:694
bool removeOutgoingStoreEdge(StoreCGEdge *outEdge)
Definition ConsGNode.h:367
bool removeIncomingStoreEdge(StoreCGEdge *inEdge)
Definition ConsGNode.h:376
ConstraintEdge::ConstraintEdgeSetTy copyInEdges
Definition ConsGNode.h:60
ConstraintEdge::ConstraintEdgeSetTy directInEdges
Definition ConsGNode.h:57
bool removeIncomingAddrEdge(AddrCGEdge *inEdge)
Definition ConsGNode.h:314
virtual const std::string toString() const
Definition ConsG.cpp:735
bool removeOutgoingDirectEdge(ConstraintEdge *outEdge)
Definition ConsGNode.h:323
bool removeIncomingDirectEdge(ConstraintEdge *inEdge)
Definition ConsGNode.h:336
bool removeOutgoingLoadEdge(LoadCGEdge *outEdge)
Definition ConsGNode.h:349
iterator directInEdgeBegin()
Definition ConsG.cpp:686
bool removeIncomingLoadEdge(LoadCGEdge *inEdge)
Definition ConsGNode.h:358
iterator directOutEdgeEnd()
Definition ConsG.cpp:678
ConstraintEdge::ConstraintEdgeSetTy::const_iterator const_iterator
Definition ConsGNode.h:45
bool removeOutgoingAddrEdge(AddrCGEdge *outEdge)
Remove constraint graph edges.
Definition ConsGNode.h:305
iterator directOutEdgeBegin()
Iterators.
Definition ConsG.cpp:670
ConstraintEdge::ConstraintEdgeSetTy directOutEdges
Definition ConsGNode.h:58
iterator begin()
Iterators.
IDToNodeMapTy::iterator iterator
Node Iterators.
iterator OutEdgeEnd()
iterator OutEdgeBegin()
iterators
iterator InEdgeBegin()
iterator InEdgeEnd()
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType &GT, bool simple=false)
NodeID getOpVarID(u32_t pos) const
NodeID getResID() const
u32_t getOpVarNum() const
static const Option< bool > BriefConsCGDotGraph
Definition Options.h:199
static Option< bool > DetectPWC
Definition Options.h:206
static const Option< bool > ShowHiddenNode
Definition Options.h:218
const ValVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
Definition SVFIR.h:407
static bool pagReadFromTXT()
Definition SVFIR.h:280
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
Definition SVFIR.h:453
const SVFVar * getSVFVar(NodeID id) const
ObjVar/GepObjVar/BaseObjVar.
Definition SVFIR.h:135
bool callsiteHasRet(const RetICFGNode *cs) const
Definition SVFIR.h:413
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:120
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.
virtual const std::string toString() const
Get string representation.
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52
for isBitcode
Definition BasicTypes.h:70
Set< NodeID > NodeSet
Definition GeneralType.h:87
u32_t NodeID
Definition GeneralType.h:76
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
unsigned u32_t
Definition GeneralType.h:67
u32_t EdgeID
Definition GeneralType.h:77
static std::string getNodeAttributes(NodeType *n, ConstraintGraph *)
Definition ConsG.cpp:802
static std::string getEdgeSourceLabel(NodeType *, EdgeIter)
Definition ConsG.cpp:874
static std::string getGraphName(ConstraintGraph *)
Return name of the graph.
Definition ConsG.cpp:756
static std::string getEdgeAttributes(NodeType *, EdgeIter EI, ConstraintGraph *)
Definition ConsG.cpp:841
static std::string getNodeLabel(NodeType *n, ConstraintGraph *)
Definition ConsG.cpp:769
static bool isNodeHidden(NodeType *n, ConstraintGraph *)
Definition ConsG.cpp:761
DOTGraphTraits(bool isSimple=false)
Definition ConsG.cpp:750