X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=cyclegraph.cc;h=44f5a28bc15b69cc3289a4906b298341845ae324;hb=ff1d424096506e2fe30b15286afb84a95cd05703;hp=69d6660bccee0768d2f8629d8ca787e6b3912d22;hpb=24d17393dc45f60f6f6660159f2f329d1cc5d15a;p=model-checker.git diff --git a/cyclegraph.cc b/cyclegraph.cc index 69d6660..44f5a28 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -198,7 +198,7 @@ bool CycleGraph::mergeNodes(CycleNode *w_node, CycleNode *p_node, } erasePromiseNode(promise); - delete p_node; + /* Not deleting p_node, to maintain consistency if mergeNodes() fails */ return !hasCycles; } @@ -308,10 +308,11 @@ bool CycleGraph::addEdge(const T *from, const U *to) return addNodeEdge(fromnode, tonode); } -/* Instantiate three forms of CycleGraph::addEdge */ +/* Instantiate four forms of CycleGraph::addEdge */ template bool CycleGraph::addEdge(const ModelAction *from, const ModelAction *to); template bool CycleGraph::addEdge(const ModelAction *from, const Promise *to); template bool CycleGraph::addEdge(const Promise *from, const ModelAction *to); +template bool CycleGraph::addEdge(const Promise *from, const Promise *to); #if SUPPORT_MOD_ORDER_DUMP @@ -405,13 +406,13 @@ bool CycleGraph::checkReachable(const CycleNode *from, const CycleNode *to) cons } /** - * Checks whether one ModelAction can reach another ModelAction/Promise - * @param from The ModelAction from which to begin exploration + * Checks whether one ModelAction/Promise can reach another ModelAction/Promise + * @param from The ModelAction or Promise from which to begin exploration * @param to The ModelAction or Promise to reach * @return True, @a from can reach @a to; otherwise, false */ -template -bool CycleGraph::checkReachable(const ModelAction *from, const T *to) const +template +bool CycleGraph::checkReachable(const T *from, const U *to) const { CycleNode *fromnode = getNode_noCreate(from); CycleNode *tonode = getNode_noCreate(to); @@ -421,11 +422,13 @@ bool CycleGraph::checkReachable(const ModelAction *from, const T *to) const return checkReachable(fromnode, tonode); } -/* Instantiate two forms of CycleGraph::checkReachable */ +/* Instantiate three forms of CycleGraph::checkReachable */ template bool CycleGraph::checkReachable(const ModelAction *from, const ModelAction *to) const; template bool CycleGraph::checkReachable(const ModelAction *from, const Promise *to) const; +template bool CycleGraph::checkReachable(const Promise *from, + const ModelAction *to) const; /** @return True, if the promise has failed; false otherwise */ bool CycleGraph::checkPromise(const ModelAction *fromact, Promise *promise) const @@ -440,6 +443,8 @@ bool CycleGraph::checkPromise(const ModelAction *fromact, Promise *promise) cons CycleNode *node = queue.back(); queue.pop_back(); + if (node->getPromise() == promise) + return true; if (!node->is_promise() && promise->eliminate_thread(node->getAction()->get_tid())) return true;