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());
194 (void)node; // Suppress warning of unused variable under release build
196 {
197 assert(!SVFUtil::isa<DummyValVar>(node) && "a dummy node??");
198 }
199}
200
205{
209 return nullptr;
211
212 bool inserted = AddrCGEdgeSet.insert(edge).second;
213 (void)inserted; // Suppress warning of unused variable under release build
214 assert(inserted && "new AddrCGEdge not added??");
215
216 srcNode->addOutgoingAddrEdge(edge);
217 dstNode->addIncomingAddrEdge(edge);
218 return edge;
219}
220
225{
226
230 return nullptr;
231
233
234 bool inserted = directEdgeSet.insert(edge).second;
235 (void)inserted; // Suppress warning of unused variable under release build
236 assert(inserted && "new CopyCGEdge not added??");
237
238 srcNode->addOutgoingCopyEdge(edge);
239 dstNode->addIncomingCopyEdge(edge);
240 return edge;
241}
242
243
248{
252 return nullptr;
253
256
257 bool inserted = directEdgeSet.insert(edge).second;
258 (void)inserted; // Suppress warning of unused variable under release build
259 assert(inserted && "new NormalGepCGEdge not added??");
260
261 srcNode->addOutgoingGepEdge(edge);
262 dstNode->addIncomingGepEdge(edge);
263 return edge;
264}
265
270{
274 return nullptr;
275
277
278 bool inserted = directEdgeSet.insert(edge).second;
279 (void)inserted; // Suppress warning of unused variable under release build
280 assert(inserted && "new VariantGepCGEdge not added??");
281
282 srcNode->addOutgoingGepEdge(edge);
283 dstNode->addIncomingGepEdge(edge);
284 return edge;
285}
286
291{
295 return nullptr;
296
298
299 bool inserted = LoadCGEdgeSet.insert(edge).second;
300 (void)inserted; // Suppress warning of unused variable under release build
301 assert(inserted && "new LoadCGEdge not added??");
302
303 srcNode->addOutgoingLoadEdge(edge);
304 dstNode->addIncomingLoadEdge(edge);
305 return edge;
306}
307
312{
316 return nullptr;
317
319
320 bool inserted = StoreCGEdgeSet.insert(edge).second;
321 (void)inserted; // Suppress warning of unused variable under release build
322 assert(inserted && "new StoreCGEdge not added??");
323
324 srcNode->addOutgoingStoreEdge(edge);
325 dstNode->addIncomingStoreEdge(edge);
326 return edge;
327}
328
329
338{
339 NodeID newDstNodeID = newDstNode->getId();
340 NodeID srcId = edge->getSrcID();
341 if(LoadCGEdge* load = SVFUtil::dyn_cast<LoadCGEdge>(edge))
342 {
343 removeLoadEdge(load);
345 }
346 else if(StoreCGEdge* store = SVFUtil::dyn_cast<StoreCGEdge>(edge))
347 {
348 removeStoreEdge(store);
350 }
351 else if(CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(edge))
352 {
355 }
356 else if(NormalGepCGEdge* gep = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
357 {
358 const AccessPath ap = gep->getAccessPath();
361 }
362 else if(VariantGepCGEdge* gep = SVFUtil::dyn_cast<VariantGepCGEdge>(edge))
363 {
366 }
367 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
368 {
370 }
371 else
372 assert(false && "no other edge type!!");
373}
374
382{
383 NodeID newSrcNodeID = newSrcNode->getId();
384 NodeID dstId = edge->getDstID();
385 if(LoadCGEdge* load = SVFUtil::dyn_cast<LoadCGEdge>(edge))
386 {
387 removeLoadEdge(load);
389 }
390 else if(StoreCGEdge* store = SVFUtil::dyn_cast<StoreCGEdge>(edge))
391 {
392 removeStoreEdge(store);
394 }
395 else if(CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(edge))
396 {
399 }
400 else if(NormalGepCGEdge* gep = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
401 {
402 const AccessPath ap = gep->getAccessPath();
405 }
406 else if(VariantGepCGEdge* gep = SVFUtil::dyn_cast<VariantGepCGEdge>(edge))
407 {
410 }
411 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
412 {
414 }
415 else
416 assert(false && "no other edge type!!");
417}
418
423{
426 u32_t num = AddrCGEdgeSet.erase(edge);
427 (void)num; // Suppress warning of unused variable under release build
428 assert(num && "edge not in the set, can not remove!!!");
429 delete edge;
430}
431
436{
439 u32_t num = LoadCGEdgeSet.erase(edge);
440 (void)num; // Suppress warning of unused variable under release build
441 assert(num && "edge not in the set, can not remove!!!");
442 delete edge;
443}
444
449{
452 u32_t num = StoreCGEdgeSet.erase(edge);
453 (void)num; // Suppress warning of unused variable under release build
454 assert(num && "edge not in the set, can not remove!!!");
455 delete edge;
456}
457
462{
463
466 u32_t num = directEdgeSet.erase(edge);
467 (void)num; // Suppress warning of unused variable under release build
468 assert(num && "edge not in the set, can not remove!!!");
469 delete edge;
470}
471
477{
478 std::vector<ConstraintEdge*> sccEdges;
479 std::vector<ConstraintEdge*> nonSccEdges;
480 for (ConstraintNode::const_iterator it = node->InEdgeBegin(), eit = node->InEdgeEnd(); it != eit;
481 ++it)
482 {
484 if(sccRepNode(subInEdge->getSrcID()) != rep->getId())
485 nonSccEdges.push_back(subInEdge);
486 else
487 {
488 sccEdges.push_back(subInEdge);
489 }
490 }
491 // if this edge is outside scc, then re-target edge dst to rep
492 while(!nonSccEdges.empty())
493 {
495 nonSccEdges.pop_back();
497 }
498
499 bool criticalGepInsideSCC = false;
500 // if this edge is inside scc, then remove this edge and two end nodes
501 while(!sccEdges.empty())
502 {
503 ConstraintEdge* edge = sccEdges.back();
504 sccEdges.pop_back();
506 if(SVFUtil::isa<CopyCGEdge>(edge))
508 else if (SVFUtil::isa<GepCGEdge>(edge))
509 {
510 // If the GEP is critical (i.e. may have a non-zero offset),
511 // then it brings impact on field-sensitivity.
513 {
515 }
517 }
518 else if(SVFUtil::isa<LoadCGEdge, StoreCGEdge>(edge))
520 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
521 {
523 }
524 else
525 assert(false && "no such edge");
526 }
528}
529
535{
536
537 std::vector<ConstraintEdge*> sccEdges;
538 std::vector<ConstraintEdge*> nonSccEdges;
539
540 for (ConstraintNode::const_iterator it = node->OutEdgeBegin(), eit = node->OutEdgeEnd(); it != eit;
541 ++it)
542 {
544 if(sccRepNode(subOutEdge->getDstID()) != rep->getId())
545 nonSccEdges.push_back(subOutEdge);
546 else
547 {
548 sccEdges.push_back(subOutEdge);
549 }
550 }
551 // if this edge is outside scc, then re-target edge src to rep
552 while(!nonSccEdges.empty())
553 {
555 nonSccEdges.pop_back();
557 }
558 bool criticalGepInsideSCC = false;
559 // if this edge is inside scc, then remove this edge and two end nodes
560 while(!sccEdges.empty())
561 {
562 ConstraintEdge* edge = sccEdges.back();
563 sccEdges.pop_back();
565 if(SVFUtil::isa<CopyCGEdge>(edge))
567 else if (SVFUtil::isa<GepCGEdge>(edge))
568 {
569 // If the GEP is critical (i.e. may have a non-zero offset),
570 // then it brings impact on field-sensitivity.
572 {
574 }
576 }
577 else if(SVFUtil::isa<LoadCGEdge, StoreCGEdge>(edge))
579 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
580 {
582 }
583 else
584 assert(false && "no such edge");
585 }
587}
588
589
594{
596}
597
602{
603
604 outs() << "-----------------ConstraintGraph--------------------------------------\n";
605
607 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = addrs.begin(),
608 eiter = addrs.end(); iter != eiter; ++iter)
609 {
610 outs() << (*iter)->getSrcID() << " -- Addr --> " << (*iter)->getDstID()
611 << "\n";
612 }
613
615 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = directs.begin(),
616 eiter = directs.end(); iter != eiter; ++iter)
617 {
618 if (CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(*iter))
619 {
620 outs() << copy->getSrcID() << " -- Copy --> " << copy->getDstID()
621 << "\n";
622 }
623 else if (NormalGepCGEdge* ngep = SVFUtil::dyn_cast<NormalGepCGEdge>(*iter))
624 {
625 outs() << ngep->getSrcID() << " -- NormalGep (" << ngep->getConstantFieldIdx()
626 << ") --> " << ngep->getDstID() << "\n";
627 }
628 else if (VariantGepCGEdge* vgep = SVFUtil::dyn_cast<VariantGepCGEdge>(*iter))
629 {
630 outs() << vgep->getSrcID() << " -- VarintGep --> "
631 << vgep->getDstID() << "\n";
632 }
633 else
634 assert(false && "wrong constraint edge kind!");
635 }
636
638 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = loads.begin(),
639 eiter = loads.end(); iter != eiter; ++iter)
640 {
641 outs() << (*iter)->getSrcID() << " -- Load --> " << (*iter)->getDstID()
642 << "\n";
643 }
644
646 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = stores.begin(),
647 eiter = stores.end(); iter != eiter; ++iter)
648 {
649 outs() << (*iter)->getSrcID() << " -- Store --> " << (*iter)->getDstID()
650 << "\n";
651 }
652
653 outs()
654 << "--------------------------------------------------------------\n";
655
656}
657
662{
663 SVF::ViewGraph(this, "Constraint Graph");
664}
665
667
669{
670 if (Options::DetectPWC())
671 return directOutEdges.begin();
672 else
673 return copyOutEdges.begin();
674}
675
677{
678 if (Options::DetectPWC())
679 return directOutEdges.end();
680 else
681 return copyOutEdges.end();
682}
683
685{
686 if (Options::DetectPWC())
687 return directInEdges.begin();
688 else
689 return copyInEdges.begin();
690}
691
693{
694 if (Options::DetectPWC())
695 return directInEdges.end();
696 else
697 return copyInEdges.end();
698}
699
701{
702 if (Options::DetectPWC())
703 return directOutEdges.begin();
704 else
705 return copyOutEdges.begin();
706}
707
709{
710 if (Options::DetectPWC())
711 return directOutEdges.end();
712 else
713 return copyOutEdges.end();
714}
715
717{
718 if (Options::DetectPWC())
719 return directInEdges.begin();
720 else
721 return copyInEdges.begin();
722}
723
725{
726 if (Options::DetectPWC())
727 return directInEdges.end();
728 else
729 return copyInEdges.end();
730}
732
733const std::string ConstraintNode::toString() const
734{
735 return SVFIR::getPAG()->getSVFVar(getId())->toString();
736}
737
741namespace SVF
742{
743template<>
745{
746
748 DOTGraphTraits(bool isSimple = false) :
749 DOTGraphTraits<SVFIR*>(isSimple)
750 {
751 }
752
754 static std::string getGraphName(ConstraintGraph*)
755 {
756 return "ConstraintG";
757 }
758
760 {
761 if (Options::ShowHiddenNode()) return false;
762 else return (n->getInEdges().empty() && n->getOutEdges().empty());
763 }
764
767 static std::string getNodeLabel(NodeType *n, ConstraintGraph*)
768 {
769 const SVFVar* node = SVFIR::getPAG()->getSVFVar(n->getId());
771 bool nameDisplay = true;
772 std::string str;
773 std::stringstream rawstr(str);
774
775 if (briefDisplay)
776 {
777 if (SVFUtil::isa<ValVar>(node))
778 {
779 if (nameDisplay)
780 rawstr << node->getId() << ":" << node->getName();
781 else
782 rawstr << node->getId();
783 }
784 else
785 rawstr << node->getId();
786 }
787 else
788 {
789 // print the whole value
790 if (!SVFUtil::isa<DummyValVar>(node) && !SVFUtil::isa<DummyObjVar>(node))
791 rawstr << node->toString();
792 else
793 rawstr << node->getId() << ":";
794
795 }
796
797 return rawstr.str();
798 }
799
801 {
802 const SVFVar* node = SVFIR::getPAG()->getSVFVar(n->getId());
803 if (SVFUtil::isa<ValVar>(node))
804 {
805 if(SVFUtil::isa<GepValVar>(node))
806 return "shape=hexagon";
807 else if (SVFUtil::isa<DummyValVar>(node))
808 return "shape=diamond";
809 else
810 return "shape=box";
811 }
812 else if (SVFUtil::isa<ObjVar>(node))
813 {
814 if(SVFUtil::isa<GepObjVar>(node))
815 return "shape=doubleoctagon";
816 else if(SVFUtil::isa<BaseObjVar>(node))
817 return "shape=box3d";
818 else if (SVFUtil::isa<DummyObjVar>(node))
819 return "shape=tab";
820 else
821 return "shape=component";
822 }
823 else if (SVFUtil::isa<RetValPN>(node))
824 {
825 return "shape=Mrecord";
826 }
827 else if (SVFUtil::isa<VarArgValPN>(node))
828 {
829 return "shape=octagon";
830 }
831 else
832 {
833 assert(0 && "no such kind!!");
834 }
835 return "";
836 }
837
838 template<class EdgeIter>
840 {
841 ConstraintEdge* edge = *(EI.getCurrent());
842 assert(edge && "No edge found!!");
843 if (edge->getEdgeKind() == ConstraintEdge::Addr)
844 {
845 return "color=green";
846 }
847 else if (edge->getEdgeKind() == ConstraintEdge::Copy)
848 {
849 return "color=black";
850 }
851 else if (edge->getEdgeKind() == ConstraintEdge::NormalGep
852 || edge->getEdgeKind() == ConstraintEdge::VariantGep)
853 {
854 return "color=purple";
855 }
856 else if (edge->getEdgeKind() == ConstraintEdge::Store)
857 {
858 return "color=blue";
859 }
860 else if (edge->getEdgeKind() == ConstraintEdge::Load)
861 {
862 return "color=red";
863 }
864 else
865 {
866 assert(0 && "No such kind edge!!");
867 }
868 return "";
869 }
870
871 template<class EdgeIter>
873 {
874 return "";
875 }
876};
877} // 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:476
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:290
void view()
View graph from the debugger.
Definition ConsG.cpp:661
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:337
AddrCGEdge * addAddrCGEdge(NodeID src, NodeID dst)
Add a SVFIR edge into Edge map.
Definition ConsG.cpp:204
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:224
StoreCGEdge * addStoreCGEdge(NodeID src, NodeID dst)
Add Store edge.
Definition ConsG.cpp:311
VariantGepCGEdge * addVariantGepCGEdge(NodeID src, NodeID dst)
Definition ConsG.cpp:269
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:461
bool moveOutEdgesToRepNode(ConstraintNode *node, ConstraintNode *rep)
Definition ConsG.cpp:534
void removeLoadEdge(LoadCGEdge *edge)
Remove load edge from their src and dst edge sets.
Definition ConsG.cpp:435
ConstraintNode * getConstraintNode(NodeID id) const
Get/add/remove constraint node.
Definition ConsG.h:104
void print()
Print CG into terminal.
Definition ConsG.cpp:601
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:381
void removeStoreEdge(StoreCGEdge *edge)
Remove store edge from their src and dst edge sets.
Definition ConsG.cpp:448
NormalGepCGEdge * addNormalGepCGEdge(NodeID src, NodeID dst, const AccessPath &ap)
Add Gep edge.
Definition ConsG.cpp:247
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:422
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:593
ConstraintEdge::ConstraintEdgeSetTy copyOutEdges
Definition ConsGNode.h:61
ConstraintEdge::ConstraintEdgeSetTy::iterator iterator
Definition ConsGNode.h:44
iterator directInEdgeEnd()
Definition ConsG.cpp:692
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:733
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:684
bool removeIncomingLoadEdge(LoadCGEdge *inEdge)
Definition ConsGNode.h:358
iterator directOutEdgeEnd()
Definition ConsG.cpp:676
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:668
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:800
static std::string getEdgeSourceLabel(NodeType *, EdgeIter)
Definition ConsG.cpp:872
static std::string getGraphName(ConstraintGraph *)
Return name of the graph.
Definition ConsG.cpp:754
static std::string getEdgeAttributes(NodeType *, EdgeIter EI, ConstraintGraph *)
Definition ConsG.cpp:839
static std::string getNodeLabel(NodeType *n, ConstraintGraph *)
Definition ConsG.cpp:767
static bool isNodeHidden(NodeType *n, ConstraintGraph *)
Definition ConsG.cpp:759
DOTGraphTraits(bool isSimple=false)
Definition ConsG.cpp:748