Index: src/Common/PassVisitor.impl.h
===================================================================
--- src/Common/PassVisitor.impl.h	(revision 134322e8f4d4a14c74012f379a803fc111da3be3)
+++ src/Common/PassVisitor.impl.h	(revision 9c1600c894d713bbdc06ea2e3299d4c08cfdff3a)
@@ -1,8 +1,13 @@
 #pragma once
+
+#define VISIT_START( node )  \
+	call_previsit( node ); \
+
+#define VISIT_END( node )                \
+	return call_postvisit( node ); \
 
 #define MUTATE_START( node )  \
 	call_premutate( node ); \
 
-
 #define MUTATE_END( type, node )                \
 	return call_postmutate< type * >( node ); \
@@ -10,7 +15,7 @@
 
 #define VISIT_BODY( node )    \
-	call_previsit( node );  \
+	VISIT_START( node );  \
 	Visitor::visit( node ); \
-	call_postvisit( node ); \
+	VISIT_END( node ); \
 
 
@@ -39,5 +44,5 @@
 		if ( !empty( afterStmts ) ) { statements.splice( i, *afterStmts ); }
 		try {
-			*i = (*i)->accept( *this );
+			(*i)->accept( *this );
 		} catch ( SemanticError &e ) {
 			errors.append( e );
@@ -78,14 +83,14 @@
 	ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
 
-	Statement *newStmt = maybeVisit( stmt, *this );
+	maybeAccept( stmt, *this );
 
 	StmtList_t* beforeStmts = get_beforeStmts();
 	StmtList_t* afterStmts  = get_afterStmts();
 
-	if( empty(beforeStmts) && empty(afterStmts) ) { return newStmt; }
+	if( empty(beforeStmts) && empty(afterStmts) ) { return stmt; }
 
 	CompoundStmt *compound = new CompoundStmt( noLabels );
 	if( !empty(beforeStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *beforeStmts ); }
-	compound->get_kids().push_back( newStmt );
+	compound->get_kids().push_back( stmt );
 	if( !empty(afterStmts) ) { compound->get_kids().splice( compound->get_kids().end(), *afterStmts ); }
 	return compound;
@@ -187,7 +192,15 @@
 }
 
+//--------------------------------------------------------------------------
+// CompoundStmt
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( CompoundStmt * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node );
+	call_beginScope();
+
+	visitStatementList( node->get_kids() );
+
+	call_endScope();
+	VISIT_END( node );
 }
 
@@ -203,7 +216,15 @@
 }
 
+//--------------------------------------------------------------------------
+// ExprStmt
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( ExprStmt * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node );
+	call_beginScope();
+
+	visitExpression( node->get_expr() );
+
+	call_endScope();
+	VISIT_END( node );
 }
 
@@ -222,7 +243,15 @@
 }
 
+//--------------------------------------------------------------------------
+// IfStmt
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( IfStmt * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node ); 
+
+	visitExpression( node->get_condition() );
+	node->set_thenPart ( visitStatement( node->get_thenPart() ) );
+	node->set_elsePart ( visitStatement( node->get_elsePart() ) );
+
+	VISIT_END( node );
 }
 
@@ -238,7 +267,14 @@
 }
 
+//--------------------------------------------------------------------------
+// WhileStmt
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( WhileStmt * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node ); 
+
+	visitExpression( node->get_condition() );
+	node->set_body( visitStatement( node->get_body() ) );
+
+	VISIT_END( node );
 }
 
@@ -253,8 +289,16 @@
 }
 
-
+//--------------------------------------------------------------------------
+// WhileStmt
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( ForStmt * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node ); 
+
+	acceptAll( node->get_initialization(), *this );
+	visitExpression( node->get_condition() );
+	visitExpression( node->get_increment() );
+	node->set_body( visitStatement( node->get_body() ) );
+
+	VISIT_END( node );
 }
 
@@ -264,14 +308,21 @@
 
 	mutateAll( node->get_initialization(), *this );
-	node->set_condition(  mutateExpression( node->get_condition() ) );
-	node->set_increment(  mutateExpression( node->get_increment() ) );
-	node->set_body(  mutateStatement( node->get_body() ) );
+	node->set_condition( mutateExpression( node->get_condition() ) );
+	node->set_increment( mutateExpression( node->get_increment() ) );
+	node->set_body( mutateStatement( node->get_body() ) );
 
 	MUTATE_END( Statement, node );
 }
 
+//--------------------------------------------------------------------------
+// SwitchStmt
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node ); 
+
+	visitExpression( node->get_condition() );
+	visitStatementList( node->get_statements() );
+
+	VISIT_END( node );
 }
 
@@ -286,7 +337,14 @@
 }
 
+//--------------------------------------------------------------------------
+// SwitchStmt
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( CaseStmt * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node ); 
+	
+	visitExpression( node->get_condition() );
+	visitStatementList( node->get_statements() );
+	
+	VISIT_END( node );
 }
 
@@ -306,7 +364,13 @@
 }
 
+//--------------------------------------------------------------------------
+// ReturnStmt
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node );
+
+	visitExpression( node->get_expr() );
+
+	VISIT_END( node );
 }
 
@@ -320,7 +384,14 @@
 }
 
+//--------------------------------------------------------------------------
+// TryStmt
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( TryStmt * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node );
+
+	maybeAccept( node->get_block(), *this );
+	acceptAll( node->get_catchers(), *this );
+
+	VISIT_END( node );
 }
 
@@ -335,7 +406,14 @@
 }
 
+//--------------------------------------------------------------------------
+// CatchStmt
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( CatchStmt * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node );
+
+	node->set_body( visitStatement( node->get_body() ) );
+	maybeAccept( node->get_decl(), *this );
+
+	VISIT_END( node );
 }
 
@@ -375,7 +453,15 @@
 }
 
+//--------------------------------------------------------------------------
+// UntypedExpr
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node );
+
+	for ( auto expr : node->get_args() ) {
+		visitExpression( expr );
+	}
+
+	VISIT_END( node );
 }
 
@@ -536,7 +622,18 @@
 }
 
+//--------------------------------------------------------------------------
+// UntypedExpr
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( StmtExpr * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node );
+
+	// don't want statements from outer CompoundStmts to be added to this StmtExpr
+	ValueGuardPtr< TypeSubstitution * >      oldEnv        ( get_env_ptr() );
+	ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
+	ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
+
+	Visitor::visit( node );
+
+	VISIT_END( node );
 }
 
@@ -640,7 +737,13 @@
 }
 
+//--------------------------------------------------------------------------
+// UntypedExpr
 template< typename pass_type >
 void PassVisitor< pass_type >::visit( SingleInit * node ) {
-	VISIT_BODY( node ); 
+	VISIT_START( node );
+
+	visitExpression( node->get_value() );
+
+	VISIT_END( node );
 }
 
