From 6f60474b286d39efa080caaa06c87ef7cdfe9b2f Mon Sep 17 00:00:00 2001 From: Peter Matula Date: Mon, 18 Mar 2019 14:47:21 +0100 Subject: [PATCH] llvmir2hll/statment.cpp: remove observers when removing predecessors. Related to #512. --- src/llvmir2hll/ir/statement.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/llvmir2hll/ir/statement.cpp b/src/llvmir2hll/ir/statement.cpp index 6d0677a11..c63f54757 100644 --- a/src/llvmir2hll/ir/statement.cpp +++ b/src/llvmir2hll/ir/statement.cpp @@ -300,7 +300,8 @@ void Statement::removeStatement(ShPtr stmt) { // target's predecessors - target is not goto's successor. if (auto gotoStmt = cast(stmt)) { if (gotoStmt->getTarget()) { - gotoStmt->getTarget()->preds.erase(stmt); + gotoStmt->getTarget()->removeObserver(stmt); + gotoStmt->getTarget()->removePredecessor(stmt); preserveLabel(stmt, gotoStmt->getTarget()); } } @@ -503,7 +504,8 @@ void Statement::replaceStatement(ShPtr oldStmt, // target's predecessors - target is not goto's successor. if (auto gotoStmt = cast(oldStmt)) { if (gotoStmt->getTarget()) { - gotoStmt->getTarget()->preds.erase(oldStmt); + gotoStmt->getTarget()->removeObserver(oldStmt); + gotoStmt->getTarget()->removePredecessor(oldStmt); } }