Index: src/InitTweak/FixGlobalInit.cc
===================================================================
--- src/InitTweak/FixGlobalInit.cc	(revision fa761c2aa9a4a9b1a22e28f45f380ba9d9ad36c0)
+++ src/InitTweak/FixGlobalInit.cc	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -20,40 +20,11 @@
 #include <algorithm>               // for replace_if
 
-#include "Common/PassVisitor.h"
-#include "Common/UniqueName.h"     // for UniqueName
-#include "InitTweak.h"             // for isIntrinsicSingleArgCallStmt
-#include "SynTree/LinkageSpec.h"   // for C
-#include "SynTree/Attribute.h"     // for Attribute
-#include "SynTree/Constant.h"      // for Constant
-#include "SynTree/Declaration.h"   // for FunctionDecl, ObjectDecl, Declaration
-#include "SynTree/Expression.h"    // for ConstantExpr, Expression (ptr only)
-#include "SynTree/Initializer.h"   // for ConstructorInit, Initializer
-#include "SynTree/Label.h"         // for Label
-#include "SynTree/Statement.h"     // for CompoundStmt, Statement (ptr only)
-#include "SynTree/Type.h"          // for Type, Type::StorageClasses, Functi...
-#include "SynTree/Visitor.h"       // for acceptAll, Visitor
-
 #include "AST/Expr.hpp"
 #include "AST/Node.hpp"
 #include "AST/Pass.hpp"
+#include "Common/UniqueName.h"     // for UniqueName
+#include "InitTweak.h"             // for isIntrinsicSingleArgCallStmt
 
 namespace InitTweak {
-	class GlobalFixer : public WithShortCircuiting {
-	  public:
-		GlobalFixer( bool inLibrary );
-
-		void previsit( ObjectDecl *objDecl );
-		void previsit( FunctionDecl *functionDecl );
-		void previsit( StructDecl *aggregateDecl );
-		void previsit( UnionDecl *aggregateDecl );
-		void previsit( EnumDecl *aggregateDecl );
-		void previsit( TraitDecl *aggregateDecl );
-		void previsit( TypeDecl *typeDecl );
-
-		UniqueName tempNamer;
-		FunctionDecl * initFunction;
-		FunctionDecl * destroyFunction;
-	};
-
 	class GlobalFixer_new : public ast::WithShortCircuiting {
 	public:
@@ -69,43 +40,4 @@
 		std::list< ast::ptr<ast::Stmt> > destroyStmts;
 	};
-
-	void fixGlobalInit( std::list< Declaration * > & translationUnit, bool inLibrary ) {
-		PassVisitor<GlobalFixer> visitor( inLibrary );
-		acceptAll( translationUnit, visitor );
-		GlobalFixer & fixer = visitor.pass;
-		// don't need to include function if it's empty
-		if ( fixer.initFunction->get_statements()->get_kids().empty() ) {
-			delete fixer.initFunction;
-		} else {
-			translationUnit.push_back( fixer.initFunction );
-		} // if
-
-		if ( fixer.destroyFunction->get_statements()->get_kids().empty() ) {
-			delete fixer.destroyFunction;
-		} else {
-			translationUnit.push_back( fixer.destroyFunction );
-		} // if
-	}
-
-	GlobalFixer::GlobalFixer( bool inLibrary ) : tempNamer( "_global_init" ) {
-		std::list< Expression * > ctorParameters;
-		std::list< Expression * > dtorParameters;
-		if ( inLibrary ) {
-			// Constructor/destructor attributes take a single parameter which
-			// is the priority, with lower numbers meaning higher priority.
-			// Functions specified with priority are guaranteed to run before
-			// functions without a priority. To ensure that constructors and destructors
-			// for library code are run before constructors and destructors for user code,
-			// specify a priority when building the library. Priorities 0-100 are reserved by gcc.
-			// Priorities 101-200 are reserved by cfa, so use priority 200 for CFA library globals,
-			// allowing room for overriding with a higher priority.
-			ctorParameters.push_back( new ConstantExpr( Constant::from_int( 200 ) ) );
-			dtorParameters.push_back( new ConstantExpr( Constant::from_int( 200 ) ) );
-		}
-		initFunction = new FunctionDecl( "__global_init__", Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
-		initFunction->get_attributes().push_back( new Attribute( "constructor", ctorParameters ) );
-		destroyFunction = new FunctionDecl( "__global_destroy__", Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
-		destroyFunction->get_attributes().push_back( new Attribute( "destructor", dtorParameters ) );
-	}
 
 	void fixGlobalInit(ast::TranslationUnit & translationUnit, bool inLibrary) {
@@ -141,40 +73,4 @@
 	}
 
-	void GlobalFixer::previsit( ObjectDecl *objDecl ) {
-		std::list< Statement * > & initStatements = initFunction->get_statements()->get_kids();
-		std::list< Statement * > & destroyStatements = destroyFunction->get_statements()->get_kids();
-
-		// C allows you to initialize objects with constant expressions
-		// xxx - this is an optimization. Need to first resolve constructors before we decide
-		// to keep C-style initializer.
-		// if ( isConstExpr( objDecl->get_init() ) ) return;
-
-		if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) {
-			// a decision should have been made by the resolver, so ctor and init are not both non-NULL
-			assert( ! ctorInit->ctor || ! ctorInit->init );
-
-			Statement * dtor = ctorInit->dtor;
-			if ( dtor && ! isIntrinsicSingleArgCallStmt( dtor ) ) {
-				// don't need to call intrinsic dtor, because it does nothing, but
-				// non-intrinsic dtors must be called
-				destroyStatements.push_front( dtor );
-				ctorInit->dtor = nullptr;
-			} // if
-			if ( Statement * ctor = ctorInit->ctor ) {
-				addDataSectionAttribute( objDecl );
-				initStatements.push_back( ctor );
-				objDecl->init = nullptr;
-				ctorInit->ctor = nullptr;
-			} else if ( Initializer * init = ctorInit->init ) {
-				objDecl->init = init;
-				ctorInit->init = nullptr;
-			} else {
-				// no constructor and no initializer, which is okay
-				objDecl->init = nullptr;
-			} // if
-			delete ctorInit;
-		} // if
-	}
-
 	void GlobalFixer_new::previsit(const ast::ObjectDecl * objDecl) {
 		auto mutDecl = mutate(objDecl);
@@ -207,12 +103,4 @@
 	}
 
-	// only modify global variables
-	void GlobalFixer::previsit( FunctionDecl * ) { visit_children = false; }
-	void GlobalFixer::previsit( StructDecl * ) { visit_children = false; }
-	void GlobalFixer::previsit( UnionDecl * ) { visit_children = false; }
-	void GlobalFixer::previsit( EnumDecl * ) { visit_children = false; }
-	void GlobalFixer::previsit( TraitDecl * ) { visit_children = false; }
-	void GlobalFixer::previsit( TypeDecl * ) { visit_children = false; }
-
 } // namespace InitTweak
 
Index: src/InitTweak/FixInit.cc
===================================================================
--- src/InitTweak/FixInit.cc	(revision fa761c2aa9a4a9b1a22e28f45f380ba9d9ad36c0)
+++ 	(revision )
@@ -1,1291 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// FixInit.cc --
-//
-// Author           : Rob Schluntz
-// Created On       : Wed Jan 13 16:29:30 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Feb 16 04:17:07 2020
-// Update Count     : 82
-//
-#include "FixInit.h"
-
-#include <stddef.h>                    // for NULL
-#include <algorithm>                   // for set_difference, copy_if
-#include <cassert>                     // for assert, strict_dynamic_cast
-#include <iostream>                    // for operator<<, ostream, basic_ost...
-#include <iterator>                    // for insert_iterator, back_inserter
-#include <list>                        // for _List_iterator, list, list<>::...
-#include <map>                         // for _Rb_tree_iterator, _Rb_tree_co...
-#include <memory>                      // for allocator_traits<>::value_type
-#include <set>                         // for set, set<>::value_type
-#include <unordered_map>               // for unordered_map, unordered_map<>...
-#include <unordered_set>               // for unordered_set
-#include <utility>                     // for pair
-
-#include "CodeGen/GenType.h"           // for genPrettyType
-#include "CodeGen/OperatorTable.h"
-#include "Common/PassVisitor.h"        // for PassVisitor, WithStmtsToAdd
-#include "Common/SemanticError.h"      // for SemanticError
-#include "Common/ToString.hpp"         // for toCString
-#include "Common/UniqueName.h"         // for UniqueName
-#include "FixGlobalInit.h"             // for fixGlobalInit
-#include "GenInit.h"                   // for genCtorDtor
-#include "GenPoly/GenPoly.h"           // for getFunctionType
-#include "InitTweak.h"                 // for getFunctionName, getCallArg
-#include "ResolvExpr/Resolver.h"       // for findVoidExpression
-#include "ResolvExpr/Unify.h"          // for typesCompatible
-#include "SymTab/Autogen.h"            // for genImplicitCall
-#include "SymTab/Indexer.h"            // for Indexer
-#include "SymTab/Mangler.h"            // for Mangler
-#include "SynTree/LinkageSpec.h"       // for C, Spec, Cforall, isBuiltin
-#include "SynTree/Attribute.h"         // for Attribute
-#include "SynTree/Constant.h"          // for Constant
-#include "SynTree/Declaration.h"       // for ObjectDecl, FunctionDecl, Decl...
-#include "SynTree/Expression.h"        // for UniqueExpr, VariableExpr, Unty...
-#include "SynTree/Initializer.h"       // for ConstructorInit, SingleInit
-#include "SynTree/Label.h"             // for Label, operator<
-#include "SynTree/Mutator.h"           // for mutateAll, Mutator, maybeMutate
-#include "SynTree/Statement.h"         // for ExprStmt, CompoundStmt, Branch...
-#include "SynTree/Type.h"              // for Type, Type::StorageClasses
-#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution, operator<<
-#include "SynTree/DeclReplacer.h"      // for DeclReplacer
-#include "SynTree/Visitor.h"           // for acceptAll, maybeAccept
-#include "Validate/FindSpecialDecls.h" // for dtorStmt, dtorStructDestroy
-
-extern bool ctordtorp; // print all debug
-extern bool ctorp; // print ctor debug
-extern bool cpctorp; // print copy ctor debug
-extern bool dtorp; // print dtor debug
-#define PRINT( text ) if ( ctordtorp ) { text }
-#define CP_CTOR_PRINT( text ) if ( ctordtorp || cpctorp ) { text }
-#define DTOR_PRINT( text ) if ( ctordtorp || dtorp ) { text }
-
-namespace InitTweak {
-	namespace {
-		struct SelfAssignChecker {
-			void previsit( ApplicationExpr * appExpr );
-		};
-
-		struct StmtExprResult {
-			static void link( std::list< Declaration * > & translationUnit );
-
-			void previsit( StmtExpr * stmtExpr );
-		};
-
-		struct InsertImplicitCalls : public WithConstTypeSubstitution {
-			/// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which
-			/// function calls need their parameters to be copy constructed
-			static void insert( std::list< Declaration * > & translationUnit );
-
-			Expression * postmutate( ApplicationExpr * appExpr );
-		};
-
-		struct ResolveCopyCtors final : public WithStmtsToAdd, public WithIndexer, public WithShortCircuiting, public WithTypeSubstitution, public WithVisitorRef<ResolveCopyCtors> {
-			/// generate temporary ObjectDecls for each argument and return value of each ImplicitCopyCtorExpr,
-			/// generate/resolve copy construction expressions for each, and generate/resolve destructors for both
-			/// arguments and return value temporaries
-			static void resolveImplicitCalls( std::list< Declaration * > & translationUnit );
-
-			Expression * postmutate( ImplicitCopyCtorExpr * impCpCtorExpr );
-			void premutate( StmtExpr * stmtExpr );
-			void premutate( UniqueExpr * unqExpr );
-
-			/// create and resolve ctor/dtor expression: fname(var, [cpArg])
-			Expression * makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg = NULL );
-			/// true if type does not need to be copy constructed to ensure correctness
-			bool skipCopyConstruct( Type * type );
-			void copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr, Type * formal );
-			void destructRet( ObjectDecl * ret, ImplicitCopyCtorExpr * impCpCtorExpr, Expression *& arg );
-		};
-
-		/// collects constructed object decls - used as a base class
-		struct ObjDeclCollector : public WithGuards, public WithShortCircuiting {
-			// use ordered data structure to maintain ordering for set_difference and for consistent error messages
-			typedef std::list< ObjectDecl * > ObjectSet;
-			void previsit( CompoundStmt *compoundStmt );
-			void previsit( DeclStmt *stmt );
-
-			// don't go into other functions
-			void previsit( FunctionDecl * ) { visit_children = false; }
-
-		  protected:
-			ObjectSet curVars;
-		};
-
-		// debug
-		template<typename ObjectSet>
-		struct PrintSet {
-			PrintSet( const ObjectSet & objs ) : objs( objs ) {}
-			const ObjectSet & objs;
-		};
-		template<typename ObjectSet>
-		PrintSet<ObjectSet> printSet( const ObjectSet & objs ) { return PrintSet<ObjectSet>( objs ); }
-		template<typename ObjectSet>
-		std::ostream & operator<<( std::ostream & out, const PrintSet<ObjectSet> & set) {
-			out << "{ ";
-			for ( ObjectDecl * obj : set.objs ) {
-				out << obj->get_name() << ", " ;
-			} // for
-			out << " }";
-			return out;
-		}
-
-		struct LabelFinder final : public ObjDeclCollector {
-			typedef std::map< Label, ObjectSet > LabelMap;
-			// map of Label -> live variables at that label
-			LabelMap vars;
-
-			typedef ObjDeclCollector Parent;
-			using Parent::previsit;
-			void previsit( Statement * stmt );
-
-			void previsit( CompoundStmt *compoundStmt );
-			void previsit( DeclStmt *stmt );
-		};
-
-		struct InsertDtors final : public ObjDeclCollector, public WithStmtsToAdd {
-			/// insert destructor calls at the appropriate places.  must happen before CtorInit nodes are removed
-			/// (currently by FixInit)
-			static void insert( std::list< Declaration * > & translationUnit );
-
-			typedef std::list< ObjectDecl * > OrderedDecls;
-			typedef std::list< OrderedDecls > OrderedDeclsStack;
-
-			InsertDtors( PassVisitor<LabelFinder> & finder ) : finder( finder ), labelVars( finder.pass.vars ) {}
-
-			typedef ObjDeclCollector Parent;
-			using Parent::previsit;
-
-			void previsit( FunctionDecl * funcDecl );
-
-			void previsit( BranchStmt * stmt );
-		private:
-			void handleGoto( BranchStmt * stmt );
-
-			PassVisitor<LabelFinder> & finder;
-			LabelFinder::LabelMap & labelVars;
-			OrderedDeclsStack reverseDeclOrder;
-		};
-
-		class FixInit : public WithStmtsToAdd {
-		  public:
-			/// expand each object declaration to use its constructor after it is declared.
-			static void fixInitializers( std::list< Declaration * > &translationUnit );
-
-			DeclarationWithType * postmutate( ObjectDecl *objDecl );
-
-			std::list< Declaration * > staticDtorDecls;
-		};
-
-		struct GenStructMemberCalls final : public WithGuards, public WithShortCircuiting, public WithIndexer, public WithVisitorRef<GenStructMemberCalls> {
-			/// generate default/copy ctor and dtor calls for user-defined struct ctor/dtors
-			/// for any member that is missing a corresponding ctor/dtor call.
-			/// error if a member is used before constructed
-			static void generate( std::list< Declaration * > & translationUnit );
-
-			void premutate( FunctionDecl * funcDecl );
-			DeclarationWithType * postmutate( FunctionDecl * funcDecl );
-
-			void premutate( MemberExpr * memberExpr );
-			void premutate( ApplicationExpr * appExpr );
-
-			/// Note: this post mutate used to be in a separate visitor. If this pass breaks, one place to examine is whether it is
-			/// okay for this part of the recursion to occur alongside the rest.
-			Expression * postmutate( UntypedExpr * expr );
-
-			SemanticErrorException errors;
-		  private:
-			template< typename... Params >
-			void emit( CodeLocation, const Params &... params );
-
-			FunctionDecl * function = nullptr;
-			std::set< DeclarationWithType * > unhandled;
-			std::map< DeclarationWithType *, CodeLocation > usedUninit;
-			ObjectDecl * thisParam = nullptr;
-			bool isCtor = false; // true if current function is a constructor
-			StructDecl * structDecl = nullptr;
-		};
-
-		struct FixCtorExprs final : public WithDeclsToAdd, public WithIndexer {
-			/// expands ConstructorExpr nodes into comma expressions, using a temporary for the first argument
-			static void fix( std::list< Declaration * > & translationUnit );
-
-			Expression * postmutate( ConstructorExpr * ctorExpr );
-		};
-
-		struct SplitExpressions : public WithShortCircuiting, /*public WithTypeSubstitution, */public WithStmtsToAdd {
-			/// add CompoundStmts around top-level expressions so that temporaries are destroyed in the correct places.
-			static void split( std::list< Declaration * > &translationUnit );
-
-			Statement * postmutate( ExprStmt * stmt );
-			void premutate( TupleAssignExpr * expr );
-		};
-	} // namespace
-
-	void fix( std::list< Declaration * > & translationUnit, bool inLibrary ) {
-		PassVisitor<SelfAssignChecker> checker;
-		acceptAll( translationUnit, checker );
-
-		// fixes StmtExpr to properly link to their resulting expression
-		StmtExprResult::link( translationUnit );
-
-		// fixes ConstructorInit for global variables. should happen before fixInitializers.
-		InitTweak::fixGlobalInit( translationUnit, inLibrary );
-
-		// must happen before ResolveCopyCtors because temporaries have to be inserted into the correct scope
-		SplitExpressions::split( translationUnit );
-
-		InsertImplicitCalls::insert( translationUnit );
-
-		// Needs to happen before ResolveCopyCtors, because argument/return temporaries should not be considered in
-		// error checking branch statements
-		InsertDtors::insert( translationUnit );
-
-		ResolveCopyCtors::resolveImplicitCalls( translationUnit );
-		FixInit::fixInitializers( translationUnit );
-		GenStructMemberCalls::generate( translationUnit );
-
-		// Needs to happen after GenStructMemberCalls, since otherwise member constructors exprs
-		// don't have the correct form, and a member can be constructed more than once.
-		FixCtorExprs::fix( translationUnit );
-	}
-
-	namespace {
-		/// find and return the destructor used in `input`. If `input` is not a simple destructor call, generate a thunk
-		/// that wraps the destructor, insert it into `stmtsToAdd` and return the new function declaration
-		DeclarationWithType * getDtorFunc( ObjectDecl * objDecl, Statement * input, std::list< Statement * > & stmtsToAdd ) {
-			// unwrap implicit statement wrapper
-			Statement * dtor = input;
-			assert( dtor );
-			std::list< Expression * > matches;
-			collectCtorDtorCalls( dtor, matches );
-
-			if ( dynamic_cast< ExprStmt * >( dtor ) ) {
-				// only one destructor call in the expression
-				if ( matches.size() == 1 ) {
-					DeclarationWithType * func = getFunction( matches.front() );
-					assertf( func, "getFunction failed to find function in %s", toString( matches.front() ).c_str() );
-
-					// cleanup argument must be a function, not an object (including function pointer)
-					if ( FunctionDecl * dtorFunc = dynamic_cast< FunctionDecl * > ( func ) ) {
-						if ( dtorFunc->type->forall.empty() ) {
-							// simple case where the destructor is a monomorphic function call - can simply
-							// use that function as the cleanup function.
-							delete dtor;
-							return func;
-						}
-					}
-				}
-			}
-
-			// otherwise the cleanup is more complicated - need to build a single argument cleanup function that
-			// wraps the more complicated code.
-			static UniqueName dtorNamer( "__cleanup_dtor" );
-			std::string name = dtorNamer.newName();
-			FunctionDecl * dtorFunc = FunctionDecl::newFunction( name, SymTab::genDefaultType( objDecl->type->stripReferences(), false ), new CompoundStmt() );
-			stmtsToAdd.push_back( new DeclStmt( dtorFunc ) );
-
-			// the original code contains uses of objDecl - replace them with the newly generated 'this' parameter.
-			ObjectDecl * thisParam = getParamThis( dtorFunc->type );
-			Expression * replacement = new VariableExpr( thisParam );
-
-			Type * base = replacement->result->stripReferences();
-			if ( dynamic_cast< ArrayType * >( base ) || dynamic_cast< TupleType * > ( base ) ) {
-				// need to cast away reference for array types, since the destructor is generated without the reference type,
-				// and for tuple types since tuple indexing does not work directly on a reference
-				replacement = new CastExpr( replacement, base->clone() );
-			}
-			DeclReplacer::replace( dtor, { std::make_pair( objDecl, replacement ) } );
-			dtorFunc->statements->push_back( strict_dynamic_cast<Statement *>( dtor ) );
-
-			return dtorFunc;
-		}
-
-		void StmtExprResult::link( std::list< Declaration * > & translationUnit ) {
-			PassVisitor<StmtExprResult> linker;
-			acceptAll( translationUnit, linker );
-		}
-
-		void SplitExpressions::split( std::list< Declaration * > & translationUnit ) {
-			PassVisitor<SplitExpressions> splitter;
-			mutateAll( translationUnit, splitter );
-		}
-
-		void InsertImplicitCalls::insert( std::list< Declaration * > & translationUnit ) {
-			PassVisitor<InsertImplicitCalls> inserter;
-			mutateAll( translationUnit, inserter );
-		}
-
-		void ResolveCopyCtors::resolveImplicitCalls( std::list< Declaration * > & translationUnit ) {
-			PassVisitor<ResolveCopyCtors> resolver;
-			mutateAll( translationUnit, resolver );
-		}
-
-		void FixInit::fixInitializers( std::list< Declaration * > & translationUnit ) {
-			PassVisitor<FixInit> fixer;
-
-			// can't use mutateAll, because need to insert declarations at top-level
-			// can't use DeclMutator, because sometimes need to insert IfStmt, etc.
-			SemanticErrorException errors;
-			for ( std::list< Declaration * >::iterator i = translationUnit.begin(); i != translationUnit.end(); ++i ) {
-				try {
-					maybeMutate( *i, fixer );
-					translationUnit.splice( i, fixer.pass.staticDtorDecls );
-				} catch( SemanticErrorException &e ) {
-					errors.append( e );
-				} // try
-			} // for
-			if ( ! errors.isEmpty() ) {
-				throw errors;
-			} // if
-		}
-
-		void InsertDtors::insert( std::list< Declaration * > & translationUnit ) {
-			PassVisitor<LabelFinder> finder;
-			PassVisitor<InsertDtors> inserter( finder );
-			acceptAll( translationUnit, inserter );
-		}
-
-		void GenStructMemberCalls::generate( std::list< Declaration * > & translationUnit ) {
-			PassVisitor<GenStructMemberCalls> warner;
-			mutateAll( translationUnit, warner );
-		}
-
-		void FixCtorExprs::fix( std::list< Declaration * > & translationUnit ) {
-			PassVisitor<FixCtorExprs> fixer;
-			mutateAll( translationUnit, fixer );
-		}
-
-		void StmtExprResult::previsit( StmtExpr * stmtExpr ) {
-			// we might loose the result expression here so add a pointer to trace back
-			assert( stmtExpr->result );
-			Type * result = stmtExpr->result;
-			if ( ! result->isVoid() ) {
-				CompoundStmt * body = stmtExpr->statements;
-				assert( ! body->kids.empty() );
-				stmtExpr->resultExpr = strict_dynamic_cast< ExprStmt * >( body->kids.back() );
-			}
-		}
-
-		Statement * SplitExpressions::postmutate( ExprStmt * stmt ) {
-			// wrap each top-level ExprStmt in a block so that destructors for argument and return temporaries are destroyed
-			// in the correct places
-			CompoundStmt * ret = new CompoundStmt( { stmt } );
-			return ret;
-		}
-
-		void SplitExpressions::premutate( TupleAssignExpr * ) {
-			// don't do this within TupleAssignExpr, since it is already broken up into multiple expressions
-			visit_children = false;
-		}
-
-		// Relatively simple structural comparison for expressions, needed to determine
-		// if two expressions are "the same" (used to determine if self assignment occurs)
-		struct StructuralChecker {
-			Expression * stripCasts( Expression * expr ) {
-				// this might be too permissive. It's possible that only particular casts are relevant.
-				while ( CastExpr * cast = dynamic_cast< CastExpr * >( expr ) ) {
-					expr = cast->arg;
-				}
-				return expr;
-			}
-
-			void previsit( Expression * ) {
-				// anything else does not qualify
-				isSimilar = false;
-			}
-
-			template<typename T>
-			T * cast( Expression * node ) {
-				// all expressions need to ignore casts, so this bit has been factored out
-				return dynamic_cast< T * >( stripCasts( node ) );
-			}
-
-			// ignore casts
-			void previsit( CastExpr * ) {}
-
-			void previsit( MemberExpr * memExpr ) {
-				if ( MemberExpr * otherMember = cast< MemberExpr >( other ) ) {
-					if ( otherMember->member == memExpr->member ) {
-						other = otherMember->aggregate;
-						return;
-					}
-				}
-				isSimilar = false;
-			}
-
-			void previsit( VariableExpr * varExpr ) {
-				if ( VariableExpr * otherVar = cast< VariableExpr >( other ) ) {
-					if ( otherVar->var == varExpr->var ) {
-						return;
-					}
-				}
-				isSimilar = false;
-			}
-
-			void previsit( AddressExpr * ) {
-				if ( AddressExpr * addrExpr = cast< AddressExpr >( other ) ) {
-					other = addrExpr->arg;
-					return;
-				}
-				isSimilar = false;
-			}
-
-			Expression * other = nullptr;
-			bool isSimilar = true;
-		};
-
-		bool structurallySimilar( Expression * e1, Expression * e2 ) {
-			PassVisitor<StructuralChecker> checker;
-			checker.pass.other = e2;
-			e1->accept( checker );
-			return checker.pass.isSimilar;
-		}
-
-		void SelfAssignChecker::previsit( ApplicationExpr * appExpr ) {
-			DeclarationWithType * function = getFunction( appExpr );
-			if ( function->name == "?=?" ) { // doesn't use isAssignment, because ?+=?, etc. should not count as self-assignment
-				if ( appExpr->args.size() == 2 ) {
-					// check for structural similarity (same variable use, ignore casts, etc. - but does not look too deeply, anything looking like a function is off limits)
-					if ( structurallySimilar( appExpr->args.front(), appExpr->args.back() ) ) {
-						SemanticWarning( appExpr->location, Warning::SelfAssignment, toCString( appExpr->args.front() ) );
-					}
-				}
-			}
-		}
-
-		Expression * InsertImplicitCalls::postmutate( ApplicationExpr * appExpr ) {
-			if ( VariableExpr * function = dynamic_cast< VariableExpr * > ( appExpr->get_function() ) ) {
-				if ( function->var->linkage.is_builtin ) {
-					// optimization: don't need to copy construct in order to call intrinsic functions
-					return appExpr;
-				} else if ( DeclarationWithType * funcDecl = dynamic_cast< DeclarationWithType * > ( function->get_var() ) ) {
-					FunctionType * ftype = dynamic_cast< FunctionType * >( GenPoly::getFunctionType( funcDecl->get_type() ) );
-					assertf( ftype, "Function call without function type: %s", toString( funcDecl ).c_str() );
-					if ( CodeGen::isConstructor( funcDecl->get_name() ) && ftype->parameters.size() == 2 ) {
-						Type * t1 = getPointerBase( ftype->parameters.front()->get_type() );
-						Type * t2 = ftype->parameters.back()->get_type();
-						assert( t1 );
-
-						if ( ResolvExpr::typesCompatible( t1, t2, SymTab::Indexer() ) ) {
-							// optimization: don't need to copy construct in order to call a copy constructor
-							return appExpr;
-						} // if
-					} else if ( CodeGen::isDestructor( funcDecl->get_name() ) ) {
-						// correctness: never copy construct arguments to a destructor
-						return appExpr;
-					} // if
-				} // if
-			} // if
-			CP_CTOR_PRINT( std::cerr << "InsertImplicitCalls: adding a wrapper " << appExpr << std::endl; )
-
-			// wrap each function call so that it is easy to identify nodes that have to be copy constructed
-			ImplicitCopyCtorExpr * expr = new ImplicitCopyCtorExpr( appExpr );
-			// Move the type substitution to the new top-level, if it is attached to the appExpr.
-			// Ensure it is not deleted with the ImplicitCopyCtorExpr by removing it before deletion.
-			// The substitution is needed to obtain the type of temporary variables so that copy constructor
-			// calls can be resolved.
-			assert( env );
-			std::swap( expr->env, appExpr->env );
-			return expr;
-		}
-
-		bool ResolveCopyCtors::skipCopyConstruct( Type * type ) { return ! isConstructable( type ); }
-
-		Expression * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {
-			assert( var );
-			// arrays are not copy constructed, so this should always be an ExprStmt
-			ImplicitCtorDtorStmt * stmt = genCtorDtor( fname, var, cpArg );
-			assertf( stmt, "ResolveCopyCtors: genCtorDtor returned nullptr: %s / %s / %s", fname.c_str(), toString( var ).c_str(), toString( cpArg ).c_str() );
-			ExprStmt * exprStmt = strict_dynamic_cast< ExprStmt * >( stmt->callStmt );
-			Expression * resolved = exprStmt->expr;
-			exprStmt->expr = nullptr; // take ownership of expr
-
-			// resolve copy constructor
-			// should only be one alternative for copy ctor and dtor expressions, since all arguments are fixed
-			// (VariableExpr and already resolved expression)
-			CP_CTOR_PRINT( std::cerr << "ResolvingCtorDtor " << resolved << std::endl; )
-			ResolvExpr::findVoidExpression( resolved, indexer );
-			assert( resolved );
-			if ( resolved->env ) {
-				// Extract useful information and discard new environments. Keeping them causes problems in PolyMutator passes.
-				env->add( *resolved->env );
-				delete resolved->env;
-				resolved->env = nullptr;
-			} // if
-			delete stmt;
-			if ( TupleAssignExpr * assign = dynamic_cast< TupleAssignExpr * >( resolved ) ) {
-				// fix newly generated StmtExpr
-				premutate( assign->stmtExpr );
-			}
-			return resolved;
-		}
-
-		void ResolveCopyCtors::copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr, Type * formal ) {
-			static UniqueName tempNamer("_tmp_cp");
-			assert( env );
-			CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *env << std::endl; )
-			assert( arg->result );
-			Type * result = arg->result;
-			if ( skipCopyConstruct( result ) ) return; // skip certain non-copyable types
-
-			// type may involve type variables, so apply type substitution to get temporary variable's actual type,
-			// since result type may not be substituted (e.g., if the type does not appear in the parameter list)
-			// Use applyFree so that types bound in function pointers are not substituted, e.g. in forall(dtype T) void (*)(T).
-			env->applyFree( result );
-			ObjectDecl * tmp = ObjectDecl::newObject( "__tmp", result, nullptr );
-			tmp->get_type()->set_const( false );
-
-			// create and resolve copy constructor
-			CP_CTOR_PRINT( std::cerr << "makeCtorDtor for an argument" << std::endl; )
-			Expression * cpCtor = makeCtorDtor( "?{}", tmp, arg );
-
-			if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( cpCtor ) ) {
-				// if the chosen constructor is intrinsic, the copy is unnecessary, so
-				// don't create the temporary and don't call the copy constructor
-				VariableExpr * function = strict_dynamic_cast< VariableExpr * >( appExpr->function );
-				if ( function->var->linkage == LinkageSpec::Intrinsic ) {
-					// arguments that need to be boxed need a temporary regardless of whether the copy constructor is intrinsic,
-					// so that the object isn't changed inside of the polymorphic function
-					if ( ! GenPoly::needsBoxing( formal, result, impCpCtorExpr->callExpr, env ) ) return;
-					// xxx - leaking tmp
-				}
-			}
-
-			// set a unique name for the temporary once it's certain the call is necessary
-			tmp->name = tempNamer.newName();
-
-			// replace argument to function call with temporary
-			stmtsToAddBefore.push_back( new DeclStmt( tmp ) );
-			arg = cpCtor;
-			destructRet( tmp, impCpCtorExpr, arg );
-
-			// impCpCtorExpr->dtors.push_front( makeCtorDtor( "^?{}", tmp ) );
-		}
-
-		void ResolveCopyCtors::destructRet( ObjectDecl * ret, ImplicitCopyCtorExpr * /*impCpCtorExpr*/, Expression *& arg ) {
-			// TODO: refactor code for generating cleanup attribute, since it's common and reused in ~3-4 places
-			// check for existing cleanup attribute before adding another(?)
-			// need to add __Destructor for _tmp_cp variables as well
-
-			assertf( Validate::dtorStruct && Validate::dtorStruct->members.size() == 2, "Destructor generation requires __Destructor definition." );
-			assertf( Validate::dtorStructDestroy, "Destructor generation requires __destroy_Destructor." );
-
-			// generate a __Destructor for ret that calls the destructor
-			Expression * dtor = makeCtorDtor( "^?{}", ret );
-
-			// if the chosen destructor is intrinsic, elide the generated dtor handler
-			if ( arg && isIntrinsicCallExpr( dtor ) ) {
-				arg = new CommaExpr( arg, new VariableExpr( ret ) );
-				return;
-			}
-
-			if ( ! dtor->env ) dtor->env = maybeClone( env );
-			DeclarationWithType * dtorFunc = getDtorFunc( ret, new ExprStmt( dtor ), stmtsToAddBefore );
-
-			StructInstType * dtorStructType = new StructInstType( Type::Qualifiers(), Validate::dtorStruct );
-			dtorStructType->parameters.push_back( new TypeExpr( new VoidType( Type::Qualifiers() ) ) );
-
-			// cast destructor pointer to void (*)(void *), to silence GCC incompatible pointer warnings
-			FunctionType * dtorFtype = new FunctionType( Type::Qualifiers(), false );
-			dtorFtype->parameters.push_back( ObjectDecl::newObject( "", new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), nullptr ) );
-			Type * dtorType = new PointerType( Type::Qualifiers(), dtorFtype );
-
-			static UniqueName namer( "_ret_dtor" );
-			ObjectDecl * retDtor = ObjectDecl::newObject( namer.newName(), dtorStructType, new ListInit( { new SingleInit( new ConstantExpr( Constant::null() ) ), new SingleInit( new CastExpr( new VariableExpr( dtorFunc ), dtorType ) ) } ) );
-			retDtor->attributes.push_back( new Attribute( "cleanup", { new VariableExpr( Validate::dtorStructDestroy ) } ) );
-			stmtsToAddBefore.push_back( new DeclStmt( retDtor ) );
-
-			if ( arg ) {
-				Expression * member = new MemberExpr( strict_dynamic_cast<DeclarationWithType *>( Validate::dtorStruct->members.front() ), new VariableExpr( retDtor ) );
-				Expression * object = new CastExpr( new AddressExpr( new VariableExpr( ret ) ), new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ) );
-				Expression * assign = createBitwiseAssignment( member, object );
-				arg = new CommaExpr( new CommaExpr( arg, assign ), new VariableExpr( ret ) );
-			}
-
-			// impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", ret ) );
-		}
-
-		Expression * ResolveCopyCtors::postmutate( ImplicitCopyCtorExpr *impCpCtorExpr ) {
-			CP_CTOR_PRINT( std::cerr << "ResolveCopyCtors: " << impCpCtorExpr << std::endl; )
-
-			ApplicationExpr * appExpr = impCpCtorExpr->callExpr;
-			ObjectDecl * returnDecl = nullptr;
-
-			// take each argument and attempt to copy construct it.
-			FunctionType * ftype = GenPoly::getFunctionType( appExpr->function->result );
-			assert( ftype );
-			auto & params = ftype->parameters;
-			auto iter = params.begin();
-			for ( Expression * & arg : appExpr->args ) {
-				Type * formal = nullptr;
-				if ( iter != params.end() ) { // does not copy construct C-style variadic arguments
-					DeclarationWithType * param = *iter++;
-					formal = param->get_type();
-				}
-
-				copyConstructArg( arg, impCpCtorExpr, formal );
-			} // for
-
-			// each return value from the call needs to be connected with an ObjectDecl at the call site, which is
-			// initialized with the return value and is destructed later
-			// xxx - handle named return values?
-			Type * result = appExpr->result;
-			if ( ! result->isVoid() ) {
-				static UniqueName retNamer("_tmp_cp_ret");
-				result = result->clone();
-				env->apply( result );
-				ObjectDecl * ret = ObjectDecl::newObject( retNamer.newName(), result, nullptr );
-				ret->type->set_const( false );
-				returnDecl = ret;
-				stmtsToAddBefore.push_back( new DeclStmt( ret ) );
-				CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; )
-			} // for
-			CP_CTOR_PRINT( std::cerr << "after Resolving: " << impCpCtorExpr << std::endl; )
-			// ------------------------------------------------------
-
-			CP_CTOR_PRINT( std::cerr << "Coming out the back..." << impCpCtorExpr << std::endl; )
-
-			// detach fields from wrapper node so that it can be deleted without deleting too much
-			impCpCtorExpr->callExpr = nullptr;
-			std::swap( impCpCtorExpr->env, appExpr->env );
-			assert( impCpCtorExpr->env == nullptr );
-			delete impCpCtorExpr;
-
-			if ( returnDecl ) {
-				Expression * assign = createBitwiseAssignment( new VariableExpr( returnDecl ), appExpr );
-				if ( ! dynamic_cast< ReferenceType * >( result ) ) {
-					// destructing reference returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary
-					destructRet( returnDecl, impCpCtorExpr, assign );
-				} else {
-					assign = new CommaExpr( assign, new VariableExpr( returnDecl ) );
-				}
-				// move env from appExpr to retExpr
-				std::swap( assign->env, appExpr->env );
-				return assign;
-			} else {
-				return appExpr;
-			} // if
-		}
-
-		void ResolveCopyCtors::premutate( StmtExpr * stmtExpr ) {
-			// function call temporaries should be placed at statement-level, rather than nested inside of a new statement expression,
-			// since temporaries can be shared across sub-expressions, e.g.
-			//   [A, A] f();       // decl
-			//   g([A] x, [A] y);  // decl
-			//   g(f());           // call
-			// f is executed once, so the return temporary is shared across the tuple constructors for x and y.
-			// Explicitly mutating children instead of mutating the inner compound statement forces the temporaries to be added
-			// to the outer context, rather than inside of the statement expression.
-			visit_children = false;
-
-			assert( env );
-
-			indexer.enterScope();
-			// visit all statements
-			std::list< Statement * > & stmts = stmtExpr->statements->get_kids();
-			for ( Statement *& stmt : stmts ) {
-				stmt = stmt->acceptMutator( *visitor );
-			} // for
-			indexer.leaveScope();
-
-			assert( stmtExpr->result );
-			Type * result = stmtExpr->result;
-			if ( ! result->isVoid() ) {
-				static UniqueName retNamer("_tmp_stmtexpr_ret");
-
-				result = result->clone();
-				env->apply( result );
-				if ( ! InitTweak::isConstructable( result ) ) {
-					delete result;
-					return;
-				}
-
-				// create variable that will hold the result of the stmt expr
-				ObjectDecl * ret = ObjectDecl::newObject( retNamer.newName(), result, nullptr );
-				ret->type->set_const( false );
-				stmtsToAddBefore.push_back( new DeclStmt( ret ) );
-
-				assertf(
-					stmtExpr->resultExpr,
-					"Statement-Expression should have a resulting expression at %s:%d",
-					stmtExpr->location.filename.c_str(),
-					stmtExpr->location.first_line
-				);
-
-				ExprStmt * last = stmtExpr->resultExpr;
-				try {
-					last->expr = makeCtorDtor( "?{}", ret, last->expr );
-				} catch(...) {
-					std::cerr << "*CFA internal error: ";
-					std::cerr << "can't resolve implicit constructor";
-					std::cerr << " at " << stmtExpr->location.filename;
-					std::cerr << ":" << stmtExpr->location.first_line << std::endl;
-
-					abort();
-				}
-
-				// add destructors after current statement
-				stmtsToAddAfter.push_back( new ExprStmt( makeCtorDtor( "^?{}", ret ) ) );
-
-				// must have a non-empty body, otherwise it wouldn't have a result
-				assert( ! stmts.empty() );
-
-				// if there is a return decl, add a use as the last statement; will not have return decl on non-constructable returns
-				stmts.push_back( new ExprStmt( new VariableExpr( ret ) ) );
-			} // if
-
-			assert( stmtExpr->returnDecls.empty() );
-			assert( stmtExpr->dtors.empty() );
-		}
-
-		// to prevent warnings ('_unq0' may be used uninitialized in this function),
-		// insert an appropriate zero initializer for UniqueExpr temporaries.
-		Initializer * makeInit( Type * t ) {
-			if ( StructInstType * inst = dynamic_cast< StructInstType * >( t ) ) {
-				// initizer for empty struct must be empty
-				if ( inst->baseStruct->members.empty() ) return new ListInit({});
-			} else if ( UnionInstType * inst = dynamic_cast< UnionInstType * >( t ) ) {
-				// initizer for empty union must be empty
-				if ( inst->baseUnion->members.empty() ) return new ListInit({});
-			}
-
-			return new ListInit( { new SingleInit( new ConstantExpr( Constant::from_int( 0 ) ) ) } );
-		}
-
-		void ResolveCopyCtors::premutate( UniqueExpr * unqExpr ) {
-			visit_children = false;
-			// xxx - hack to prevent double-handling of unique exprs, otherwise too many temporary variables and destructors are generated
-			static std::unordered_map< int, UniqueExpr * > unqMap;
-			if ( ! unqMap.count( unqExpr->get_id() ) ) {
-				// resolve expr and find its
-
-				ImplicitCopyCtorExpr * impCpCtorExpr = dynamic_cast< ImplicitCopyCtorExpr * >( unqExpr->expr );
-				// PassVisitor<ResolveCopyCtors> fixer;
-				unqExpr->expr = unqExpr->expr->acceptMutator( *visitor );
-
-				// it should never be necessary to wrap a void-returning expression in a UniqueExpr - if this assumption changes, this needs to be rethought
-				assert( unqExpr->result );
-				if ( impCpCtorExpr ) {
-					CommaExpr * comma = strict_dynamic_cast< CommaExpr * >( unqExpr->expr );
-					VariableExpr * var = strict_dynamic_cast<VariableExpr *>( comma->arg2 );
-					// note the variable used as the result from the call
-					unqExpr->var = var->clone();
-				} else {
-					// expr isn't a call expr, so create a new temporary variable to use to hold the value of the unique expression
-					unqExpr->object = ObjectDecl::newObject( toString("_unq", unqExpr->get_id()), unqExpr->result->clone(), makeInit( unqExpr->result ) );
-					unqExpr->var = new VariableExpr( unqExpr->object );
-				}
-
-				// stmtsToAddBefore.splice( stmtsToAddBefore.end(), fixer.pass.stmtsToAddBefore );
-				// stmtsToAddAfter.splice( stmtsToAddAfter.end(), fixer.pass.stmtsToAddAfter );
-				unqMap[unqExpr->get_id()] = unqExpr;
-			} else {
-				// take data from other UniqueExpr to ensure consistency
-				delete unqExpr->get_expr();
-				unqExpr->expr = unqMap[unqExpr->get_id()]->expr->clone();
-				delete unqExpr->result;
-				unqExpr->result = maybeClone( unqExpr->expr->result );
-			}
-		}
-
-		DeclarationWithType * FixInit::postmutate( ObjectDecl *objDecl ) {
-			// since this removes the init field from objDecl, it must occur after children are mutated (i.e. postmutate)
-			if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) {
-				// a decision should have been made by the resolver, so ctor and init are not both non-NULL
-				assert( ! ctorInit->get_ctor() || ! ctorInit->get_init() );
-				if ( Statement * ctor = ctorInit->get_ctor() ) {
-					if ( objDecl->get_storageClasses().is_static ) {
-
-						// The ojbect needs to go in the data section, regardless of dtor complexity below.
-						// The attribute works, and is meant to apply, both for leaving the static local alone,
-						// and for hoisting it out as a static global.
-						addDataSectionAttribute( objDecl );
-
-						// originally wanted to take advantage of gcc nested functions, but
-						// we get memory errors with this approach. To remedy this, the static
-						// variable is hoisted when the destructor needs to be called.
-						//
-						// generate:
-						// static T __objName_static_varN;
-						// void __objName_dtor_atexitN() {
-						//   __dtor__...;
-						// }
-						// int f(...) {
-						//   ...
-						//   static bool __objName_uninitialized = true;
-						//   if (__objName_uninitialized) {
-						//     __ctor(__objName);
-						//     __objName_uninitialized = false;
-						//     atexit(__objName_dtor_atexitN);
-						//   }
-						//   ...
-						// }
-
-						static UniqueName dtorCallerNamer( "_dtor_atexit" );
-
-						// static bool __objName_uninitialized = true
-						BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool );
-						SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant::from_int( 1 ) ) );
-						ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, boolType, boolInitExpr );
-						isUninitializedVar->fixUniqueId();
-
-						// __objName_uninitialized = false;
-						UntypedExpr * setTrue = new UntypedExpr( new NameExpr( "?=?" ) );
-						setTrue->get_args().push_back( new VariableExpr( isUninitializedVar ) );
-						setTrue->get_args().push_back( new ConstantExpr( Constant::from_int( 0 ) ) );
-
-						// generate body of if
-						CompoundStmt * initStmts = new CompoundStmt();
-						std::list< Statement * > & body = initStmts->get_kids();
-						body.push_back( ctor );
-						body.push_back( new ExprStmt( setTrue ) );
-
-						// put it all together
-						IfStmt * ifStmt = new IfStmt( new VariableExpr( isUninitializedVar ), initStmts, 0 );
-						stmtsToAddAfter.push_back( new DeclStmt( isUninitializedVar ) );
-						stmtsToAddAfter.push_back( ifStmt );
-
-						Statement * dtor = ctorInit->get_dtor();
-						objDecl->set_init( nullptr );
-						ctorInit->set_ctor( nullptr );
-						ctorInit->set_dtor( nullptr );
-						if ( dtor ) {
-							// if the object has a non-trivial destructor, have to
-							// hoist it and the object into the global space and
-							// call the destructor function with atexit.
-
-							Statement * dtorStmt = dtor->clone();
-
-							// void __objName_dtor_atexitN(...) {...}
-							FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + dtorCallerNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt() );
-							dtorCaller->fixUniqueId();
-							dtorCaller->get_statements()->push_back( dtorStmt );
-
-							// atexit(dtor_atexit);
-							UntypedExpr * callAtexit = new UntypedExpr( new NameExpr( "atexit" ) );
-							callAtexit->get_args().push_back( new VariableExpr( dtorCaller ) );
-
-							body.push_back( new ExprStmt( callAtexit ) );
-
-							// hoist variable and dtor caller decls to list of decls that will be added into global scope
-							staticDtorDecls.push_back( objDecl );
-							staticDtorDecls.push_back( dtorCaller );
-
-							// need to rename object uniquely since it now appears
-							// at global scope and there could be multiple function-scoped
-							// static variables with the same name in different functions.
-							// Note: it isn't sufficient to modify only the mangleName, because
-							// then subsequent Indexer passes can choke on seeing the object's name
-							// if another object has the same name and type. An unfortunate side-effect
-							// of renaming the object is that subsequent NameExprs may fail to resolve,
-							// but there shouldn't be any remaining past this point.
-							static UniqueName staticNamer( "_static_var" );
-							objDecl->set_name( objDecl->get_name() + staticNamer.newName() );
-							objDecl->set_mangleName( SymTab::Mangler::mangle( objDecl ) );
-
-							// xxx - temporary hack: need to return a declaration, but want to hoist the current object out of this scope
-							// create a new object which is never used
-							static UniqueName dummyNamer( "_dummy" );
-							ObjectDecl * dummy = new ObjectDecl( dummyNamer.newName(), Type::StorageClasses( Type::Static ), LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), 0, std::list< Attribute * >{ new Attribute("unused") } );
-							delete ctorInit;
-							return dummy;
-						}
-					} else {
-						ImplicitCtorDtorStmt * implicit = strict_dynamic_cast< ImplicitCtorDtorStmt * > ( ctor );
-						ExprStmt * ctorStmt = dynamic_cast< ExprStmt * >( implicit->callStmt );
-						ApplicationExpr * ctorCall = nullptr;
-						if ( ctorStmt && (ctorCall = isIntrinsicCallExpr( ctorStmt->expr )) && ctorCall->get_args().size() == 2 ) {
-							// clean up intrinsic copy constructor calls by making them into SingleInits
-							Expression * ctorArg = ctorCall->args.back();
-							std::swap( ctorArg->env, ctorCall->env );
-							objDecl->init = new SingleInit( ctorArg );
-
-							ctorCall->args.pop_back();
-						} else {
-							stmtsToAddAfter.push_back( ctor );
-							objDecl->init = nullptr;
-							ctorInit->ctor = nullptr;
-						}
-
-						Statement * dtor = ctorInit->dtor;
-						if ( dtor ) {
-							ImplicitCtorDtorStmt * implicit = strict_dynamic_cast< ImplicitCtorDtorStmt * >( dtor );
-							Statement * dtorStmt = implicit->callStmt;
-
-							// don't need to call intrinsic dtor, because it does nothing, but
-							// non-intrinsic dtors must be called
-							if ( ! isIntrinsicSingleArgCallStmt( dtorStmt ) ) {
-								// set dtor location to the object's location for error messages
-								DeclarationWithType * dtorFunc = getDtorFunc( objDecl, dtorStmt, stmtsToAddBefore );
-								objDecl->attributes.push_back( new Attribute( "cleanup", { new VariableExpr( dtorFunc ) } ) );
-								ctorInit->dtor = nullptr;
-							} // if
-						}
-					} // if
-				} else if ( Initializer * init = ctorInit->init ) {
-					objDecl->init = init;
-					ctorInit->init = nullptr;
-				} else {
-					// no constructor and no initializer, which is okay
-					objDecl->init = nullptr;
-				} // if
-				delete ctorInit;
-			} // if
-			return objDecl;
-		}
-
-		void ObjDeclCollector::previsit( CompoundStmt * ) {
-			GuardValue( curVars );
-		}
-
-		void ObjDeclCollector::previsit( DeclStmt * stmt ) {
-			// keep track of all variables currently in scope
-			if ( ObjectDecl * objDecl = dynamic_cast< ObjectDecl * > ( stmt->get_decl() ) ) {
-				curVars.push_back( objDecl );
-			} // if
-		}
-
-		void LabelFinder::previsit( Statement * stmt ) {
-			// for each label, remember the variables in scope at that label.
-			for ( Label l : stmt->get_labels() ) {
-				vars[l] = curVars;
-			} // for
-		}
-
-		void LabelFinder::previsit( CompoundStmt * stmt ) {
-			previsit( (Statement *)stmt );
-			Parent::previsit( stmt );
-		}
-
-		void LabelFinder::previsit( DeclStmt * stmt ) {
-			previsit( (Statement *)stmt );
-			Parent::previsit( stmt );
-		}
-
-
-		void InsertDtors::previsit( FunctionDecl * funcDecl ) {
-			// each function needs to have its own set of labels
-			GuardValue( labelVars );
-			labelVars.clear();
-			// LabelFinder does not recurse into FunctionDecl, so need to visit
-			// its children manually.
-			maybeAccept( funcDecl->type, finder );
-			maybeAccept( funcDecl->statements, finder );
-
-			// all labels for this function have been collected, insert destructors as appropriate via implicit recursion.
-		}
-
-		// Handle break/continue/goto in the same manner as C++.  Basic idea: any objects that are in scope at the
-		// BranchStmt but not at the labelled (target) statement must be destructed.  If there are any objects in scope
-		// at the target location but not at the BranchStmt then those objects would be uninitialized so notify the user
-		// of the error.  See C++ Reference 6.6 Jump Statements for details.
-		void InsertDtors::handleGoto( BranchStmt * stmt ) {
-			// can't do anything for computed goto
-			if ( stmt->computedTarget ) return;
-
-			assertf( stmt->get_target() != "", "BranchStmt missing a label: %s", toString( stmt ).c_str() );
-			// S_L = lvars = set of objects in scope at label definition
-			// S_G = curVars = set of objects in scope at goto statement
-			ObjectSet & lvars = labelVars[ stmt->get_target() ];
-
-			DTOR_PRINT(
-				std::cerr << "at goto label: " << stmt->get_target().get_name() << std::endl;
-				std::cerr << "S_G = " << printSet( curVars ) << std::endl;
-				std::cerr << "S_L = " << printSet( lvars ) << std::endl;
-			)
-
-
-			// std::set_difference requires that the inputs be sorted.
-			lvars.sort();
-			curVars.sort();
-
-			ObjectSet diff;
-			// S_L-S_G results in set of objects whose construction is skipped - it's an error if this set is non-empty
-			std::set_difference( lvars.begin(), lvars.end(), curVars.begin(), curVars.end(), std::inserter( diff, diff.begin() ) );
-			DTOR_PRINT(
-				std::cerr << "S_L-S_G = " << printSet( diff ) << std::endl;
-			)
-			if ( ! diff.empty() ) {
-				SemanticError( stmt, std::string("jump to label '") + stmt->get_target().get_name() + "' crosses initialization of " + (*diff.begin())->get_name() + " " );
-			} // if
-		}
-
-		void InsertDtors::previsit( BranchStmt * stmt ) {
-			switch( stmt->get_type() ) {
-			  case BranchStmt::Continue:
-			  case BranchStmt::Break:
-				// could optimize the break/continue case, because the S_L-S_G check is unnecessary (this set should
-				// always be empty), but it serves as a small sanity check.
-			  case BranchStmt::Goto:
-				handleGoto( stmt );
-				break;
-			  default:
-				assert( false );
-			} // switch
-		}
-
-		bool checkWarnings( FunctionDecl * funcDecl ) {
-			// only check for warnings if the current function is a user-defined
-			// constructor or destructor
-			if ( ! funcDecl ) return false;
-			if ( ! funcDecl->get_statements() ) return false;
-			return CodeGen::isCtorDtor( funcDecl->get_name() ) && ! LinkageSpec::isOverridable( funcDecl->get_linkage() );
-		}
-
-		void GenStructMemberCalls::premutate( FunctionDecl * funcDecl ) {
-			GuardValue( function );
-			GuardValue( unhandled );
-			GuardValue( usedUninit );
-			GuardValue( thisParam );
-			GuardValue( isCtor );
-			GuardValue( structDecl );
-			errors = SemanticErrorException();  // clear previous errors
-
-			// need to start with fresh sets
-			unhandled.clear();
-			usedUninit.clear();
-
-			function = funcDecl;
-			isCtor = CodeGen::isConstructor( function->get_name() );
-			if ( checkWarnings( function ) ) {
-				FunctionType * type = function->get_functionType();
-				assert( ! type->get_parameters().empty() );
-				thisParam = strict_dynamic_cast< ObjectDecl * >( type->get_parameters().front() );
-				Type * thisType = getPointerBase( thisParam->get_type() );
-				StructInstType * structType = dynamic_cast< StructInstType * >( thisType );
-				if ( structType ) {
-					structDecl = structType->get_baseStruct();
-					for ( Declaration * member : structDecl->get_members() ) {
-						if ( ObjectDecl * field = dynamic_cast< ObjectDecl * >( member ) ) {
-							// record all of the struct type's members that need to be constructed or
-							// destructed by the end of the function
-							unhandled.insert( field );
-						}
-					}
-				}
-			}
-		}
-
-		DeclarationWithType * GenStructMemberCalls::postmutate( FunctionDecl * funcDecl ) {
-			// remove the unhandled objects from usedUninit, because a call is inserted
-			// to handle them - only objects that are later constructed are used uninitialized.
-			std::map< DeclarationWithType *, CodeLocation > diff;
-			// need the comparator since usedUninit and unhandled have different types
-			struct comp_t {
-				typedef decltype(usedUninit)::value_type usedUninit_t;
-				typedef decltype(unhandled)::value_type unhandled_t;
-				bool operator()(usedUninit_t x, unhandled_t y) { return x.first < y; }
-				bool operator()(unhandled_t x, usedUninit_t y) { return x < y.first; }
-			} comp;
-			std::set_difference( usedUninit.begin(), usedUninit.end(), unhandled.begin(), unhandled.end(), std::inserter( diff, diff.begin() ), comp );
-			for ( auto p : diff ) {
-				DeclarationWithType * member = p.first;
-				CodeLocation loc = p.second;
-				// xxx - make error message better by also tracking the location that the object is constructed at?
-				emit( loc, "in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", member->get_name(), " used before being constructed" );
-			}
-
-			if ( ! unhandled.empty() ) {
-				// need to explicitly re-add function parameters to the indexer in order to resolve copy constructors
-				auto guard = makeFuncGuard( [this]() { indexer.enterScope(); }, [this]() { indexer.leaveScope(); } );
-				indexer.addFunctionType( function->type );
-
-				// need to iterate through members in reverse in order for
-				// ctor/dtor statements to come out in the right order
-				for ( Declaration * member : reverseIterate( structDecl->get_members() ) ) {
-					DeclarationWithType * field = dynamic_cast< DeclarationWithType * >( member );
-					// skip non-DWT members
-					if ( ! field ) continue;
-					// skip non-constructable members
-					if ( ! tryConstruct( field ) ) continue;
-					// skip handled members
-					if ( ! unhandled.count( field ) ) continue;
-
-					// insert and resolve default/copy constructor call for each field that's unhandled
-					std::list< Statement * > stmt;
-					Expression * arg2 = nullptr;
-					if ( isCopyConstructor( function ) ) {
-						// if copy ctor, need to pass second-param-of-this-function.field
-						std::list< DeclarationWithType * > & params = function->get_functionType()->get_parameters();
-						assert( params.size() == 2 );
-						arg2 = new MemberExpr( field, new VariableExpr( params.back() ) );
-					}
-					InitExpander_old srcParam( arg2 );
-					// cast away reference type and construct field.
-					Expression * thisExpr = new CastExpr( new VariableExpr( thisParam ), thisParam->get_type()->stripReferences()->clone() );
-					Expression * memberDest = new MemberExpr( field, thisExpr );
-					SymTab::genImplicitCall( srcParam, memberDest, function->get_name(), back_inserter( stmt ), field, isCtor );
-
-					assert( stmt.size() <= 1 );
-					if ( stmt.size() == 1 ) {
-						Statement * callStmt = stmt.front();
-
-						try {
-							callStmt->acceptMutator( *visitor );
-							if ( isCtor ) {
-								function->statements->push_front( callStmt );
-							} else { // TODO: don't generate destructor function/object for intrinsic calls
-								// destructor statements should be added at the end
-								// function->get_statements()->push_back( callStmt );
-
-								// Optimization: do not need to call intrinsic destructors on members
-								if ( isIntrinsicSingleArgCallStmt( callStmt ) ) continue;;
-
-								// __Destructor _dtor0 = { (void *)&b.a1, (void (*)(void *)_destroy_A };
-								std::list< Statement * > stmtsToAdd;
-
-								static UniqueName memberDtorNamer = { "__memberDtor" };
-								assertf( Validate::dtorStruct, "builtin __Destructor not found." );
-								assertf( Validate::dtorStructDestroy, "builtin __destroy_Destructor not found." );
-
-								Expression * thisExpr = new CastExpr( new AddressExpr( new VariableExpr( thisParam ) ), new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ) );
-								Expression * dtorExpr = new VariableExpr( getDtorFunc( thisParam, callStmt, stmtsToAdd ) );
-
-								// cast destructor pointer to void (*)(void *), to silence GCC incompatible pointer warnings
-								FunctionType * dtorFtype = new FunctionType( Type::Qualifiers(), false );
-								dtorFtype->parameters.push_back( ObjectDecl::newObject( "", new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), nullptr ) );
-								Type * dtorType = new PointerType( Type::Qualifiers(), dtorFtype );
-
-								ObjectDecl * destructor = ObjectDecl::newObject( memberDtorNamer.newName(), new StructInstType( Type::Qualifiers(), Validate::dtorStruct ), new ListInit( { new SingleInit( thisExpr ), new SingleInit( new CastExpr( dtorExpr, dtorType ) ) } ) );
-								function->statements->push_front( new DeclStmt( destructor ) );
-								destructor->attributes.push_back( new Attribute( "cleanup", { new VariableExpr( Validate::dtorStructDestroy ) } ) );
-
-								function->statements->kids.splice( function->statements->kids.begin(), stmtsToAdd );
-							}
-						} catch ( SemanticErrorException & error ) {
-							emit( funcDecl->location, "in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", field->get_name(), " not explicitly ", isCtor ? "constructed" : "destructed",  " and no ", isCtor ? "default constructor" : "destructor", " found" );
-						}
-					}
-				}
-			}
-			if (! errors.isEmpty()) {
-				throw errors;
-			}
-			return funcDecl;
-		}
-
-		/// true if expr is effectively just the 'this' parameter
-		bool isThisExpression( Expression * expr, DeclarationWithType * thisParam ) {
-			// TODO: there are more complicated ways to pass 'this' to a constructor, e.g. &*, *&, etc.
-			if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( expr ) ) {
-				return varExpr->get_var() == thisParam;
-			} else if ( CastExpr * castExpr = dynamic_cast< CastExpr * > ( expr ) ) {
-				return isThisExpression( castExpr->get_arg(), thisParam );
-			}
-			return false;
-		}
-
-		/// returns a MemberExpr if expr is effectively just member access on the 'this' parameter, else nullptr
-		MemberExpr * isThisMemberExpr( Expression * expr, DeclarationWithType * thisParam ) {
-			if ( MemberExpr * memberExpr = dynamic_cast< MemberExpr * >( expr ) ) {
-				if ( isThisExpression( memberExpr->get_aggregate(), thisParam ) ) {
-					return memberExpr;
-				}
-			} else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) {
-				return isThisMemberExpr( castExpr->get_arg(), thisParam );
-			}
-			return nullptr;
-		}
-
-		void GenStructMemberCalls::premutate( ApplicationExpr * appExpr ) {
-			if ( ! checkWarnings( function ) ) {
-				visit_children = false;
-				return;
-			}
-
-			std::string fname = getFunctionName( appExpr );
-			if ( fname == function->name ) {
-				// call to same kind of function
-				Expression * firstParam = appExpr->args.front();
-
-				if ( isThisExpression( firstParam, thisParam ) ) {
-					// if calling another constructor on thisParam, assume that function handles
-					// all members - if it doesn't a warning will appear in that function.
-					unhandled.clear();
-				} else if ( MemberExpr * memberExpr = isThisMemberExpr( firstParam, thisParam ) ) {
-					// if first parameter is a member expression on the this parameter,
-					// then remove the member from unhandled set.
-					if ( isThisExpression( memberExpr->aggregate, thisParam ) ) {
-						unhandled.erase( memberExpr->member );
-					}
-				}
-			}
-		}
-
-		void GenStructMemberCalls::premutate( MemberExpr * memberExpr ) {
-			if ( ! checkWarnings( function ) || ! isCtor ) {
-				visit_children = false;
-				return;
-			}
-
-			if ( isThisExpression( memberExpr->get_aggregate(), thisParam ) ) {
-				if ( unhandled.count( memberExpr->get_member() ) ) {
-					// emit a warning because a member was used before it was constructed
-					usedUninit.insert( { memberExpr->get_member(), memberExpr->location } );
-				}
-			}
-		}
-
-		template< typename... Params >
-		void GenStructMemberCalls::emit( CodeLocation loc, const Params &... params ) {
-			SemanticErrorException err( loc, toString( params... ) );
-			errors.append( err );
-		}
-
-		Expression * GenStructMemberCalls::postmutate( UntypedExpr * untypedExpr ) {
-			Expression * newExpr = untypedExpr;
-			ResolvExpr::findVoidExpression( newExpr, indexer );
-			return newExpr;
-		}
-
-		Expression * FixCtorExprs::postmutate( ConstructorExpr * ctorExpr ) {
-			static UniqueName tempNamer( "_tmp_ctor_expr" );
-			// xxx - is the size check necessary?
-			assert( ctorExpr->result && ctorExpr->get_result()->size() == 1 );
-
-			// xxx - this can be TupleAssignExpr now. Need to properly handle this case.
-			ApplicationExpr * callExpr = strict_dynamic_cast< ApplicationExpr * > ( ctorExpr->get_callExpr() );
-			TypeSubstitution * env = ctorExpr->get_env();
-			ctorExpr->set_callExpr( nullptr );
-			ctorExpr->set_env( nullptr );
-
-			// xxx - ideally we would reuse the temporary generated from the copy constructor passes from within firstArg if it exists and not generate a temporary if it's unnecessary.
-			ObjectDecl * tmp = ObjectDecl::newObject( tempNamer.newName(), callExpr->args.front()->result->clone(), nullptr );
-			declsToAddBefore.push_back( tmp );
-			delete ctorExpr;
-
-			// build assignment and replace constructor's first argument with new temporary
-			Expression *& firstArg = callExpr->get_args().front();
-			Expression * assign = new UntypedExpr( new NameExpr( "?=?" ), { new AddressExpr( new VariableExpr( tmp ) ), new AddressExpr( firstArg ) } );
-			firstArg = new VariableExpr( tmp );
-
-			// resolve assignment and dispose of new env
-			ResolvExpr::findVoidExpression( assign, indexer );
-			delete assign->env;
-			assign->env = nullptr;
-
-			// for constructor expr:
-			//   T x;
-			//   x{};
-			// results in:
-			//   T x;
-			//   T & tmp;
-			//   &tmp = &x, ?{}(tmp), tmp
-			CommaExpr * commaExpr = new CommaExpr( assign, new CommaExpr( callExpr, new VariableExpr( tmp ) ) );
-			commaExpr->set_env( env );
-			return commaExpr;
-		}
-	} // namespace
-} // namespace InitTweak
-
-// Local Variables: //
-// tab-width: 4 //
-// mode: c++ //
-// compile-command: "make install" //
-// End: //
Index: src/InitTweak/FixInitNew.cpp
===================================================================
--- src/InitTweak/FixInitNew.cpp	(revision fa761c2aa9a4a9b1a22e28f45f380ba9d9ad36c0)
+++ src/InitTweak/FixInitNew.cpp	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -178,7 +178,4 @@
 /// (currently by FixInit)
 struct InsertDtors final : public ObjDeclCollector, public ast::WithStmtsToAdd<> {
-	typedef std::list< ObjectDecl * > OrderedDecls;
-	typedef std::list< OrderedDecls > OrderedDeclsStack;
-
 	InsertDtors( ast::Pass<LabelFinder> & finder ) : finder( finder ), labelVars( finder.core.vars ) {}
 
@@ -194,5 +191,4 @@
 	ast::Pass<LabelFinder> & finder;
 	LabelFinder::LabelMap & labelVars;
-	OrderedDeclsStack reverseDeclOrder;
 };
 
Index: src/InitTweak/GenInit.cc
===================================================================
--- src/InitTweak/GenInit.cc	(revision fa761c2aa9a4a9b1a22e28f45f380ba9d9ad36c0)
+++ src/InitTweak/GenInit.cc	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -29,5 +29,4 @@
 #include "CompilationState.h"
 #include "CodeGen/OperatorTable.h"
-#include "Common/PassVisitor.h"        // for PassVisitor, WithGuards, WithShort...
 #include "Common/SemanticError.h"      // for SemanticError
 #include "Common/ToString.hpp"         // for toCString
@@ -38,262 +37,10 @@
 #include "InitTweak.h"                 // for isConstExpr, InitExpander, checkIn...
 #include "ResolvExpr/Resolver.h"
-#include "SymTab/Autogen.h"            // for genImplicitCall
 #include "SymTab/GenImplicitCall.hpp"  // for genImplicitCall
 #include "SymTab/Mangler.h"            // for Mangler
-#include "SynTree/LinkageSpec.h"       // for isOverridable, C
-#include "SynTree/Declaration.h"       // for ObjectDecl, DeclarationWithType
-#include "SynTree/Expression.h"        // for VariableExpr, UntypedExpr, Address...
-#include "SynTree/Initializer.h"       // for ConstructorInit, SingleInit, Initi...
-#include "SynTree/Label.h"             // for Label
-#include "SynTree/Mutator.h"           // for mutateAll
-#include "SynTree/Statement.h"         // for CompoundStmt, ImplicitCtorDtorStmt
-#include "SynTree/Type.h"              // for Type, ArrayType, Type::Qualifiers
-#include "SynTree/Visitor.h"           // for acceptAll, maybeAccept
 #include "Tuples/Tuples.h"             // for maybeImpure
 #include "Validate/FindSpecialDecls.h" // for SizeType
 
 namespace InitTweak {
-	namespace {
-		const std::list<Label> noLabels;
-		const std::list<Expression *> noDesignators;
-	}
-
-	struct ReturnFixer : public WithStmtsToAdd, public WithGuards {
-		/// consistently allocates a temporary variable for the return value
-		/// of a function so that anything which the resolver decides can be constructed
-		/// into the return type of a function can be returned.
-		static void makeReturnTemp( std::list< Declaration * > &translationUnit );
-
-		void premutate( FunctionDecl *functionDecl );
-		void premutate( ReturnStmt * returnStmt );
-
-	  protected:
-		FunctionType * ftype = nullptr;
-		std::string funcName;
-	};
-
-	struct CtorDtor : public WithGuards, public WithShortCircuiting, public WithVisitorRef<CtorDtor>  {
-		/// create constructor and destructor statements for object declarations.
-		/// the actual call statements will be added in after the resolver has run
-		/// so that the initializer expression is only removed if a constructor is found
-		/// and the same destructor call is inserted in all of the appropriate locations.
-		static void generateCtorDtor( std::list< Declaration * > &translationUnit );
-
-		void previsit( ObjectDecl * );
-		void previsit( FunctionDecl *functionDecl );
-
-		// should not traverse into any of these declarations to find objects
-		// that need to be constructed or destructed
-		void previsit( StructDecl *aggregateDecl );
-		void previsit( AggregateDecl * ) { visit_children = false; }
-		void previsit( NamedTypeDecl * ) { visit_children = false; }
-		void previsit( FunctionType * ) { visit_children = false; }
-
-		void previsit( CompoundStmt * compoundStmt );
-
-	  private:
-		// set of mangled type names for which a constructor or destructor exists in the current scope.
-		// these types require a ConstructorInit node to be generated, anything else is a POD type and thus
-		// should not have a ConstructorInit generated.
-
-		ManagedTypes managedTypes;
-		bool inFunction = false;
-	};
-
-	struct HoistArrayDimension final : public WithDeclsToAdd, public WithShortCircuiting, public WithGuards, public WithIndexer {
-		/// hoist dimension from array types in object declaration so that it uses a single
-		/// const variable of type size_t, so that side effecting array dimensions are only
-		/// computed once.
-		static void hoistArrayDimension( std::list< Declaration * > & translationUnit );
-
-		void premutate( ObjectDecl * objectDecl );
-		DeclarationWithType * postmutate( ObjectDecl * objectDecl );
-		void premutate( FunctionDecl *functionDecl );
-		// should not traverse into any of these declarations to find objects
-		// that need to be constructed or destructed
-		void premutate( AggregateDecl * ) { visit_children = false; }
-		void premutate( NamedTypeDecl * ) { visit_children = false; }
-		void premutate( FunctionType * ) { visit_children = false; }
-
-		// need this so that enumerators are added to the indexer, due to premutate(AggregateDecl *)
-		void premutate( EnumDecl * ) {}
-
-		void hoist( Type * type );
-
-		Type::StorageClasses storageClasses;
-		bool inFunction = false;
-	};
-
-	struct HoistArrayDimension_NoResolve final : public WithDeclsToAdd, public WithShortCircuiting, public WithGuards {
-		/// hoist dimension from array types in object declaration so that it uses a single
-		/// const variable of type size_t, so that side effecting array dimensions are only
-		/// computed once.
-		static void hoistArrayDimension( std::list< Declaration * > & translationUnit );
-
-		void premutate( ObjectDecl * objectDecl );
-		DeclarationWithType * postmutate( ObjectDecl * objectDecl );
-		void premutate( FunctionDecl *functionDecl );
-		// should not traverse into any of these declarations to find objects
-		// that need to be constructed or destructed
-		void premutate( AggregateDecl * ) { visit_children = false; }
-		void premutate( NamedTypeDecl * ) { visit_children = false; }
-		void premutate( FunctionType * ) { visit_children = false; }
-
-		void hoist( Type * type );
-
-		Type::StorageClasses storageClasses;
-		bool inFunction = false;
-	};
-
-	void genInit( std::list< Declaration * > & translationUnit ) {
-		if (!useNewAST) {
-			HoistArrayDimension::hoistArrayDimension( translationUnit );
-		}
-		else {
-			HoistArrayDimension_NoResolve::hoistArrayDimension( translationUnit );
-		}
-		fixReturnStatements( translationUnit );
-
-		if (!useNewAST) {
-			CtorDtor::generateCtorDtor( translationUnit );
-		}
-	}
-
-	void fixReturnStatements( std::list< Declaration * > & translationUnit ) {
-		PassVisitor<ReturnFixer> fixer;
-		mutateAll( translationUnit, fixer );
-	}
-
-	void ReturnFixer::premutate( ReturnStmt *returnStmt ) {
-		std::list< DeclarationWithType * > & returnVals = ftype->get_returnVals();
-		assert( returnVals.size() == 0 || returnVals.size() == 1 );
-		// hands off if the function returns a reference - we don't want to allocate a temporary if a variable's address
-		// is being returned
-		if ( returnStmt->expr && returnVals.size() == 1 && isConstructable( returnVals.front()->get_type() ) ) {
-			// explicitly construct the return value using the return expression and the retVal object
-			assertf( returnVals.front()->name != "", "Function %s has unnamed return value\n", funcName.c_str() );
-
-			ObjectDecl * retVal = strict_dynamic_cast< ObjectDecl * >( returnVals.front() );
-			if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( returnStmt->expr ) ) {
-				// return statement has already been mutated - don't need to do it again
-				if ( varExpr->var == retVal ) return;
-			}
-			Statement * stmt = genCtorDtor( "?{}", retVal, returnStmt->expr );
-			assertf( stmt, "ReturnFixer: genCtorDtor returned nullptr: %s / %s", toString( retVal ).c_str(), toString( returnStmt->expr ).c_str() );
-			stmtsToAddBefore.push_back( stmt );
-
-			// return the retVal object
-			returnStmt->expr = new VariableExpr( returnVals.front() );
-		} // if
-	}
-
-	void ReturnFixer::premutate( FunctionDecl *functionDecl ) {
-		GuardValue( ftype );
-		GuardValue( funcName );
-
-		ftype = functionDecl->type;
-		funcName = functionDecl->name;
-	}
-
-	// precompute array dimension expression, because constructor generation may duplicate it,
-	// which would be incorrect if it is a side-effecting computation.
-	void HoistArrayDimension::hoistArrayDimension( std::list< Declaration * > & translationUnit ) {
-		PassVisitor<HoistArrayDimension> hoister;
-		mutateAll( translationUnit, hoister );
-	}
-
-	void HoistArrayDimension::premutate( ObjectDecl * objectDecl ) {
-		GuardValue( storageClasses );
-		storageClasses = objectDecl->get_storageClasses();
-	}
-
-	DeclarationWithType * HoistArrayDimension::postmutate( ObjectDecl * objectDecl ) {
-		hoist( objectDecl->get_type() );
-		return objectDecl;
-	}
-
-	void HoistArrayDimension::hoist( Type * type ) {
-		// if in function, generate const size_t var
-		static UniqueName dimensionName( "_array_dim" );
-
-		// C doesn't allow variable sized arrays at global scope or for static variables, so don't hoist dimension.
-		if ( ! inFunction ) return;
-		if ( storageClasses.is_static ) return;
-
-		if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) {
-			if ( ! arrayType->get_dimension() ) return; // xxx - recursive call to hoist?
-
-			// need to resolve array dimensions in order to accurately determine if constexpr
-			ResolvExpr::findSingleExpression( arrayType->dimension, Validate::SizeType->clone(), indexer );
-			// array is variable-length when the dimension is not constexpr
-			arrayType->isVarLen = ! isConstExpr( arrayType->dimension );
-			// don't need to hoist dimension if it's definitely pure - only need to if there's potential for side effects.
-			// xxx - hoisting has no side effects anyways, so don't skip since we delay resolve
-			// still try to detect constant expressions
-			if ( ! Tuples::maybeImpure( arrayType->dimension ) ) return;
-
-			ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storageClasses, LinkageSpec::C, 0, Validate::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) );
-			arrayDimension->get_type()->set_const( true );
-
-			arrayType->set_dimension( new VariableExpr( arrayDimension ) );
-			declsToAddBefore.push_back( arrayDimension );
-
-			hoist( arrayType->get_base() );
-			return;
-		}
-	}
-
-	void HoistArrayDimension::premutate( FunctionDecl * ) {
-		GuardValue( inFunction );
-		inFunction = true;
-	}
-
-	// precompute array dimension expression, because constructor generation may duplicate it,
-	// which would be incorrect if it is a side-effecting computation.
-	void HoistArrayDimension_NoResolve::hoistArrayDimension( std::list< Declaration * > & translationUnit ) {
-		PassVisitor<HoistArrayDimension_NoResolve> hoister;
-		mutateAll( translationUnit, hoister );
-	}
-
-	void HoistArrayDimension_NoResolve::premutate( ObjectDecl * objectDecl ) {
-		GuardValue( storageClasses );
-		storageClasses = objectDecl->get_storageClasses();
-	}
-
-	DeclarationWithType * HoistArrayDimension_NoResolve::postmutate( ObjectDecl * objectDecl ) {
-		hoist( objectDecl->get_type() );
-		return objectDecl;
-	}
-
-	void HoistArrayDimension_NoResolve::hoist( Type * type ) {
-		// if in function, generate const size_t var
-		static UniqueName dimensionName( "_array_dim" );
-
-		// C doesn't allow variable sized arrays at global scope or for static variables, so don't hoist dimension.
-		if ( ! inFunction ) return;
-		if ( storageClasses.is_static ) return;
-
-		if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) {
-			if ( ! arrayType->get_dimension() ) return; // xxx - recursive call to hoist?
-			// don't need to hoist dimension if it's definitely pure - only need to if there's potential for side effects.
-			// xxx - hoisting has no side effects anyways, so don't skip since we delay resolve
-			// still try to detect constant expressions
-			if ( ! Tuples::maybeImpure( arrayType->dimension ) ) return;
-
-			ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storageClasses, LinkageSpec::C, 0, Validate::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) );
-			arrayDimension->get_type()->set_const( true );
-
-			arrayType->set_dimension( new VariableExpr( arrayDimension ) );
-			declsToAddBefore.push_back( arrayDimension );
-
-			hoist( arrayType->get_base() );
-			return;
-		}
-	}
-
-	void HoistArrayDimension_NoResolve::premutate( FunctionDecl * ) {
-		GuardValue( inFunction );
-		inFunction = true;
-	}
 
 namespace {
@@ -526,66 +273,4 @@
 	}
 
-	void CtorDtor::generateCtorDtor( std::list< Declaration * > & translationUnit ) {
-		PassVisitor<CtorDtor> ctordtor;
-		acceptAll( translationUnit, ctordtor );
-	}
-
-	bool ManagedTypes::isManaged( Type * type ) const {
-		// references are never constructed
-		if ( dynamic_cast< ReferenceType * >( type ) ) return false;
-		// need to clear and reset qualifiers when determining if a type is managed
-		ValueGuard< Type::Qualifiers > qualifiers( type->get_qualifiers() );
-		type->get_qualifiers() = Type::Qualifiers();
-		if ( TupleType * tupleType = dynamic_cast< TupleType * > ( type ) ) {
-			// tuple is also managed if any of its components are managed
-			if ( std::any_of( tupleType->types.begin(), tupleType->types.end(), [&](Type * type) { return isManaged( type ); }) ) {
-				return true;
-			}
-		}
-		// a type is managed if it appears in the map of known managed types, or if it contains any polymorphism (is a type variable or generic type containing a type variable)
-		return managedTypes.find( SymTab::Mangler::mangleConcrete( type ) ) != managedTypes.end() || GenPoly::isPolyType( type );
-	}
-
-	bool ManagedTypes::isManaged( ObjectDecl * objDecl ) const {
-		Type * type = objDecl->get_type();
-		while ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
-			// must always construct VLAs with an initializer, since this is an error in C
-			if ( at->isVarLen && objDecl->init ) return true;
-			type = at->get_base();
-		}
-		return isManaged( type );
-	}
-
-	// why is this not just on FunctionDecl?
-	void ManagedTypes::handleDWT( DeclarationWithType * dwt ) {
-		// if this function is a user-defined constructor or destructor, mark down the type as "managed"
-		if ( ! LinkageSpec::isOverridable( dwt->get_linkage() ) && CodeGen::isCtorDtor( dwt->get_name() ) ) {
-			std::list< DeclarationWithType * > & params = GenPoly::getFunctionType( dwt->get_type() )->get_parameters();
-			assert( ! params.empty() );
-			Type * type = InitTweak::getPointerBase( params.front()->get_type() );
-			assert( type );
-			managedTypes.insert( SymTab::Mangler::mangleConcrete( type ) );
-		}
-	}
-
-	void ManagedTypes::handleStruct( StructDecl * aggregateDecl ) {
-		// don't construct members, but need to take note if there is a managed member,
-		// because that means that this type is also managed
-		for ( Declaration * member : aggregateDecl->get_members() ) {
-			if ( ObjectDecl * field = dynamic_cast< ObjectDecl * >( member ) ) {
-				if ( isManaged( field ) ) {
-					// generic parameters should not play a role in determining whether a generic type is constructed - construct all generic types, so that
-					// polymorphic constructors make generic types managed types
-					StructInstType inst( Type::Qualifiers(), aggregateDecl );
-					managedTypes.insert( SymTab::Mangler::mangleConcrete( &inst ) );
-					break;
-				}
-			}
-		}
-	}
-
-	void ManagedTypes::beginScope() { managedTypes.beginScope(); }
-	void ManagedTypes::endScope() { managedTypes.endScope(); }
-
 	bool ManagedTypes_new::isManaged( const ast::Type * type ) const {
 		// references are never constructed
@@ -647,93 +332,8 @@
 	void ManagedTypes_new::endScope() { managedTypes.endScope(); }
 
-	ImplicitCtorDtorStmt * genCtorDtor( const std::string & fname, ObjectDecl * objDecl, Expression * arg ) {
-		// call into genImplicitCall from Autogen.h to generate calls to ctor/dtor
-		assertf( objDecl, "genCtorDtor passed null objDecl" );
-		std::list< Statement * > stmts;
-		InitExpander_old srcParam( maybeClone( arg ) );
-		SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), fname, back_inserter( stmts ), objDecl );
-		assert( stmts.size() <= 1 );
-		return stmts.size() == 1 ? strict_dynamic_cast< ImplicitCtorDtorStmt * >( stmts.front() ) : nullptr;
-
-	}
-
 	ast::ptr<ast::Stmt> genCtorDtor (const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * objDecl, const ast::Expr * arg) {
 		assertf(objDecl, "genCtorDtor passed null objDecl");
 		InitExpander_new srcParam(arg);
 		return SymTab::genImplicitCall(srcParam, new ast::VariableExpr(loc, objDecl), loc, fname, objDecl);
-	}
-
-	ConstructorInit * genCtorInit( ObjectDecl * objDecl ) {
-		// call into genImplicitCall from Autogen.h to generate calls to ctor/dtor
-		// for each constructable object
-		std::list< Statement * > ctor;
-		std::list< Statement * > dtor;
-
-		InitExpander_old srcParam( objDecl->get_init() );
-		InitExpander_old nullParam( (Initializer *)NULL );
-		SymTab::genImplicitCall( srcParam, new VariableExpr( objDecl ), "?{}", back_inserter( ctor ), objDecl );
-		SymTab::genImplicitCall( nullParam, new VariableExpr( objDecl ), "^?{}", front_inserter( dtor ), objDecl, false );
-
-		// Currently genImplicitCall produces a single Statement - a CompoundStmt
-		// which  wraps everything that needs to happen. As such, it's technically
-		// possible to use a Statement ** in the above calls, but this is inherently
-		// unsafe, so instead we take the slightly less efficient route, but will be
-		// immediately informed if somehow the above assumption is broken. In this case,
-		// we could always wrap the list of statements at this point with a CompoundStmt,
-		// but it seems reasonable at the moment for this to be done by genImplicitCall
-		// itself. It is possible that genImplicitCall produces no statements (e.g. if
-		// an array type does not have a dimension). In this case, it's fine to ignore
-		// the object for the purposes of construction.
-		assert( ctor.size() == dtor.size() && ctor.size() <= 1 );
-		if ( ctor.size() == 1 ) {
-			// need to remember init expression, in case no ctors exist
-			// if ctor does exist, want to use ctor expression instead of init
-			// push this decision to the resolver
-			assert( dynamic_cast< ImplicitCtorDtorStmt * > ( ctor.front() ) && dynamic_cast< ImplicitCtorDtorStmt * > ( dtor.front() ) );
-			return new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() );
-		}
-		return nullptr;
-	}
-
-	void CtorDtor::previsit( ObjectDecl * objDecl ) {
-		managedTypes.handleDWT( objDecl );
-		// hands off if @=, extern, builtin, etc.
-		// even if unmanaged, try to construct global or static if initializer is not constexpr, since this is not legal C
-		if ( tryConstruct( objDecl ) && ( managedTypes.isManaged( objDecl ) || ((! inFunction || objDecl->get_storageClasses().is_static ) && ! isConstExpr( objDecl->get_init() ) ) ) ) {
-			// constructed objects cannot be designated
-			if ( isDesignated( objDecl->get_init() ) ) SemanticError( objDecl, "Cannot include designations in the initializer for a managed Object. If this is really what you want, then initialize with @=.\n" );
-			// constructed objects should not have initializers nested too deeply
-			if ( ! checkInitDepth( objDecl ) ) SemanticError( objDecl, "Managed object's initializer is too deep " );
-
-			objDecl->set_init( genCtorInit( objDecl ) );
-		}
-	}
-
-	void CtorDtor::previsit( FunctionDecl *functionDecl ) {
-		visit_children = false;  // do not try and construct parameters or forall parameters
-		GuardValue( inFunction );
-		inFunction = true;
-
-		managedTypes.handleDWT( functionDecl );
-
-		GuardScope( managedTypes );
-		// go through assertions and recursively add seen ctor/dtors
-		for ( auto & tyDecl : functionDecl->get_functionType()->get_forall() ) {
-			for ( DeclarationWithType *& assertion : tyDecl->get_assertions() ) {
-				managedTypes.handleDWT( assertion );
-			}
-		}
-
-		maybeAccept( functionDecl->get_statements(), *visitor );
-	}
-
-	void CtorDtor::previsit( StructDecl *aggregateDecl ) {
-		visit_children = false; // do not try to construct and destruct aggregate members
-
-		managedTypes.handleStruct( aggregateDecl );
-	}
-
-	void CtorDtor::previsit( CompoundStmt * ) {
-		GuardScope( managedTypes );
 	}
 
Index: src/InitTweak/GenInit.h
===================================================================
--- src/InitTweak/GenInit.h	(revision fa761c2aa9a4a9b1a22e28f45f380ba9d9ad36c0)
+++ src/InitTweak/GenInit.h	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -22,37 +22,18 @@
 #include "Common/CodeLocation.h"
 #include "GenPoly/ScopedSet.h" // for ScopedSet
-#include "SynTree/SynTree.h"   // for Visitor Nodes
 
 namespace InitTweak {
 	/// Adds return value temporaries and wraps Initializers in ConstructorInit nodes
-	void genInit( std::list< Declaration * > & translationUnit );
 	void genInit( ast::TranslationUnit & translationUnit );
 
 	/// Converts return statements into copy constructor calls on the hidden return variable.
 	/// This pass must happen before auto-gen.
-	void fixReturnStatements( std::list< Declaration * > & translationUnit );
 	void fixReturnStatements( ast::TranslationUnit & translationUnit );
 
 	/// generates a single ctor/dtor statement using objDecl as the 'this' parameter and arg as the optional argument
-	ImplicitCtorDtorStmt * genCtorDtor( const std::string & fname, ObjectDecl * objDecl, Expression * arg = nullptr );
 	ast::ptr<ast::Stmt> genCtorDtor (const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * objDecl, const ast::Expr * arg = nullptr);
 
 	/// creates an appropriate ConstructorInit node which contains a constructor, destructor, and C-initializer
-	ConstructorInit * genCtorInit( ObjectDecl * objDecl );
 	ast::ConstructorInit * genCtorInit( const CodeLocation & loc, const ast::ObjectDecl * objDecl );
-
-	class ManagedTypes {
-	public:
-		bool isManaged( ObjectDecl * objDecl ) const ; // determine if object is managed
-		bool isManaged( Type * type ) const; // determine if type is managed
-
-		void handleDWT( DeclarationWithType * dwt ); // add type to managed if ctor/dtor
-		void handleStruct( StructDecl * aggregateDecl ); // add type to managed if child is managed
-
-		void beginScope();
-		void endScope();
-	private:
-		GenPoly::ScopedSet< std::string > managedTypes;
-	};
 
 	class ManagedTypes_new {
Index: src/InitTweak/InitTweak.cc
===================================================================
--- src/InitTweak/InitTweak.cc	(revision fa761c2aa9a4a9b1a22e28f45f380ba9d9ad36c0)
+++ src/InitTweak/InitTweak.cc	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -29,5 +29,4 @@
 #include "AST/Type.hpp"
 #include "CodeGen/OperatorTable.h" // for isConstructor, isDestructor, isCto...
-#include "Common/PassVisitor.h"
 #include "Common/SemanticError.h"  // for SemanticError
 #include "Common/UniqueName.h"     // for UniqueName
@@ -36,57 +35,8 @@
 #include "InitTweak.h"
 #include "ResolvExpr/Unify.h"      // for typesCompatibleIgnoreQualifiers
-#include "SymTab/Autogen.h"
-#include "SymTab/Indexer.h"        // for Indexer
-#include "SynTree/LinkageSpec.h"   // for Spec, isBuiltin, Intrinsic
-#include "SynTree/Attribute.h"     // for Attribute
-#include "SynTree/Constant.h"      // for Constant
-#include "SynTree/Declaration.h"   // for ObjectDecl, DeclarationWithType
-#include "SynTree/Expression.h"    // for Expression, UntypedExpr, Applicati...
-#include "SynTree/Initializer.h"   // for Initializer, ListInit, Designation
-#include "SynTree/Label.h"         // for Label
-#include "SynTree/Statement.h"     // for CompoundStmt, ExprStmt, BranchStmt
-#include "SynTree/Type.h"          // for FunctionType, ArrayType, PointerType
-#include "SynTree/Visitor.h"       // for Visitor, maybeAccept
 #include "Tuples/Tuples.h"         // for Tuples::isTtype
 
 namespace InitTweak {
 	namespace {
-		struct HasDesignations : public WithShortCircuiting {
-			bool hasDesignations = false;
-
-			void previsit( BaseSyntaxNode * ) {
-				// short circuit if we already know there are designations
-				if ( hasDesignations ) visit_children = false;
-			}
-
-			void previsit( Designation * des ) {
-				// short circuit if we already know there are designations
-				if ( hasDesignations ) visit_children = false;
-				else if ( ! des->get_designators().empty() ) {
-					hasDesignations = true;
-					visit_children = false;
-				}
-			}
-		};
-
-		struct InitDepthChecker : public WithGuards {
-			bool depthOkay = true;
-			Type * type;
-			int curDepth = 0, maxDepth = 0;
-			InitDepthChecker( Type * type ) : type( type ) {
-				Type * t = type;
-				while ( ArrayType * at = dynamic_cast< ArrayType * >( t ) ) {
-					maxDepth++;
-					t = at->get_base();
-				}
-				maxDepth++;
-			}
-			void previsit( ListInit * ) {
-				curDepth++;
-				GuardAction( [this]() { curDepth--; } );
-				if ( curDepth > maxDepth ) depthOkay = false;
-			}
-		};
-
 		struct HasDesignations_new : public ast::WithShortCircuiting {
 			bool result = false;
@@ -128,12 +78,4 @@
 		};
 
-		struct InitFlattener_old : public WithShortCircuiting {
-			void previsit( SingleInit * singleInit ) {
-				visit_children = false;
-				argList.push_back( singleInit->value->clone() );
-			}
-			std::list< Expression * > argList;
-		};
-
 		struct InitFlattener_new : public ast::WithShortCircuiting {
 			std::vector< ast::ptr< ast::Expr > > argList;
@@ -146,22 +88,4 @@
 
 	} // anonymous namespace
-
-	std::list< Expression * > makeInitList( Initializer * init ) {
-		PassVisitor<InitFlattener_old> flattener;
-		maybeAccept( init, flattener );
-		return flattener.pass.argList;
-	}
-
-	bool isDesignated( Initializer * init ) {
-		PassVisitor<HasDesignations> finder;
-		maybeAccept( init, finder );
-		return finder.pass.hasDesignations;
-	}
-
-	bool checkInitDepth( ObjectDecl * objDecl ) {
-		PassVisitor<InitDepthChecker> checker( objDecl->type );
-		maybeAccept( objDecl->init, checker );
-		return checker.pass.depthOkay;
-	}
 
 	bool isDesignated( const ast::Init * init ) {
@@ -182,188 +106,4 @@
 	return std::move( flattener.core.argList );
 }
-
-	class InitExpander_old::ExpanderImpl {
-	public:
-		virtual ~ExpanderImpl() = default;
-		virtual std::list< Expression * > next( std::list< Expression * > & indices ) = 0;
-		virtual Statement * buildListInit( UntypedExpr * callExpr, std::list< Expression * > & indices ) = 0;
-	};
-
-	class InitImpl_old : public InitExpander_old::ExpanderImpl {
-	public:
-		InitImpl_old( Initializer * init ) : init( init ) {}
-		virtual ~InitImpl_old() = default;
-
-		virtual std::list< Expression * > next( __attribute((unused)) std::list< Expression * > & indices ) {
-			// this is wrong, but just a placeholder for now
-			// if ( ! flattened ) flatten( indices );
-			// return ! inits.empty() ? makeInitList( inits.front() ) : std::list< Expression * >();
-			return makeInitList( init );
-		}
-
-		virtual Statement * buildListInit( UntypedExpr * callExpr, std::list< Expression * > & indices );
-	private:
-		Initializer * init;
-	};
-
-	class ExprImpl_old : public InitExpander_old::ExpanderImpl {
-	public:
-		ExprImpl_old( Expression * expr ) : arg( expr ) {}
-		virtual ~ExprImpl_old() { delete arg; }
-
-		virtual std::list< Expression * > next( std::list< Expression * > & indices ) {
-			std::list< Expression * > ret;
-			Expression * expr = maybeClone( arg );
-			if ( expr ) {
-				for ( std::list< Expression * >::reverse_iterator it = indices.rbegin(); it != indices.rend(); ++it ) {
-					// go through indices and layer on subscript exprs ?[?]
-					++it;
-					UntypedExpr * subscriptExpr = new UntypedExpr( new NameExpr( "?[?]") );
-					subscriptExpr->get_args().push_back( expr );
-					subscriptExpr->get_args().push_back( (*it)->clone() );
-					expr = subscriptExpr;
-				}
-				ret.push_back( expr );
-			}
-			return ret;
-		}
-
-		virtual Statement * buildListInit( UntypedExpr * callExpr, std::list< Expression * > & indices );
-	private:
-		Expression * arg;
-	};
-
-	InitExpander_old::InitExpander_old( Initializer * init ) : expander( new InitImpl_old( init ) ) {}
-
-	InitExpander_old::InitExpander_old( Expression * expr ) : expander( new ExprImpl_old( expr ) ) {}
-
-	std::list< Expression * > InitExpander_old::operator*() {
-		return cur;
-	}
-
-	InitExpander_old & InitExpander_old::operator++() {
-		cur = expander->next( indices );
-		return *this;
-	}
-
-	// use array indices list to build switch statement
-	void InitExpander_old::addArrayIndex( Expression * index, Expression * dimension ) {
-		indices.push_back( index );
-		indices.push_back( dimension );
-	}
-
-	void InitExpander_old::clearArrayIndices() {
-		deleteAll( indices );
-		indices.clear();
-	}
-
-	bool InitExpander_old::addReference() {
-		bool added = false;
-		for ( Expression *& expr : cur ) {
-			expr = new AddressExpr( expr );
-			added = true;
-		}
-		return added;
-	}
-
-	namespace {
-		/// given index i, dimension d, initializer init, and callExpr f, generates
-		///   if (i < d) f(..., init)
-		///   ++i;
-		/// so that only elements within the range of the array are constructed
-		template< typename OutIterator >
-		void buildCallExpr( UntypedExpr * callExpr, Expression * index, Expression * dimension, Initializer * init, OutIterator out ) {
-			UntypedExpr * cond = new UntypedExpr( new NameExpr( "?<?") );
-			cond->get_args().push_back( index->clone() );
-			cond->get_args().push_back( dimension->clone() );
-
-			std::list< Expression * > args = makeInitList( init );
-			callExpr->get_args().splice( callExpr->get_args().end(), args );
-
-			*out++ = new IfStmt( cond, new ExprStmt( callExpr ), nullptr );
-
-			UntypedExpr * increment = new UntypedExpr( new NameExpr( "++?" ) );
-			increment->get_args().push_back( index->clone() );
-			*out++ = new ExprStmt( increment );
-		}
-
-		template< typename OutIterator >
-		void build( UntypedExpr * callExpr, InitExpander_old::IndexList::iterator idx, InitExpander_old::IndexList::iterator idxEnd, Initializer * init, OutIterator out ) {
-			if ( idx == idxEnd ) return;
-			Expression * index = *idx++;
-			assert( idx != idxEnd );
-			Expression * dimension = *idx++;
-
-			// xxx - may want to eventually issue a warning here if we can detect
-			// that the number of elements exceeds to dimension of the array
-			if ( idx == idxEnd ) {
-				if ( ListInit * listInit = dynamic_cast< ListInit * >( init ) ) {
-					for ( Initializer * init : *listInit ) {
-						buildCallExpr( callExpr->clone(), index, dimension, init, out );
-					}
-				} else {
-					buildCallExpr( callExpr->clone(), index, dimension, init, out );
-				}
-			} else {
-				std::list< Statement * > branches;
-
-				unsigned long cond = 0;
-				ListInit * listInit = dynamic_cast< ListInit * >( init );
-				if ( ! listInit ) {
-					// xxx - this shouldn't be an error, but need a way to
-					// terminate without creating output, so should catch this error
-					SemanticError( init->location, "unbalanced list initializers" );
-				}
-
-				static UniqueName targetLabel( "L__autogen__" );
-				Label switchLabel( targetLabel.newName(), 0, std::list< Attribute * >{ new Attribute("unused") } );
-				for ( Initializer * init : *listInit ) {
-					Expression * condition;
-					// check for designations
-					// if ( init-> ) {
-						condition = new ConstantExpr( Constant::from_ulong( cond ) );
-						++cond;
-					// } else {
-					// 	condition = // ... take designation
-					// 	cond = // ... take designation+1
-					// }
-					std::list< Statement * > stmts;
-					build( callExpr, idx, idxEnd, init, back_inserter( stmts ) );
-					stmts.push_back( new BranchStmt( switchLabel, BranchStmt::Break ) );
-					CaseStmt * caseStmt = new CaseStmt( condition, stmts );
-					branches.push_back( caseStmt );
-				}
-				*out++ = new SwitchStmt( index->clone(), branches );
-				*out++ = new NullStmt( { switchLabel } );
-			}
-		}
-	}
-
-	// if array came with an initializer list: initialize each element
-	// may have more initializers than elements in the array - need to check at each index that
-	// we haven't exceeded size.
-	// may have fewer initializers than elements in the array - need to default construct
-	// remaining elements.
-	// To accomplish this, generate switch statement, consuming all of expander's elements
-	Statement * InitImpl_old::buildListInit( UntypedExpr * dst, std::list< Expression * > & indices ) {
-		if ( ! init ) return nullptr;
-		CompoundStmt * block = new CompoundStmt();
-		build( dst, indices.begin(), indices.end(), init, back_inserter( block->get_kids() ) );
-		if ( block->get_kids().empty() ) {
-			delete block;
-			return nullptr;
-		} else {
-			init = nullptr; // init was consumed in creating the list init
-			return block;
-		}
-	}
-
-	Statement * ExprImpl_old::buildListInit( UntypedExpr *, std::list< Expression * > & ) {
-		return nullptr;
-	}
-
-	Statement * InitExpander_old::buildListInit( UntypedExpr * dst ) {
-		return expander->buildListInit( dst, indices );
-	}
 
 class InitExpander_new::ExpanderImpl {
@@ -537,11 +277,4 @@
 }
 
-	Type * getTypeofThis( FunctionType * ftype ) {
-		assertf( ftype, "getTypeofThis: nullptr ftype" );
-		ObjectDecl * thisParam = getParamThis( ftype );
-		ReferenceType * refType = strict_dynamic_cast< ReferenceType * >( thisParam->type );
-		return refType->base;
-	}
-
 	const ast::Type * getTypeofThis( const ast::FunctionType * ftype ) {
 		assertf( ftype, "getTypeofThis: nullptr ftype" );
@@ -554,11 +287,4 @@
 	}
 
-	ObjectDecl * getParamThis( FunctionType * ftype ) {
-		assertf( ftype, "getParamThis: nullptr ftype" );
-		auto & params = ftype->parameters;
-		assertf( ! params.empty(), "getParamThis: ftype with 0 parameters: %s", toString( ftype ).c_str() );
-		return strict_dynamic_cast< ObjectDecl * >( params.front() );
-	}
-
 	const ast::ObjectDecl * getParamThis(const ast::FunctionDecl * func) {
 		assertf( func, "getParamThis: nullptr ftype" );
@@ -566,17 +292,4 @@
 		assertf( ! params.empty(), "getParamThis: ftype with 0 parameters: %s", toString( func ).c_str());
 		return params.front().strict_as<ast::ObjectDecl>();
-	}
-
-	bool tryConstruct( DeclarationWithType * dwt ) {
-		ObjectDecl * objDecl = dynamic_cast< ObjectDecl * >( dwt );
-		if ( ! objDecl ) return false;
-		return (objDecl->get_init() == nullptr ||
-				( objDecl->get_init() != nullptr && objDecl->get_init()->get_maybeConstructed() ))
-			&& ! objDecl->get_storageClasses().is_extern
-			&& isConstructable( objDecl->type );
-	}
-
-	bool isConstructable( Type * type ) {
-		return ! dynamic_cast< VarArgsType * >( type ) && ! dynamic_cast< ReferenceType * >( type ) && ! dynamic_cast< FunctionType * >( type ) && ! Tuples::isTtype( type );
 	}
 
@@ -595,28 +308,4 @@
 	}
 
-	struct CallFinder_old {
-		CallFinder_old( const std::list< std::string > & names ) : names( names ) {}
-
-		void postvisit( ApplicationExpr * appExpr ) {
-			handleCallExpr( appExpr );
-		}
-
-		void postvisit( UntypedExpr * untypedExpr ) {
-			handleCallExpr( untypedExpr );
-		}
-
-		std::list< Expression * > * matches;
-	private:
-		const std::list< std::string > names;
-
-		template< typename CallExpr >
-		void handleCallExpr( CallExpr * expr ) {
-			std::string fname = getFunctionName( expr );
-			if ( std::find( names.begin(), names.end(), fname ) != names.end() ) {
-				matches->push_back( expr );
-			}
-		}
-	};
-
 	struct CallFinder_new final {
 		std::vector< const ast::Expr * > matches;
@@ -636,10 +325,4 @@
 	};
 
-	void collectCtorDtorCalls( Statement * stmt, std::list< Expression * > & matches ) {
-		static PassVisitor<CallFinder_old> finder( std::list< std::string >{ "?{}", "^?{}" } );
-		finder.pass.matches = &matches;
-		maybeAccept( stmt, finder );
-	}
-
 	std::vector< const ast::Expr * > collectCtorDtorCalls( const ast::Stmt * stmt ) {
 		ast::Pass< CallFinder_new > finder{ std::vector< std::string >{ "?{}", "^?{}" } };
@@ -648,79 +331,5 @@
 	}
 
-	Expression * getCtorDtorCall( Statement * stmt ) {
-		std::list< Expression * > matches;
-		collectCtorDtorCalls( stmt, matches );
-		assertf( matches.size() <= 1, "%zd constructor/destructors found in %s", matches.size(), toString( stmt ).c_str() );
-		return matches.size() == 1 ? matches.front() : nullptr;
-	}
-
 	namespace {
-		DeclarationWithType * getCalledFunction( Expression * expr );
-
-		template<typename CallExpr>
-		DeclarationWithType * handleDerefCalledFunction( CallExpr * expr ) {
-			// (*f)(x) => should get "f"
-			std::string name = getFunctionName( expr );
-			assertf( name == "*?", "Unexpected untyped expression: %s", name.c_str() );
-			assertf( ! expr->get_args().empty(), "Cannot get called function from dereference with no arguments" );
-			return getCalledFunction( expr->get_args().front() );
-		}
-
-		DeclarationWithType * getCalledFunction( Expression * expr ) {
-			assert( expr );
-			if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( expr ) ) {
-				return varExpr->var;
-			} else if ( MemberExpr * memberExpr = dynamic_cast< MemberExpr * >( expr ) ) {
-				return memberExpr->member;
-			} else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) {
-				return getCalledFunction( castExpr->arg );
-			} else if ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * >( expr ) ) {
-				return handleDerefCalledFunction( untypedExpr );
-			} else if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * > ( expr ) ) {
-				return handleDerefCalledFunction( appExpr );
-			} else if ( AddressExpr * addrExpr = dynamic_cast< AddressExpr * >( expr ) ) {
-				return getCalledFunction( addrExpr->arg );
-			} else if ( CommaExpr * commaExpr = dynamic_cast< CommaExpr * >( expr ) ) {
-				return getCalledFunction( commaExpr->arg2 );
-			}
-			return nullptr;
-		}
-
-		DeclarationWithType * getFunctionCore( const Expression * expr ) {
-			if ( const auto * appExpr = dynamic_cast< const ApplicationExpr * >( expr ) ) {
-				return getCalledFunction( appExpr->function );
-			} else if ( const auto * untyped = dynamic_cast< const UntypedExpr * >( expr ) ) {
-				return getCalledFunction( untyped->function );
-			}
-			assertf( false, "getFunction with unknown expression: %s", toString( expr ).c_str() );
-		}
-	}
-
-	DeclarationWithType * getFunction( Expression * expr ) {
-		return getFunctionCore( expr );
-	}
-
-	const DeclarationWithType * getFunction( const Expression * expr ) {
-		return getFunctionCore( expr );
-	}
-
-	ApplicationExpr * isIntrinsicCallExpr( Expression * expr ) {
-		ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr );
-		if ( ! appExpr ) return nullptr;
-		DeclarationWithType * function = getCalledFunction( appExpr->get_function() );
-		assertf( function, "getCalledFunction returned nullptr: %s", toString( appExpr->get_function() ).c_str() );
-		// check for Intrinsic only - don't want to remove all overridable ctor/dtors because autogenerated ctor/dtor
-		// will call all member dtors, and some members may have a user defined dtor.
-		return function->get_linkage() == LinkageSpec::Intrinsic ? appExpr : nullptr;
-	}
-
-	namespace {
-		template <typename Predicate>
-		bool allofCtorDtor( Statement * stmt, const Predicate & pred ) {
-			std::list< Expression * > callExprs;
-			collectCtorDtorCalls( stmt, callExprs );
-			return std::all_of( callExprs.begin(), callExprs.end(), pred);
-		}
-
 		template <typename Predicate>
 		bool allofCtorDtor( const ast::Stmt * stmt, const Predicate & pred ) {
@@ -728,15 +337,4 @@
 			return std::all_of( callExprs.begin(), callExprs.end(), pred );
 		}
-	}
-
-	bool isIntrinsicSingleArgCallStmt( Statement * stmt ) {
-		return allofCtorDtor( stmt, []( Expression * callExpr ){
-			if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) {
-				FunctionType *funcType = GenPoly::getFunctionType( appExpr->function->result );
-				assert( funcType );
-				return funcType->get_parameters().size() == 1;
-			}
-			return false;
-		});
 	}
 
@@ -751,129 +349,4 @@
 			return false;
 		});
-	}
-
-	bool isIntrinsicCallStmt( Statement * stmt ) {
-		return allofCtorDtor( stmt, []( Expression * callExpr ) {
-			return isIntrinsicCallExpr( callExpr );
-		});
-	}
-
-	namespace {
-		template<typename CallExpr>
-		Expression *& callArg( CallExpr * callExpr, unsigned int pos ) {
-			if ( pos >= callExpr->get_args().size() ) assertf( false, "getCallArg for argument that doesn't exist: (%u); %s.", pos, toString( callExpr ).c_str() );
-			for ( Expression *& arg : callExpr->get_args() ) {
-				if ( pos == 0 ) return arg;
-				pos--;
-			}
-			assert( false );
-		}
-	}
-
-	Expression *& getCallArg( Expression * callExpr, unsigned int pos ) {
-		if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( callExpr ) ) {
-			return callArg( appExpr, pos );
-		} else if ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * >( callExpr ) ) {
-			return callArg( untypedExpr, pos );
-		} else if ( TupleAssignExpr * tupleExpr = dynamic_cast< TupleAssignExpr * > ( callExpr ) ) {
-			std::list< Statement * > & stmts = tupleExpr->get_stmtExpr()->get_statements()->get_kids();
-			assertf( ! stmts.empty(), "TupleAssignExpr somehow has no statements." );
-			ExprStmt * stmt = strict_dynamic_cast< ExprStmt * >( stmts.back() );
-			TupleExpr * tuple = strict_dynamic_cast< TupleExpr * >( stmt->get_expr() );
-			assertf( ! tuple->get_exprs().empty(), "TupleAssignExpr somehow has empty tuple expr." );
-			return getCallArg( tuple->get_exprs().front(), pos );
-		} else if ( ImplicitCopyCtorExpr * copyCtor = dynamic_cast< ImplicitCopyCtorExpr * >( callExpr ) ) {
-			return getCallArg( copyCtor->callExpr, pos );
-		} else {
-			assertf( false, "Unexpected expression type passed to getCallArg: %s", toString( callExpr ).c_str() );
-		}
-	}
-
-	namespace {
-		std::string funcName( Expression * func );
-
-		template<typename CallExpr>
-		std::string handleDerefName( CallExpr * expr ) {
-			// (*f)(x) => should get name "f"
-			std::string name = getFunctionName( expr );
-			assertf( name == "*?", "Unexpected untyped expression: %s", name.c_str() );
-			assertf( ! expr->get_args().empty(), "Cannot get function name from dereference with no arguments" );
-			return funcName( expr->get_args().front() );
-		}
-
-		std::string funcName( Expression * func ) {
-			if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( func ) ) {
-				return nameExpr->get_name();
-			} else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( func ) ) {
-				return varExpr->get_var()->get_name();
-			} else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( func ) ) {
-				return funcName( castExpr->get_arg() );
-			} else if ( MemberExpr * memberExpr = dynamic_cast< MemberExpr * >( func ) ) {
-				return memberExpr->get_member()->get_name();
-			} else if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * > ( func ) ) {
-				return funcName( memberExpr->get_member() );
-			} else if ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * >( func ) ) {
-				return handleDerefName( untypedExpr );
-			} else if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( func ) ) {
-				return handleDerefName( appExpr );
-			} else if ( ConstructorExpr * ctorExpr = dynamic_cast< ConstructorExpr * >( func ) ) {
-				return funcName( getCallArg( ctorExpr->get_callExpr(), 0 ) );
-			} else {
-				assertf( false, "Unexpected expression type being called as a function in call expression: %s", toString( func ).c_str() );
-			}
-		}
-	}
-
-	std::string getFunctionName( Expression * expr ) {
-		// there's some unforunate overlap here with getCalledFunction. Ideally this would be able to use getCalledFunction and
-		// return the name of the DeclarationWithType, but this needs to work for NameExpr and UntypedMemberExpr, where getCalledFunction
-		// can't possibly do anything reasonable.
-		if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr ) ) {
-			return funcName( appExpr->get_function() );
-		} else if ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * > ( expr ) ) {
-			return funcName( untypedExpr->get_function() );
-		} else {
-			std::cerr << expr << std::endl;
-			assertf( false, "Unexpected expression type passed to getFunctionName" );
-		}
-	}
-
-	Type * getPointerBase( Type * type ) {
-		if ( PointerType * ptrType = dynamic_cast< PointerType * >( type ) ) {
-			return ptrType->get_base();
-		} else if ( ArrayType * arrayType = dynamic_cast< ArrayType * >( type ) ) {
-			return arrayType->get_base();
-		} else if ( ReferenceType * refType = dynamic_cast< ReferenceType * >( type ) ) {
-			return refType->get_base();
-		} else {
-			return nullptr;
-		}
-	}
-
-	Type * isPointerType( Type * type ) {
-		return getPointerBase( type ) ? type : nullptr;
-	}
-
-	ApplicationExpr * createBitwiseAssignment( Expression * dst, Expression * src ) {
-		static FunctionDecl * assign = nullptr;
-		if ( ! assign ) {
-			// temporary? Generate a fake assignment operator to represent bitwise assignments.
-			// This operator could easily exist as a real function, but it's tricky because nothing should resolve to this function.
-			TypeDecl * td = new TypeDecl( "T", noStorageClasses, nullptr, TypeDecl::Dtype, true );
-			assign = new FunctionDecl( "?=?", noStorageClasses, LinkageSpec::Intrinsic, SymTab::genAssignType( new TypeInstType( noQualifiers, td->name, td ) ), nullptr );
-		}
-		if ( dynamic_cast< ReferenceType * >( dst->result ) ) {
-			for (int depth = dst->result->referenceDepth(); depth > 0; depth--) {
-				dst = new AddressExpr( dst );
-			}
-		} else {
-			dst = new CastExpr( dst, new ReferenceType( noQualifiers, dst->result->clone() ) );
-		}
-		if ( dynamic_cast< ReferenceType * >( src->result ) ) {
-			for (int depth = src->result->referenceDepth(); depth > 0; depth--) {
-				src = new AddressExpr( src );
-			}
-		}
-		return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } );
 	}
 
@@ -907,44 +380,4 @@
 		return app;
 	}
-
-	struct ConstExprChecker : public WithShortCircuiting {
-		// most expressions are not const expr
-		void previsit( Expression * ) { isConstExpr = false; visit_children = false; }
-
-		void previsit( AddressExpr *addressExpr ) {
-			visit_children = false;
-
-			// address of a variable or member expression is constexpr
-			Expression * arg = addressExpr->get_arg();
-			if ( ! dynamic_cast< NameExpr * >( arg) && ! dynamic_cast< VariableExpr * >( arg ) && ! dynamic_cast< MemberExpr * >( arg ) && ! dynamic_cast< UntypedMemberExpr * >( arg ) ) isConstExpr = false;
-		}
-
-		// these expressions may be const expr, depending on their children
-		void previsit( SizeofExpr * ) {}
-		void previsit( AlignofExpr * ) {}
-		void previsit( UntypedOffsetofExpr * ) {}
-		void previsit( OffsetofExpr * ) {}
-		void previsit( OffsetPackExpr * ) {}
-		void previsit( CommaExpr * ) {}
-		void previsit( LogicalExpr * ) {}
-		void previsit( ConditionalExpr * ) {}
-		void previsit( CastExpr * ) {}
-		void previsit( ConstantExpr * ) {}
-
-		void previsit( VariableExpr * varExpr ) {
-			visit_children = false;
-
-			if ( EnumInstType * inst = dynamic_cast< EnumInstType * >( varExpr->result ) ) {
-				long long int value;
-				if ( inst->baseEnum->valueOf( varExpr->var, value ) ) {
-					// enumerators are const expr
-					return;
-				}
-			}
-			isConstExpr = false;
-		}
-
-		bool isConstExpr = true;
-	};
 
 	struct ConstExprChecker_new : public ast::WithShortCircuiting {
@@ -991,23 +424,4 @@
 	};
 
-	bool isConstExpr( Expression * expr ) {
-		if ( expr ) {
-			PassVisitor<ConstExprChecker> checker;
-			expr->accept( checker );
-			return checker.pass.isConstExpr;
-		}
-		return true;
-	}
-
-	bool isConstExpr( Initializer * init ) {
-		if ( init ) {
-			PassVisitor<ConstExprChecker> checker;
-			init->accept( checker );
-			return checker.pass.isConstExpr;
-		} // if
-		// for all intents and purposes, no initializer means const expr
-		return true;
-	}
-
 	bool isConstExpr( const ast::Expr * expr ) {
 		if ( expr ) {
@@ -1029,22 +443,4 @@
 	}
 
-	const FunctionDecl * isCopyFunction( const Declaration * decl, const std::string & fname ) {
-		const FunctionDecl * function = dynamic_cast< const FunctionDecl * >( decl );
-		if ( ! function ) return nullptr;
-		if ( function->name != fname ) return nullptr;
-		FunctionType * ftype = function->type;
-		if ( ftype->parameters.size() != 2 ) return nullptr;
-
-		Type * t1 = getPointerBase( ftype->get_parameters().front()->get_type() );
-		Type * t2 = ftype->parameters.back()->get_type();
-		assert( t1 );
-
-		if ( ResolvExpr::typesCompatibleIgnoreQualifiers( t1, t2, SymTab::Indexer() ) ) {
-			return function;
-		} else {
-			return nullptr;
-		}
-	}
-
 bool isAssignment( const ast::FunctionDecl * decl ) {
 	return CodeGen::isAssignment( decl->name ) && isCopyFunction( decl );
@@ -1073,28 +469,4 @@
 	return ResolvExpr::typesCompatibleIgnoreQualifiers( t1, t2 );
 }
-
-
-	const FunctionDecl * isAssignment( const Declaration * decl ) {
-		return isCopyFunction( decl, "?=?" );
-	}
-	const FunctionDecl * isDestructor( const Declaration * decl ) {
-		if ( CodeGen::isDestructor( decl->name ) ) {
-			return dynamic_cast< const FunctionDecl * >( decl );
-		}
-		return nullptr;
-	}
-	const FunctionDecl * isDefaultConstructor( const Declaration * decl ) {
-		if ( CodeGen::isConstructor( decl->name ) ) {
-			if ( const FunctionDecl * func = dynamic_cast< const FunctionDecl * >( decl ) ) {
-				if ( func->type->parameters.size() == 1 ) {
-					return func;
-				}
-			}
-		}
-		return nullptr;
-	}
-	const FunctionDecl * isCopyConstructor( const Declaration * decl ) {
-		return isCopyFunction( decl, "?{}" );
-	}
 
 	#if defined( __x86_64 ) || defined( __i386 ) // assembler comment to prevent assembler warning message
@@ -1105,11 +477,4 @@
 	static const char * const data_section =  ".data" ASM_COMMENT;
 	static const char * const tlsd_section = ".tdata" ASM_COMMENT;
-	void addDataSectionAttribute( ObjectDecl * objDecl ) {
-		const bool is_tls = objDecl->get_storageClasses().is_threadlocal_any();
-		const char * section = is_tls ? tlsd_section : data_section;
-		objDecl->attributes.push_back(new Attribute("section", {
-			new ConstantExpr( Constant::from_string( section ) )
-		}));
-	}
 
 	void addDataSectionAttribute( ast::ObjectDecl * objDecl ) {
Index: src/InitTweak/InitTweak.h
===================================================================
--- src/InitTweak/InitTweak.h	(revision fa761c2aa9a4a9b1a22e28f45f380ba9d9ad36c0)
+++ src/InitTweak/InitTweak.h	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -22,13 +22,7 @@
 
 #include "AST/Fwd.hpp"        // for AST nodes
-#include "SynTree/SynTree.h"  // for Visitor Nodes
 
 // helper functions for initialization
 namespace InitTweak {
-	const FunctionDecl * isAssignment( const Declaration * decl );
-	const FunctionDecl * isDestructor( const Declaration * decl );
-	const FunctionDecl * isDefaultConstructor( const Declaration * decl );
-	const FunctionDecl * isCopyConstructor( const Declaration * decl );
-	const FunctionDecl * isCopyFunction( const Declaration * decl, const std::string & fname );
 	bool isAssignment( const ast::FunctionDecl * decl );
 	bool isDestructor( const ast::FunctionDecl * decl );
@@ -38,76 +32,37 @@
 
 	/// returns the base type of the first parameter to a constructor/destructor/assignment function
-	Type * getTypeofThis( FunctionType * ftype );
 	const ast::Type * getTypeofThis( const ast::FunctionType * ftype );
 
 	/// returns the first parameter of a constructor/destructor/assignment function
-	ObjectDecl * getParamThis( FunctionType * ftype );
 	const ast::ObjectDecl * getParamThis(const ast::FunctionDecl * func);
 
 	/// generate a bitwise assignment operation.
-	ApplicationExpr * createBitwiseAssignment( Expression * dst, Expression * src );
-
 	ast::Expr * createBitwiseAssignment( const ast::Expr * dst, const ast::Expr * src);
 
 	/// transform Initializer into an argument list that can be passed to a call expression
-	std::list< Expression * > makeInitList( Initializer * init );
 	std::vector< ast::ptr< ast::Expr > > makeInitList( const ast::Init * init );
 
 	/// True if the resolver should try to construct dwt
-	bool tryConstruct( DeclarationWithType * dwt );
 	bool tryConstruct( const ast::DeclWithType * dwt );
 
 	/// True if the type can have a user-defined constructor
-	bool isConstructable( Type * t );
 	bool isConstructable( const ast::Type * t );
 
 	/// True if the Initializer contains designations
-	bool isDesignated( Initializer * init );
 	bool isDesignated( const ast::Init * init );
 
 	/// True if the ObjectDecl's Initializer nesting level is not deeper than the depth of its
 	/// type, where the depth of its type is the number of nested ArrayTypes + 1
-	bool checkInitDepth( ObjectDecl * objDecl );
 	bool checkInitDepth( const ast::ObjectDecl * objDecl );
-
-	/// returns the declaration of the function called by the expr (must be ApplicationExpr or UntypedExpr)
-	DeclarationWithType * getFunction( Expression * expr );
-	const DeclarationWithType * getFunction( const Expression * expr );
-
-	/// Non-Null if expr is a call expression whose target function is intrinsic
-	ApplicationExpr * isIntrinsicCallExpr( Expression * expr );
 
 	/// True if stmt is a call statement where the function called is intrinsic and takes one parameter.
 	/// Intended to be used for default ctor/dtor calls, but might have use elsewhere.
 	/// Currently has assertions that make it less than fully general.
-	bool isIntrinsicSingleArgCallStmt( Statement * stmt );
 	bool isIntrinsicSingleArgCallStmt( const ast::Stmt * stmt );
 
-	/// True if stmt is a call statement where the function called is intrinsic.
-	bool isIntrinsicCallStmt( Statement * stmt );
-
 	/// get all Ctor/Dtor call expressions from a Statement
-	void collectCtorDtorCalls( Statement * stmt, std::list< Expression * > & matches );
 	std::vector< const ast::Expr * > collectCtorDtorCalls( const ast::Stmt * stmt );
 
-	/// get the Ctor/Dtor call expression from a Statement that looks like a generated ctor/dtor call
-	Expression * getCtorDtorCall( Statement * stmt );
-
-	/// returns the name of the function being called
-	std::string getFunctionName( Expression * expr );
-
-	/// returns the argument to a call expression in position N indexed from 0
-	Expression *& getCallArg( Expression * callExpr, unsigned int pos );
-
-	/// returns the base type of a PointerType or ArrayType, else returns NULL
-	Type * getPointerBase( Type * );
-
-	/// returns the argument if it is a PointerType or ArrayType, else returns NULL
-	Type * isPointerType( Type * );
-
 	/// returns true if expr is trivially a compile-time constant
-	bool isConstExpr( Expression * expr );
-	bool isConstExpr( Initializer * init );
-
 	bool isConstExpr( const ast::Expr * expr );
 	bool isConstExpr( const ast::Init * init );
@@ -122,37 +77,5 @@
 	///    .section .data#,"a"
 	/// to avoid assembler warning "ignoring changed section attributes for .data"
-	void addDataSectionAttribute( ObjectDecl * objDecl );
-
 	void addDataSectionAttribute( ast::ObjectDecl * objDecl );
-
-	class InitExpander_old {
-	public:
-		// expand by stepping through init to get each list of arguments
-		InitExpander_old( Initializer * init );
-
-		// always expand to expr
-		InitExpander_old( Expression * expr );
-
-		// iterator-like interface
-		std::list< Expression * > operator*();
-		InitExpander_old & operator++();
-
-		// builds statement which has the same semantics as a C-style list initializer
-		// (for array initializers) using callExpr as the base expression to perform initialization
-		Statement * buildListInit( UntypedExpr * callExpr );
-		void addArrayIndex( Expression * index, Expression * dimension );
-		void clearArrayIndices();
-		bool addReference();
-
-		class ExpanderImpl;
-
-		typedef std::list< Expression * > IndexList;
-	private:
-		std::shared_ptr< ExpanderImpl > expander;
-		std::list< Expression * > cur;
-
-		// invariant: list of size 2N (elements come in pairs [index, dimension])
-		IndexList indices;
-	};
 
 	class InitExpander_new {
Index: src/InitTweak/module.mk
===================================================================
--- src/InitTweak/module.mk	(revision fa761c2aa9a4a9b1a22e28f45f380ba9d9ad36c0)
+++ src/InitTweak/module.mk	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -24,5 +24,4 @@
 	InitTweak/FixGlobalInit.cc \
 	InitTweak/FixGlobalInit.h \
-	InitTweak/FixInit.cc \
 	InitTweak/FixInit.h \
 	InitTweak/FixInitNew.cpp
