diff --git a/svf/include/Graphs/BasicBlockG.h b/svf/include/Graphs/BasicBlockG.h index d655e3dd2..ef203f950 100644 --- a/svf/include/Graphs/BasicBlockG.h +++ b/svf/include/Graphs/BasicBlockG.h @@ -138,6 +138,12 @@ class SVFBasicBlock : public GenericBasicBlockNodeTy inline void addSuccBasicBlock(const SVFBasicBlock* succ2) { + // check if the edge already exists + for (auto edge: this->getOutEdges()) { + if (edge->getDstNode() == succ2) + return; + } + SVFBasicBlock* succ = const_cast(succ2); BasicBlockEdge* edge = new BasicBlockEdge(this, succ); this->addOutgoingEdge(edge); @@ -148,6 +154,11 @@ class SVFBasicBlock : public GenericBasicBlockNodeTy inline void addPredBasicBlock(const SVFBasicBlock* pred2) { + // check if the edge already exists + for (auto edge: this->getInEdges()) { + if (edge->getSrcNode() == pred2) + return; + } SVFBasicBlock* pred = const_cast(pred2); BasicBlockEdge* edge = new BasicBlockEdge(pred, this); this->addIncomingEdge(edge);