changes
[c11tester.git] / cyclegraph.cc
index 1eb1add33fc255e4f53e9044b3d3850b422668dd..3168923a8c0f260c137755e7775f99a643ab96a5 100644 (file)
@@ -31,7 +31,7 @@ CycleNode * CycleGraph::getNode(const ModelAction *action) {
  * @param to The edge points to this ModelAction
  * @param from The edge comes from this ModelAction
  */
-void CycleGraph::addEdge(const ModelAction *to, const ModelAction *from) {
+void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) {
        CycleNode *fromnode=getNode(from);
        CycleNode *tonode=getNode(to);
 
@@ -60,7 +60,7 @@ void CycleGraph::addEdge(const ModelAction *to, const ModelAction *from) {
  *  can occur in between the rmw and the from action.  Only one RMW
  *  action can read from a given write.
  */
-void CycleGraph::addRMWEdge(const ModelAction *rmw, const ModelAction *from) {
+void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) {
        CycleNode *fromnode=getNode(from);
        CycleNode *rmwnode=getNode(rmw);
 
@@ -81,6 +81,21 @@ void CycleGraph::addRMWEdge(const ModelAction *rmw, const ModelAction *from) {
        fromnode->addEdge(rmwnode);
 }
 
+/**
+ * Checks whether one ModelAction can reach another.
+ * @param from The ModelAction from which to begin exploration
+ * @param to The ModelAction to reach
+ * @return True, @a from can reach @a to; otherwise, false
+ */
+bool CycleGraph::checkReachable(const ModelAction *from, const ModelAction *to) {
+       CycleNode *fromnode = actionToNode.get(from);
+       CycleNode *tonode = actionToNode.get(to);
+
+       if (!fromnode || !tonode)
+               return false;
+
+       return checkReachable(fromnode, tonode);
+}
 
 /**
  * Checks whether one CycleNode can reach another.