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 "Util/Options.h"
32
33using namespace SVF;
34using namespace SVFUtil;
35
36
41{
42
43 // initialize nodes
44 for(SVFIR::iterator it = pag->begin(), eit = pag->end(); it!=eit; ++it)
45 {
46 addConstraintNode(new ConstraintNode(it->first), it->first);
47 }
48
49 // initialize edges
51 for (SVFStmt::SVFStmtSetTy::iterator iter = addrs.begin(), eiter =
52 addrs.end(); iter != eiter; ++iter)
53 {
54 const AddrStmt* edge = SVFUtil::cast<AddrStmt>(*iter);
55 addAddrCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
56 }
57
59 for (SVFStmt::SVFStmtSetTy::iterator iter = copys.begin(), eiter =
60 copys.end(); iter != eiter; ++iter)
61 {
62 const CopyStmt* edge = SVFUtil::cast<CopyStmt>(*iter);
63 if(edge->isBitCast() || edge->isValueCopy())
64 addCopyCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
65 }
66
68 for (SVFStmt::SVFStmtSetTy::iterator iter = phis.begin(), eiter =
69 phis.end(); iter != eiter; ++iter)
70 {
71 const PhiStmt* edge = SVFUtil::cast<PhiStmt>(*iter);
72 for(const auto opVar : edge->getOpndVars())
73 addCopyCGEdge(opVar->getId(),edge->getResID());
74 }
75
77 for (SVFStmt::SVFStmtSetTy::iterator iter = selects.begin(), eiter =
78 selects.end(); iter != eiter; ++iter)
79 {
80 const SelectStmt* edge = SVFUtil::cast<SelectStmt>(*iter);
81 for(const auto opVar : edge->getOpndVars())
82 addCopyCGEdge(opVar->getId(),edge->getResID());
83 }
84
86 for (SVFStmt::SVFStmtSetTy::iterator iter = calls.begin(), eiter =
87 calls.end(); iter != eiter; ++iter)
88 {
89 const CallPE* callPE = SVFUtil::cast<CallPE>(*iter);
90 for(u32_t i = 0; i < callPE->getOpVarNum(); i++)
91 addCopyCGEdge(callPE->getOpVarID(i), callPE->getResID());
92 }
93
95 for (SVFStmt::SVFStmtSetTy::iterator iter = rets.begin(), eiter =
96 rets.end(); iter != eiter; ++iter)
97 {
98 const RetPE* edge = SVFUtil::cast<RetPE>(*iter);
99 addCopyCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
100 }
101
103 for (SVFStmt::SVFStmtSetTy::iterator iter = tdfks.begin(), eiter =
104 tdfks.end(); iter != eiter; ++iter)
105 {
106 const TDForkPE* forkPE = SVFUtil::cast<TDForkPE>(*iter);
107 for(u32_t i = 0; i < forkPE->getOpVarNum(); i++)
108 addCopyCGEdge(forkPE->getOpVarID(i), forkPE->getResID());
109 }
110
112 for (SVFStmt::SVFStmtSetTy::iterator iter = tdjns.begin(), eiter =
113 tdjns.end(); iter != eiter; ++iter)
114 {
115 const TDJoinPE* edge = SVFUtil::cast<TDJoinPE>(*iter);
116 addCopyCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
117 }
118
120 for (SVFStmt::SVFStmtSetTy::iterator iter = ngeps.begin(), eiter =
121 ngeps.end(); iter != eiter; ++iter)
122 {
123 GepStmt* edge = SVFUtil::cast<GepStmt>(*iter);
124 if(edge->isVariantFieldGep())
125 addVariantGepCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
126 else
127 addNormalGepCGEdge(edge->getRHSVarID(),edge->getLHSVarID(),edge->getAccessPath());
128 }
129
131 for (SVFStmt::SVFStmtSetTy::iterator iter = loads.begin(), eiter =
132 loads.end(); iter != eiter; ++iter)
133 {
134 LoadStmt* edge = SVFUtil::cast<LoadStmt>(*iter);
135 addLoadCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
136 }
137
139 for (SVFStmt::SVFStmtSetTy::iterator iter = stores.begin(), eiter =
140 stores.end(); iter != eiter; ++iter)
141 {
142 StoreStmt* edge = SVFUtil::cast<StoreStmt>(*iter);
143 addStoreCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
144 }
145
147}
148
153{
156 for(auto cs_pair : pag->getIndirectCallsites())
157 {
158 const RetICFGNode* retBlockNode = cs_pair.first->getRetICFGNode();
161 }
162
164 for (auto it = this->begin(); it != this->end(); ++it)
165 {
166 if (it->second->hasIncomingEdge() || it->second->hasOutgoingEdge())
167 continue;
168 if (pag->getSVFVar(it->first)->isPointer())
169 continue;
170 if (retFromIndCalls.find(it->first)!=retFromIndCalls.end())
171 continue;
172 nodesToRemove.insert(it->second);
173 }
174
175 for (auto node : nodesToRemove)
177}
178
185
190 : ConstraintEdge(s,d,Addr,id)
191{
192 // Retarget addr edges may lead s to be a dummy node
193 const SVFVar* node = SVFIR::getPAG()->getSVFVar(s->getId());
195 {
196 assert(!SVFUtil::isa<DummyValVar>(node) && "a dummy node??");
197 }
198}
199
204{
208 return nullptr;
210
211 bool inserted = AddrCGEdgeSet.insert(edge).second;
212 (void)inserted; // Suppress warning of unused variable under release build
213 assert(inserted && "new AddrCGEdge not added??");
214
215 srcNode->addOutgoingAddrEdge(edge);
216 dstNode->addIncomingAddrEdge(edge);
217 return edge;
218}
219
224{
225
229 return nullptr;
230
232
233 bool inserted = directEdgeSet.insert(edge).second;
234 (void)inserted; // Suppress warning of unused variable under release build
235 assert(inserted && "new CopyCGEdge not added??");
236
237 srcNode->addOutgoingCopyEdge(edge);
238 dstNode->addIncomingCopyEdge(edge);
239 return edge;
240}
241
242
247{
251 return nullptr;
252
255
256 bool inserted = directEdgeSet.insert(edge).second;
257 (void)inserted; // Suppress warning of unused variable under release build
258 assert(inserted && "new NormalGepCGEdge not added??");
259
260 srcNode->addOutgoingGepEdge(edge);
261 dstNode->addIncomingGepEdge(edge);
262 return edge;
263}
264
269{
273 return nullptr;
274
276
277 bool inserted = directEdgeSet.insert(edge).second;
278 (void)inserted; // Suppress warning of unused variable under release build
279 assert(inserted && "new VariantGepCGEdge not added??");
280
281 srcNode->addOutgoingGepEdge(edge);
282 dstNode->addIncomingGepEdge(edge);
283 return edge;
284}
285
290{
294 return nullptr;
295
297
298 bool inserted = LoadCGEdgeSet.insert(edge).second;
299 (void)inserted; // Suppress warning of unused variable under release build
300 assert(inserted && "new LoadCGEdge not added??");
301
302 srcNode->addOutgoingLoadEdge(edge);
303 dstNode->addIncomingLoadEdge(edge);
304 return edge;
305}
306
311{
315 return nullptr;
316
318
319 bool inserted = StoreCGEdgeSet.insert(edge).second;
320 (void)inserted; // Suppress warning of unused variable under release build
321 assert(inserted && "new StoreCGEdge not added??");
322
323 srcNode->addOutgoingStoreEdge(edge);
324 dstNode->addIncomingStoreEdge(edge);
325 return edge;
326}
327
328
337{
338 NodeID newDstNodeID = newDstNode->getId();
339 NodeID srcId = edge->getSrcID();
340 if(LoadCGEdge* load = SVFUtil::dyn_cast<LoadCGEdge>(edge))
341 {
342 removeLoadEdge(load);
344 }
345 else if(StoreCGEdge* store = SVFUtil::dyn_cast<StoreCGEdge>(edge))
346 {
347 removeStoreEdge(store);
349 }
350 else if(CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(edge))
351 {
354 }
355 else if(NormalGepCGEdge* gep = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
356 {
357 const AccessPath ap = gep->getAccessPath();
360 }
361 else if(VariantGepCGEdge* gep = SVFUtil::dyn_cast<VariantGepCGEdge>(edge))
362 {
365 }
366 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
367 {
369 }
370 else
371 assert(false && "no other edge type!!");
372}
373
381{
382 NodeID newSrcNodeID = newSrcNode->getId();
383 NodeID dstId = edge->getDstID();
384 if(LoadCGEdge* load = SVFUtil::dyn_cast<LoadCGEdge>(edge))
385 {
386 removeLoadEdge(load);
388 }
389 else if(StoreCGEdge* store = SVFUtil::dyn_cast<StoreCGEdge>(edge))
390 {
391 removeStoreEdge(store);
393 }
394 else if(CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(edge))
395 {
398 }
399 else if(NormalGepCGEdge* gep = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
400 {
401 const AccessPath ap = gep->getAccessPath();
404 }
405 else if(VariantGepCGEdge* gep = SVFUtil::dyn_cast<VariantGepCGEdge>(edge))
406 {
409 }
410 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
411 {
413 }
414 else
415 assert(false && "no other edge type!!");
416}
417
422{
425 u32_t num = AddrCGEdgeSet.erase(edge);
426 (void)num; // Suppress warning of unused variable under release build
427 assert(num && "edge not in the set, can not remove!!!");
428 delete edge;
429}
430
435{
438 u32_t num = LoadCGEdgeSet.erase(edge);
439 (void)num; // Suppress warning of unused variable under release build
440 assert(num && "edge not in the set, can not remove!!!");
441 delete edge;
442}
443
448{
451 u32_t num = StoreCGEdgeSet.erase(edge);
452 (void)num; // Suppress warning of unused variable under release build
453 assert(num && "edge not in the set, can not remove!!!");
454 delete edge;
455}
456
461{
462
465 u32_t num = directEdgeSet.erase(edge);
466 (void)num; // Suppress warning of unused variable under release build
467 assert(num && "edge not in the set, can not remove!!!");
468 delete edge;
469}
470
476{
477 std::vector<ConstraintEdge*> sccEdges;
478 std::vector<ConstraintEdge*> nonSccEdges;
479 for (ConstraintNode::const_iterator it = node->InEdgeBegin(), eit = node->InEdgeEnd(); it != eit;
480 ++it)
481 {
483 if(sccRepNode(subInEdge->getSrcID()) != rep->getId())
484 nonSccEdges.push_back(subInEdge);
485 else
486 {
487 sccEdges.push_back(subInEdge);
488 }
489 }
490 // if this edge is outside scc, then re-target edge dst to rep
491 while(!nonSccEdges.empty())
492 {
494 nonSccEdges.pop_back();
496 }
497
498 bool criticalGepInsideSCC = false;
499 // if this edge is inside scc, then remove this edge and two end nodes
500 while(!sccEdges.empty())
501 {
502 ConstraintEdge* edge = sccEdges.back();
503 sccEdges.pop_back();
505 if(SVFUtil::isa<CopyCGEdge>(edge))
507 else if (SVFUtil::isa<GepCGEdge>(edge))
508 {
509 // If the GEP is critical (i.e. may have a non-zero offset),
510 // then it brings impact on field-sensitivity.
512 {
514 }
516 }
517 else if(SVFUtil::isa<LoadCGEdge, StoreCGEdge>(edge))
519 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
520 {
522 }
523 else
524 assert(false && "no such edge");
525 }
527}
528
534{
535
536 std::vector<ConstraintEdge*> sccEdges;
537 std::vector<ConstraintEdge*> nonSccEdges;
538
539 for (ConstraintNode::const_iterator it = node->OutEdgeBegin(), eit = node->OutEdgeEnd(); it != eit;
540 ++it)
541 {
543 if(sccRepNode(subOutEdge->getDstID()) != rep->getId())
544 nonSccEdges.push_back(subOutEdge);
545 else
546 {
547 sccEdges.push_back(subOutEdge);
548 }
549 }
550 // if this edge is outside scc, then re-target edge src to rep
551 while(!nonSccEdges.empty())
552 {
554 nonSccEdges.pop_back();
556 }
557 bool criticalGepInsideSCC = false;
558 // if this edge is inside scc, then remove this edge and two end nodes
559 while(!sccEdges.empty())
560 {
561 ConstraintEdge* edge = sccEdges.back();
562 sccEdges.pop_back();
564 if(SVFUtil::isa<CopyCGEdge>(edge))
566 else if (SVFUtil::isa<GepCGEdge>(edge))
567 {
568 // If the GEP is critical (i.e. may have a non-zero offset),
569 // then it brings impact on field-sensitivity.
571 {
573 }
575 }
576 else if(SVFUtil::isa<LoadCGEdge, StoreCGEdge>(edge))
578 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
579 {
581 }
582 else
583 assert(false && "no such edge");
584 }
586}
587
588
593{
595}
596
601{
602
603 outs() << "-----------------ConstraintGraph--------------------------------------\n";
604
606 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = addrs.begin(),
607 eiter = addrs.end(); iter != eiter; ++iter)
608 {
609 outs() << (*iter)->getSrcID() << " -- Addr --> " << (*iter)->getDstID()
610 << "\n";
611 }
612
614 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = directs.begin(),
615 eiter = directs.end(); iter != eiter; ++iter)
616 {
617 if (CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(*iter))
618 {
619 outs() << copy->getSrcID() << " -- Copy --> " << copy->getDstID()
620 << "\n";
621 }
622 else if (NormalGepCGEdge* ngep = SVFUtil::dyn_cast<NormalGepCGEdge>(*iter))
623 {
624 outs() << ngep->getSrcID() << " -- NormalGep (" << ngep->getConstantFieldIdx()
625 << ") --> " << ngep->getDstID() << "\n";
626 }
627 else if (VariantGepCGEdge* vgep = SVFUtil::dyn_cast<VariantGepCGEdge>(*iter))
628 {
629 outs() << vgep->getSrcID() << " -- VarintGep --> "
630 << vgep->getDstID() << "\n";
631 }
632 else
633 assert(false && "wrong constraint edge kind!");
634 }
635
637 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = loads.begin(),
638 eiter = loads.end(); iter != eiter; ++iter)
639 {
640 outs() << (*iter)->getSrcID() << " -- Load --> " << (*iter)->getDstID()
641 << "\n";
642 }
643
645 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = stores.begin(),
646 eiter = stores.end(); iter != eiter; ++iter)
647 {
648 outs() << (*iter)->getSrcID() << " -- Store --> " << (*iter)->getDstID()
649 << "\n";
650 }
651
652 outs()
653 << "--------------------------------------------------------------\n";
654
655}
656
661{
662 SVF::ViewGraph(this, "Constraint Graph");
663}
664
666
668{
669 if (Options::DetectPWC())
670 return directOutEdges.begin();
671 else
672 return copyOutEdges.begin();
673}
674
676{
677 if (Options::DetectPWC())
678 return directOutEdges.end();
679 else
680 return copyOutEdges.end();
681}
682
684{
685 if (Options::DetectPWC())
686 return directInEdges.begin();
687 else
688 return copyInEdges.begin();
689}
690
692{
693 if (Options::DetectPWC())
694 return directInEdges.end();
695 else
696 return copyInEdges.end();
697}
698
700{
701 if (Options::DetectPWC())
702 return directOutEdges.begin();
703 else
704 return copyOutEdges.begin();
705}
706
708{
709 if (Options::DetectPWC())
710 return directOutEdges.end();
711 else
712 return copyOutEdges.end();
713}
714
716{
717 if (Options::DetectPWC())
718 return directInEdges.begin();
719 else
720 return copyInEdges.begin();
721}
722
724{
725 if (Options::DetectPWC())
726 return directInEdges.end();
727 else
728 return copyInEdges.end();
729}
731
732const std::string ConstraintNode::toString() const
733{
734 return SVFIR::getPAG()->getSVFVar(getId())->toString();
735}
736
740namespace SVF
741{
742template<>
744{
745
747 DOTGraphTraits(bool isSimple = false) :
748 DOTGraphTraits<SVFIR*>(isSimple)
749 {
750 }
751
753 static std::string getGraphName(ConstraintGraph*)
754 {
755 return "ConstraintG";
756 }
757
759 {
760 if (Options::ShowHiddenNode()) return false;
761 else return (n->getInEdges().empty() && n->getOutEdges().empty());
762 }
763
766 static std::string getNodeLabel(NodeType *n, ConstraintGraph*)
767 {
768 const SVFVar* node = SVFIR::getPAG()->getSVFVar(n->getId());
770 bool nameDisplay = true;
771 std::string str;
772 std::stringstream rawstr(str);
773
774 if (briefDisplay)
775 {
776 if (SVFUtil::isa<ValVar>(node))
777 {
778 if (nameDisplay)
779 rawstr << node->getId() << ":" << node->getName();
780 else
781 rawstr << node->getId();
782 }
783 else
784 rawstr << node->getId();
785 }
786 else
787 {
788 // print the whole value
789 if (!SVFUtil::isa<DummyValVar>(node) && !SVFUtil::isa<DummyObjVar>(node))
790 rawstr << node->toString();
791 else
792 rawstr << node->getId() << ":";
793
794 }
795
796 return rawstr.str();
797 }
798
800 {
801 const SVFVar* node = SVFIR::getPAG()->getSVFVar(n->getId());
802 if (SVFUtil::isa<ValVar>(node))
803 {
804 if(SVFUtil::isa<GepValVar>(node))
805 return "shape=hexagon";
806 else if (SVFUtil::isa<DummyValVar>(node))
807 return "shape=diamond";
808 else
809 return "shape=box";
810 }
811 else if (SVFUtil::isa<ObjVar>(node))
812 {
813 if(SVFUtil::isa<GepObjVar>(node))
814 return "shape=doubleoctagon";
815 else if(SVFUtil::isa<BaseObjVar>(node))
816 return "shape=box3d";
817 else if (SVFUtil::isa<DummyObjVar>(node))
818 return "shape=tab";
819 else
820 return "shape=component";
821 }
822 else if (SVFUtil::isa<RetValPN>(node))
823 {
824 return "shape=Mrecord";
825 }
826 else if (SVFUtil::isa<VarArgValPN>(node))
827 {
828 return "shape=octagon";
829 }
830 else
831 {
832 assert(0 && "no such kind!!");
833 }
834 return "";
835 }
836
837 template<class EdgeIter>
839 {
840 ConstraintEdge* edge = *(EI.getCurrent());
841 assert(edge && "No edge found!!");
842 if (edge->getEdgeKind() == ConstraintEdge::Addr)
843 {
844 return "color=green";
845 }
846 else if (edge->getEdgeKind() == ConstraintEdge::Copy)
847 {
848 return "color=black";
849 }
850 else if (edge->getEdgeKind() == ConstraintEdge::NormalGep
851 || edge->getEdgeKind() == ConstraintEdge::VariantGep)
852 {
853 return "color=purple";
854 }
855 else if (edge->getEdgeKind() == ConstraintEdge::Store)
856 {
857 return "color=blue";
858 }
859 else if (edge->getEdgeKind() == ConstraintEdge::Load)
860 {
861 return "color=red";
862 }
863 else
864 {
865 assert(0 && "No such kind edge!!");
866 }
867 return "";
868 }
869
870 template<class EdgeIter>
872 {
873 return "";
874 }
875};
876} // 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:475
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:289
void view()
View graph from the debugger.
Definition ConsG.cpp:660
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:336
AddrCGEdge * addAddrCGEdge(NodeID src, NodeID dst)
Add a SVFIR edge into Edge map.
Definition ConsG.cpp:203
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:223
StoreCGEdge * addStoreCGEdge(NodeID src, NodeID dst)
Add Store edge.
Definition ConsG.cpp:310
VariantGepCGEdge * addVariantGepCGEdge(NodeID src, NodeID dst)
Definition ConsG.cpp:268
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:460
bool moveOutEdgesToRepNode(ConstraintNode *node, ConstraintNode *rep)
Definition ConsG.cpp:533
void removeLoadEdge(LoadCGEdge *edge)
Remove load edge from their src and dst edge sets.
Definition ConsG.cpp:434
ConstraintNode * getConstraintNode(NodeID id) const
Get/add/remove constraint node.
Definition ConsG.h:104
void print()
Print CG into terminal.
Definition ConsG.cpp:600
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:380
void removeStoreEdge(StoreCGEdge *edge)
Remove store edge from their src and dst edge sets.
Definition ConsG.cpp:447
NormalGepCGEdge * addNormalGepCGEdge(NodeID src, NodeID dst, const AccessPath &ap)
Add Gep edge.
Definition ConsG.cpp:246
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:421
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:592
ConstraintEdge::ConstraintEdgeSetTy copyOutEdges
Definition ConsGNode.h:61
ConstraintEdge::ConstraintEdgeSetTy::iterator iterator
Definition ConsGNode.h:44
iterator directInEdgeEnd()
Definition ConsG.cpp:691
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:732
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:683
bool removeIncomingLoadEdge(LoadCGEdge *inEdge)
Definition ConsGNode.h:358
iterator directOutEdgeEnd()
Definition ConsG.cpp:675
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:667
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:206
static Option< bool > DetectPWC
Definition Options.h:213
static const Option< bool > ShowHiddenNode
Definition Options.h:225
const ValVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
Definition SVFIR.h:405
static bool pagReadFromTXT()
Definition SVFIR.h:278
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
Definition SVFIR.h:451
const SVFVar * getSVFVar(NodeID id) const
ObjVar/GepObjVar/BaseObjVar.
Definition SVFIR.h:133
bool callsiteHasRet(const RetICFGNode *cs) const
Definition SVFIR.h:411
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:118
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
NodeID getId() const
Get ID.
Definition SVFValue.h:163
virtual const std::string & getName() const
Definition SVFValue.h:189
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
u32_t NodeID
Definition GeneralType.h:56
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:47
u32_t EdgeID
Definition GeneralType.h:57
static std::string getNodeAttributes(NodeType *n, ConstraintGraph *)
Definition ConsG.cpp:799
static std::string getEdgeSourceLabel(NodeType *, EdgeIter)
Definition ConsG.cpp:871
static std::string getGraphName(ConstraintGraph *)
Return name of the graph.
Definition ConsG.cpp:753
static std::string getEdgeAttributes(NodeType *, EdgeIter EI, ConstraintGraph *)
Definition ConsG.cpp:838
static std::string getNodeLabel(NodeType *n, ConstraintGraph *)
Definition ConsG.cpp:766
static bool isNodeHidden(NodeType *n, ConstraintGraph *)
Definition ConsG.cpp:758
DOTGraphTraits(bool isSimple=false)
Definition ConsG.cpp:747