]> sourceware.org Git - systemtap.git/commitdiff
PR16300: switch back to nested visitors for visit_if_statement
authorFrank Ch. Eigler <fche@redhat.com>
Tue, 17 Jun 2014 15:26:16 +0000 (11:26 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Tue, 17 Jun 2014 15:34:57 +0000 (11:34 -0400)
This reverts commit 450cc664d02ec242327e63a84534aacb1c998c6d.

translate.cxx

index 65768baf3fa9b289a4e2aeb86b0d7cf9cb73516d..7499ba1ffa60a010f6e89576028b27e854196e03 100644 (file)
@@ -2231,21 +2231,19 @@ struct max_action_info: public functioncall_traversing_visitor
       add_stmt_count(1);
       stmt->condition->visit(this);
 
-      unsigned tmp_statement_count = statement_count;
-      unsigned then_count = 0;
-      unsigned else_count = 0;
-
-      stmt->thenblock->visit(this);
-      then_count = statement_count - tmp_statement_count;
-      statement_count = tmp_statement_count;
+      // Create new visitors for the two forks.  Copy the traversed[] set
+      // to prevent infinite recursion for a   function f () { if (a) f() }
+      max_action_info tmp_visitor_then (*this);
+      max_action_info tmp_visitor_else (*this);
+      stmt->thenblock->visit(& tmp_visitor_then);
       if (stmt->elseblock)
         {
-          stmt->elseblock->visit(this);
-          else_count = statement_count - tmp_statement_count;
-          statement_count = tmp_statement_count;
+          stmt->elseblock->visit(& tmp_visitor_else);
         }
 
-      add_stmt_count(max(then_count, else_count));
+      // Simply overwrite our copy of statement_count, since these
+      // visitor copies already included our starting count.
+      statement_count = max(tmp_visitor_then.statement_count, tmp_visitor_else.statement_count);
     }
 
   void visit_null_statement (null_statement *stmt) { add_stmt_count(1); }
This page took 0.040921 seconds and 5 git commands to generate.