Index: src/InitTweak/FixGlobalInit.cc
===================================================================
--- src/InitTweak/FixGlobalInit.cc	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
+++ src/InitTweak/FixGlobalInit.cc	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
@@ -10,9 +10,10 @@
 // Created On       : Mon May 04 15:14:56 2016
 // Last Modified By : Rob Schluntz
-// Last Modified On : Fri May 06 15:40:48 2016
+// Last Modified On : Fri May 06 16:14:13 2016
 // Update Count     : 2
 //
 
 #include "FixGlobalInit.h"
+#include "GenInit.h"
 #include "SynTree/Declaration.h"
 #include "SynTree/Type.h"
@@ -42,4 +43,5 @@
 		UniqueName tempNamer;
 		FunctionDecl * initFunction;
+		FunctionDecl * destroyFunction;
 	};
 
@@ -91,7 +93,8 @@
 		acceptAll( translationUnit, fixer );
 		translationUnit.push_back( fixer.initFunction );
+		translationUnit.push_back( fixer.destroyFunction );
 	}
 
-  std::string initName( const std::string & name ) {
+  std::string globalFunctionName( const std::string & name ) {
   	// get basename
   	std::string ret = name.substr( 0, name.find( '.' ) );
@@ -99,15 +102,20 @@
 		static std::string invalid = "/-";
   	replace_if( ret.begin(), ret.end(), []( char c ) { return invalid.find(c) != std::string::npos; }, '_' );
-  	return "_init_" + ret;
+  	return ret;
   }
 
 	GlobalFixer::GlobalFixer( const std::string & name, bool inLibrary ) : tempNamer( "_global_init" ) {
-		initFunction = new FunctionDecl( initName( name ), DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false, FunctionDecl::Attribute( FunctionDecl::Attribute::Constructor, inLibrary ? FunctionDecl::Attribute::High : FunctionDecl::Attribute::Default ) );
+		std::string fixedName = globalFunctionName( name );
+		initFunction = new FunctionDecl( "_init_" + fixedName, DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false, FunctionDecl::Attribute( FunctionDecl::Attribute::Constructor, inLibrary ? FunctionDecl::Attribute::High : FunctionDecl::Attribute::Default ) );
+
+		destroyFunction = new FunctionDecl( "_destroy_" + fixedName, DeclarationNode::Static, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false, FunctionDecl::Attribute( FunctionDecl::Attribute::Destructor, inLibrary ? FunctionDecl::Attribute::High : FunctionDecl::Attribute::Default ) );
 	}
 
 	void GlobalFixer::visit( ObjectDecl *objDecl ) {
-		std::list< Statement * > & statements = initFunction->get_statements()->get_kids();
+		std::list< Statement * > & initStatements = initFunction->get_statements()->get_kids();
+		std::list< Statement * > & destroyStatements = destroyFunction->get_statements()->get_kids();
 
 		if ( objDecl->get_init() == NULL ) return;
+		if ( ! tryConstruct( objDecl ) ) return; // don't construct @= or designated objects
 		if ( objDecl->get_type()->get_isConst() ) return; // temporary: can't assign to a const variable
 		// C allows you to initialize objects with constant expressions
@@ -119,13 +127,16 @@
 		ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, objDecl->get_type()->clone(), objDecl->get_init() );
 		objDecl->set_init( NULL );
-		statements.push_back( new DeclStmt( noLabels, newObj ) );
+		initStatements.push_back( new DeclStmt( noLabels, newObj ) );
 
-		// assign (later: copy construct) objDecl using temporary
-		UntypedExpr * init = new UntypedExpr( new NameExpr( "?=?" ) );
+		// copy construct objDecl using temporary
+		UntypedExpr * init = new UntypedExpr( new NameExpr( "?{}" ) );
 		init->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) );
 		init->get_args().push_back( new VariableExpr( newObj ) );
-		statements.push_back( new ExprStmt( noLabels, init ) );
+		initStatements.push_back( new ExprStmt( noLabels, init ) );
 
-		// xxx- need to destruct objDecl atexit
+		// add destructor calls to global destroy function
+		UntypedExpr * destroy = new UntypedExpr( new NameExpr( "^?{}" ) );
+		destroy->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) );
+		destroyStatements.push_front( new ExprStmt( noLabels, destroy ) );
 	}
 
Index: src/InitTweak/FixGlobalInit.h
===================================================================
--- src/InitTweak/FixGlobalInit.h	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
+++ src/InitTweak/FixGlobalInit.h	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
@@ -10,5 +10,5 @@
 // Created On       : Mon May 04 15:14:56 2016
 // Last Modified By : Rob Schluntz
-// Last Modified On : Fri May 06 15:29:13 2016
+// Last Modified On : Fri May 06 16:07:47 2016
 // Update Count     : 2
 //
@@ -31,5 +31,5 @@
   /// Apply transformations to a file name to get a valid C identifier which will be used as
   /// the name of the generated initializer function.
-  std::string initName( const std::string & name );
+  std::string globalFunctionName( const std::string & name );
 } // namespace
 
Index: src/InitTweak/FixInit.cc
===================================================================
--- src/InitTweak/FixInit.cc	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
+++ src/InitTweak/FixInit.cc	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
@@ -0,0 +1,478 @@
+//
+// 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.h --
+//
+// Author           : Rob Schluntz
+// Created On       : Wed Jan 13 16:29:30 2016
+// Last Modified By : Rob Schluntz
+// Last Modified On : Wed May 04 14:51:33 2016
+// Update Count     : 30
+//
+
+#include <stack>
+#include <list>
+#include "FixInit.h"
+#include "ResolvExpr/Resolver.h"
+#include "ResolvExpr/typeops.h"
+#include "SynTree/Declaration.h"
+#include "SynTree/Type.h"
+#include "SynTree/Expression.h"
+#include "SynTree/Statement.h"
+#include "SynTree/Initializer.h"
+#include "SynTree/Mutator.h"
+#include "SymTab/Indexer.h"
+#include "GenPoly/PolyMutator.h"
+#include "GenPoly/GenPoly.h"
+
+bool ctordtorp = false;
+#define PRINT( text ) if ( ctordtorp ) { text }
+
+namespace InitTweak {
+	namespace {
+		const std::list<Label> noLabels;
+		const std::list<Expression*> noDesignators;
+	}
+
+	class InsertImplicitCalls : public GenPoly::PolyMutator {
+	public:
+		/// 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 );
+
+		virtual Expression * mutate( ApplicationExpr * appExpr );
+	};
+
+	class ResolveCopyCtors : public SymTab::Indexer {
+	public:
+		/// 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 );
+
+		virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr );
+
+		/// create and resolve ctor/dtor expression: fname(var, [cpArg])
+		ApplicationExpr * 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 * );
+	private:
+		TypeSubstitution * env;
+	};
+
+	class FixInit : public GenPoly::PolyMutator {
+	  public:
+		/// expand each object declaration to use its constructor after it is declared.
+		/// insert destructor calls at the appropriate places
+		static void fixInitializers( std::list< Declaration * > &translationUnit );
+
+		virtual DeclarationWithType * mutate( ObjectDecl *objDecl );
+
+		virtual CompoundStmt * mutate( CompoundStmt * compoundStmt );
+		virtual Statement * mutate( ReturnStmt * returnStmt );
+		virtual Statement * mutate( BranchStmt * branchStmt );
+
+	  private:
+		// stack of list of statements - used to differentiate scopes
+		std::list< std::list< Statement * > > dtorStmts;
+	};
+
+	class FixCopyCtors : public GenPoly::PolyMutator {
+	  public:
+		/// expand ImplicitCopyCtorExpr nodes into the temporary declarations, copy constructors,
+		/// call expression, and destructors
+		static void fixCopyCtors( std::list< Declaration * > &translationUnit );
+
+		virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr );
+
+	  private:
+		// stack of list of statements - used to differentiate scopes
+		std::list< std::list< Statement * > > dtorStmts;
+	};
+
+	void fix( std::list< Declaration * > & translationUnit ) {
+		InsertImplicitCalls::insert( translationUnit );
+		ResolveCopyCtors::resolveImplicitCalls( translationUnit );
+		FixInit::fixInitializers( translationUnit );
+		// FixCopyCtors must happen after FixInit, so that destructors are placed correctly
+		FixCopyCtors::fixCopyCtors( translationUnit );
+	}
+
+	void InsertImplicitCalls::insert( std::list< Declaration * > & translationUnit ) {
+		InsertImplicitCalls inserter;
+		mutateAll( translationUnit, inserter );
+	}
+
+	void ResolveCopyCtors::resolveImplicitCalls( std::list< Declaration * > & translationUnit ) {
+		ResolveCopyCtors resolver;
+		acceptAll( translationUnit, resolver );
+	}
+
+	void FixInit::fixInitializers( std::list< Declaration * > & translationUnit ) {
+		FixInit fixer;
+		mutateAll( translationUnit, fixer );
+	}
+
+	void FixCopyCtors::fixCopyCtors( std::list< Declaration * > & translationUnit ) {
+		FixCopyCtors fixer;
+		mutateAll( translationUnit, fixer );
+	}
+
+	Expression * InsertImplicitCalls::mutate( ApplicationExpr * appExpr ) {
+		appExpr = dynamic_cast< ApplicationExpr * >( Mutator::mutate( appExpr ) );
+		assert( appExpr );
+
+		if ( VariableExpr * function = dynamic_cast< VariableExpr * > ( appExpr->get_function() ) ) {
+			if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) {
+				// optimization: don't need to copy construct in order to call intrinsic functions
+				return appExpr;
+			} else if ( FunctionDecl * funcDecl = dynamic_cast< FunctionDecl * > ( function->get_var() ) ) {
+				FunctionType * ftype = funcDecl->get_functionType();
+				if ( (funcDecl->get_name() == "?{}" || funcDecl->get_name() == "?=?") && ftype->get_parameters().size() == 2 ) {
+					Type * t1 = ftype->get_parameters().front()->get_type();
+					Type * t2 = ftype->get_parameters().back()->get_type();
+					PointerType * ptrType = dynamic_cast< PointerType * > ( t1 );
+					assert( ptrType );
+					if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) {
+						// optimization: don't need to copy construct in order to call a copy constructor or
+						// assignment operator
+						return appExpr;
+					}
+				} else if ( funcDecl->get_name() == "^?{}" ) {
+					// correctness: never copy construct arguments to a destructor
+					return appExpr;
+				}
+			}
+		}
+		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 );
+		// save the type substitution onto the new node so that it is easy to find.
+		// 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. Normally this is what PolyMutator is for, but the pass that resolves
+		// copy constructor calls must be an Indexer. We could alternatively make a PolyIndexer which
+		// saves the environment, or compute the types of temporaries here, but it's much simpler to
+		// save the environment here, and more cohesive to compute temporary variables and resolve copy
+		// constructor calls together.
+		assert( env );
+		expr->set_env( env );
+		return expr;
+	}
+
+	bool ResolveCopyCtors::skipCopyConstruct( Type * type ) {
+		return dynamic_cast< VarArgsType * >( type ) || GenPoly::getFunctionType( type );
+	}
+
+	ApplicationExpr * ResolveCopyCtors::makeCtorDtor( const std::string & fname, ObjectDecl * var, Expression * cpArg ) {
+		assert( var );
+		UntypedExpr * untyped = new UntypedExpr( new NameExpr( fname ) );
+		untyped->get_args().push_back( new AddressExpr( new VariableExpr( var ) ) );
+		if (cpArg) untyped->get_args().push_back( cpArg );
+
+		// resolve copy constructor
+		// should only be one alternative for copy ctor and dtor expressions, since
+		// all arguments are fixed (VariableExpr and already resolved expression)
+		PRINT( std::cerr << "ResolvingCtorDtor " << untyped << std::endl; )
+		ApplicationExpr * resolved = dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untyped, *this ) );
+		if ( resolved->get_env() ) {
+			env->add( *resolved->get_env() );
+		}
+
+		assert( resolved );
+		delete untyped;
+		return resolved;
+	}
+
+	void ResolveCopyCtors::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
+		static UniqueName tempNamer("_tmp_cp");
+		static UniqueName retNamer("_tmp_cp_ret");
+
+		PRINT( std::cerr << "ResolveCopyCtors: " << impCpCtorExpr << std::endl; )
+		Visitor::visit( impCpCtorExpr );
+		env = impCpCtorExpr->get_env(); // xxx - maybe we really should just have a PolyIndexer...
+
+		ApplicationExpr * appExpr = impCpCtorExpr->get_callExpr();
+
+		// take each argument and attempt to copy construct it.
+		for ( Expression * & arg : appExpr->get_args() ) {
+			PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; )
+			// xxx - need to handle tuple arguments
+			assert( ! arg->get_results().empty() );
+			Type * result = arg->get_results().front();
+			if ( skipCopyConstruct( result ) ) continue; // skip certain non-copyable types
+			// type may involve type variables, so apply type substitution to get temporary variable's actual type
+			result = result->clone();
+			impCpCtorExpr->get_env()->apply( result );
+			ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 );
+			tmp->get_type()->set_isConst( false );
+
+			// create and resolve copy constructor
+			PRINT( std::cerr << "makeCtorDtor for an argument" << std::endl; )
+			ApplicationExpr * cpCtor = makeCtorDtor( "?{}", tmp, arg );
+
+			// 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 = dynamic_cast< VariableExpr * >( cpCtor->get_function() );
+			assert( function );
+			if ( function->get_var()->get_linkage() != LinkageSpec::Intrinsic ) {
+				// replace argument to function call with temporary
+				arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) );
+				impCpCtorExpr->get_tempDecls().push_back( tmp );
+				impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) );
+			}
+		}
+
+		// 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 multiple return values
+		ApplicationExpr * callExpr = impCpCtorExpr->get_callExpr();
+		// xxx - is this right? callExpr may not have the right environment, because it was attached
+		// at a higher level. Trying to pass that environment along.
+		callExpr->set_env( impCpCtorExpr->get_env()->clone() );
+		for ( Type * result : appExpr->get_results() ) {
+			result = result->clone();
+			impCpCtorExpr->get_env()->apply( result );
+			ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 );
+			ret->get_type()->set_isConst( false );
+			impCpCtorExpr->get_returnDecls().push_back( ret );
+			PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; )
+			impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", ret ) );
+		}
+		PRINT( std::cerr << "after Resolving: " << impCpCtorExpr << std::endl; )
+	}
+
+
+	Expression * FixCopyCtors::mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) {
+		PRINT( std::cerr << "FixCopyCtors: " << impCpCtorExpr << std::endl; )
+
+		impCpCtorExpr = dynamic_cast< ImplicitCopyCtorExpr * >( Mutator::mutate( impCpCtorExpr ) );
+		assert( impCpCtorExpr );
+
+		std::list< ObjectDecl * > & tempDecls = impCpCtorExpr->get_tempDecls();
+		std::list< ObjectDecl * > & returnDecls = impCpCtorExpr->get_returnDecls();
+		std::list< Expression * > & dtors = impCpCtorExpr->get_dtors();
+
+		// add all temporary declarations and their constructors
+		for ( ObjectDecl * obj : tempDecls ) {
+			stmtsToAdd.push_back( new DeclStmt( noLabels, obj ) );
+		}
+		for ( ObjectDecl * obj : returnDecls ) {
+			stmtsToAdd.push_back( new DeclStmt( noLabels, obj ) );
+		}
+
+		// add destructors after current statement
+		for ( Expression * dtor : dtors ) {
+			stmtsToAddAfter.push_back( new ExprStmt( noLabels, dtor ) );
+		}
+
+		// xxx - update to work with multiple return values
+		ObjectDecl * returnDecl = returnDecls.empty() ? NULL : returnDecls.front();
+		Expression * callExpr = impCpCtorExpr->get_callExpr();
+
+		PRINT( std::cerr << "Coming out the back..." << impCpCtorExpr << std::endl; )
+
+		// xxx - some of these aren't necessary, and can be removed once this is stable
+		dtors.clear();
+		tempDecls.clear();
+		returnDecls.clear();
+		impCpCtorExpr->set_callExpr( NULL );
+		impCpCtorExpr->set_env( NULL );
+		delete impCpCtorExpr;
+
+		if ( returnDecl ) {
+			UntypedExpr * assign = new UntypedExpr( new NameExpr( "?=?" ) );
+			assign->get_args().push_back( new VariableExpr( returnDecl ) );
+			assign->get_args().push_back( callExpr );
+			// know the result type of the assignment is the type of the LHS (minus the pointer), so
+			// add that onto the assignment expression so that later steps have the necessary information
+			assign->add_result( returnDecl->get_type()->clone() );
+
+			Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) );
+			if ( callExpr->get_results().front()->get_isLvalue() ) {
+				// lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any
+				// lvalue returning non-intrinsic function. Add an AddressExpr to the call to negate
+				// the derefence and change the type of the return temporary from T to T* to properly
+				// capture the return value. Then dereference the result of the comma expression, since
+				// the lvalue returning call was originally wrapped with an AddressExpr.
+				// Effectively, this turns
+				//   lvalue T f();
+				//   &*f()
+				// into
+				//   T * tmp_cp_retN;
+				//   tmp_cp_ret_N = &*(tmp_cp_ret_N = &*f(), tmp_cp_ret);
+				// which work out in terms of types, but is pretty messy. It would be nice to find a better way.
+				assign->get_args().back() = new AddressExpr( assign->get_args().back() );
+
+				Type * resultType = returnDecl->get_type()->clone();
+				returnDecl->set_type( new PointerType( Type::Qualifiers(), returnDecl->get_type() ) );
+				UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
+				deref->get_args().push_back( retExpr );
+				deref->add_result( resultType );
+				retExpr = deref;
+			}
+			// xxx - might need to set env on retExpr...
+			// retExpr->set_env( env->clone() );
+			return retExpr;
+		} else {
+			return callExpr;
+		}
+	}
+
+	DeclarationWithType *FixInit::mutate( ObjectDecl *objDecl ) {
+		// first recursively handle pieces of ObjectDecl so that they aren't missed by other visitors
+		// when the init is removed from the ObjectDecl
+		objDecl = dynamic_cast< ObjectDecl * >( Mutator::mutate( objDecl ) );
+
+		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_storageClass() == DeclarationNode::Static ) {
+					// generate:
+					// static bool __objName_uninitialized = true;
+					// if (__objName_uninitialized) {
+					//   __ctor(__objName);
+					//   void dtor_atexit() {
+					//     __dtor(__objName);
+					//   }
+					//   on_exit(dtorOnExit, &__objName);
+					//   __objName_uninitialized = false;
+					// }
+
+					// generate first line
+					BasicType * boolType = new BasicType( Type::Qualifiers(), BasicType::Bool );
+					SingleInit * boolInitExpr = new SingleInit( new ConstantExpr( Constant( boolType->clone(), "1" ) ), noDesignators );
+					ObjectDecl * isUninitializedVar = new ObjectDecl( objDecl->get_mangleName() + "_uninitialized", DeclarationNode::Static, LinkageSpec::Cforall, 0, boolType, boolInitExpr );
+					isUninitializedVar->fixUniqueId();
+
+					// void dtor_atexit(...) {...}
+					FunctionDecl * dtorCaller = new FunctionDecl( objDecl->get_mangleName() + "_dtor_atexit", DeclarationNode::NoStorageClass, LinkageSpec::C, new FunctionType( Type::Qualifiers(), false ), new CompoundStmt( noLabels ), false, false );
+					dtorCaller->fixUniqueId();
+					dtorCaller->get_statements()->get_kids().push_back( ctorInit->get_dtor() );
+
+					// on_exit(dtor_atexit);
+					UntypedExpr * callAtexit = new UntypedExpr( new NameExpr( "atexit" ) );
+					callAtexit->get_args().push_back( new VariableExpr( dtorCaller ) );
+
+					// __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( boolType->clone(), "0" ) ) );
+
+					// generate body of if
+					CompoundStmt * initStmts = new CompoundStmt( noLabels );
+					std::list< Statement * > & body = initStmts->get_kids();
+					body.push_back( ctor );
+					body.push_back( new DeclStmt( noLabels, dtorCaller ) );
+					body.push_back( new ExprStmt( noLabels, callAtexit ) );
+					body.push_back( new ExprStmt( noLabels, setTrue ) );
+
+					// put it all together
+					IfStmt * ifStmt = new IfStmt( noLabels, new VariableExpr( isUninitializedVar ), initStmts, 0 );
+					stmtsToAddAfter.push_back( new DeclStmt( noLabels, isUninitializedVar ) );
+					stmtsToAddAfter.push_back( ifStmt );
+				} else {
+					stmtsToAddAfter.push_back( ctor );
+					dtorStmts.back().push_front( ctorInit->get_dtor() );
+				}
+				objDecl->set_init( NULL );
+				ctorInit->set_ctor( NULL );
+				ctorInit->set_dtor( NULL );  // xxx - only destruct when constructing? Probably not?
+			} else if ( Initializer * init = ctorInit->get_init() ) {
+				objDecl->set_init( init );
+				ctorInit->set_init( NULL );
+			} else {
+				// no constructor and no initializer, which is okay
+				objDecl->set_init( NULL );
+			}
+			delete ctorInit;
+		}
+		return objDecl;
+	}
+
+	template<typename Iterator, typename OutputIterator>
+	void insertDtors( Iterator begin, Iterator end, OutputIterator out ) {
+		for ( Iterator it = begin ; it != end ; ++it ) {
+			// remove if instrinsic destructor statement. Note that this is only called
+			// on lists of implicit dtors, so if the user manually calls an intrinsic
+			// dtor then the call will still be generated
+			if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( *it ) ) {
+				ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( exprStmt->get_expr() );
+				assert( appExpr );
+				VariableExpr * function = dynamic_cast< VariableExpr * >( appExpr->get_function() );
+				assert( function );
+				// check for Intrinsic only - don't want to remove all overridable dtors because autogenerated dtor
+				// will call all member dtors, and some members may have a user defined dtor.
+				if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) {
+					// don't need to call intrinsic dtor, because it does nothing
+				} else {
+					// non-intrinsic dtors must be called
+					*out++ = (*it)->clone();
+				}
+			} else {
+				// could also be a compound statement with a loop, in the case of an array
+				// xxx - write code to remove loop calling intrinsic dtor.
+				*out++ = (*it)->clone();
+			}
+		}
+	}
+
+
+	CompoundStmt * FixInit::mutate( CompoundStmt * compoundStmt ) {
+		// mutate statements - this will also populate dtorStmts list.
+		// don't want to dump all destructors when block is left,
+		// just the destructors associated with variables defined in this block,
+		// so push a new list to the top of the stack so that we can differentiate scopes
+		dtorStmts.push_back( std::list<Statement *>() );
+
+		compoundStmt = PolyMutator::mutate( compoundStmt );
+		std::list< Statement * > & statements = compoundStmt->get_kids();
+
+		insertDtors( dtorStmts.back().begin(), dtorStmts.back().end(), back_inserter( statements ) );
+
+		deleteAll( dtorStmts.back() );
+		dtorStmts.pop_back();
+		return compoundStmt;
+	}
+
+	Statement * FixInit::mutate( ReturnStmt * returnStmt ) {
+		for ( std::list< std::list< Statement * > >::reverse_iterator list = dtorStmts.rbegin(); list != dtorStmts.rend(); ++list ) {
+			insertDtors( list->begin(), list->end(), back_inserter( stmtsToAdd ) );
+		}
+		return Mutator::mutate( returnStmt );
+	}
+
+	Statement * FixInit::mutate( BranchStmt * branchStmt ) {
+		// TODO: adding to the end of a block isn't sufficient, since
+		// return/break/goto should trigger destructor when block is left.
+		switch( branchStmt->get_type() ) {
+			case BranchStmt::Continue:
+			case BranchStmt::Break:
+				insertDtors( dtorStmts.back().begin(), dtorStmts.back().end(), back_inserter( stmtsToAdd ) );
+				break;
+			case BranchStmt::Goto:
+				// xxx
+				// if goto leaves a block, generate dtors for every block it leaves
+				// if goto is in same block but earlier statement, destruct every object that was defined after the statement
+				break;
+			default:
+				assert( false );
+		}
+		return Mutator::mutate( branchStmt );
+	}
+
+
+} // namespace InitTweak
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/InitTweak/FixInit.h
===================================================================
--- src/InitTweak/FixInit.h	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
+++ src/InitTweak/FixInit.h	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
@@ -0,0 +1,38 @@
+//
+// 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.h --
+//
+// Author           : Rob Schluntz
+// Created On       : Wed Jan 13 16:29:30 2016
+// Last Modified By : Rob Schluntz
+// Last Modified On : Wed Jan 13 16:31:13 2016
+// Update Count     : 5
+//
+
+#ifndef FIX_INIT_H
+#define FIX_INIT_H
+
+#include <string>
+#include <list>
+
+#include "SynTree/SynTree.h"
+#include "SynTree/Declaration.h"
+#include "SynTree/Mutator.h"
+
+namespace InitTweak {
+  /// replace constructor initializers with expression statements
+  /// and unwrap basic C-style initializers
+	void fix( std::list< Declaration * > & translationUnit );
+} // namespace
+
+#endif // GENPOLY_POLYMUTATOR_H
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/InitTweak/GenInit.cc
===================================================================
--- src/InitTweak/GenInit.cc	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
+++ src/InitTweak/GenInit.cc	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
@@ -0,0 +1,242 @@
+//
+// 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.
+//
+// GenInit.cc --
+//
+// Author           : Rob Schluntz
+// Created On       : Mon May 18 07:44:20 2015
+// Last Modified By : Rob Schluntz
+// Last Modified On : Fri May 06 16:11:15 2016
+// Update Count     : 166
+//
+
+#include <stack>
+#include <list>
+#include "GenInit.h"
+#include "SynTree/Declaration.h"
+#include "SynTree/Type.h"
+#include "SynTree/Expression.h"
+#include "SynTree/Statement.h"
+#include "SynTree/Initializer.h"
+#include "SynTree/Mutator.h"
+#include "SymTab/Autogen.h"
+#include "GenPoly/PolyMutator.h"
+
+namespace InitTweak {
+	namespace {
+		const std::list<Label> noLabels;
+		const std::list<Expression *> noDesignators;
+	}
+
+	class ReturnFixer : public GenPoly::PolyMutator {
+	  public:
+		/// 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 );
+
+		ReturnFixer();
+
+		virtual DeclarationWithType * mutate( FunctionDecl *functionDecl );
+
+		virtual Statement * mutate( ReturnStmt * returnStmt );
+
+	  protected:
+		std::list<DeclarationWithType*> returnVals;
+		UniqueName tempNamer;
+		std::string funcName;
+	};
+
+	class CtorDtor : public GenPoly::PolyMutator {
+	  public:
+		/// create constructor and destructor statements for object declarations.
+		/// Destructors are inserted directly into the code, whereas constructors
+		/// will be added in after the resolver has run so that the initializer expression
+		/// is only removed if a constructor is found
+		static void generateCtorDtor( std::list< Declaration * > &translationUnit );
+
+		CtorDtor() : inFunction( false ) {}
+
+		virtual DeclarationWithType * mutate( ObjectDecl * );
+		virtual DeclarationWithType * mutate( FunctionDecl *functionDecl );
+		virtual Declaration* mutate( StructDecl *aggregateDecl );
+		virtual Declaration* mutate( UnionDecl *aggregateDecl );
+		virtual Declaration* mutate( EnumDecl *aggregateDecl );
+		virtual Declaration* mutate( TraitDecl *aggregateDecl );
+		virtual TypeDecl* mutate( TypeDecl *typeDecl );
+		virtual Declaration* mutate( TypedefDecl *typeDecl );
+
+		virtual Type * mutate( FunctionType *funcType );
+
+	  protected:
+		bool inFunction;
+	};
+
+	void genInit( std::list< Declaration * > & translationUnit ) {
+		ReturnFixer::makeReturnTemp( translationUnit );
+		CtorDtor::generateCtorDtor( translationUnit );
+	}
+
+	void ReturnFixer::makeReturnTemp( std::list< Declaration * > & translationUnit ) {
+		ReturnFixer fixer;
+		mutateAll( translationUnit, fixer );
+	}
+
+	ReturnFixer::ReturnFixer() : tempNamer( "_retVal" ) {}
+
+	Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) {
+		// update for multiple return values
+		assert( returnVals.size() == 0 || returnVals.size() == 1 );
+		// hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address
+		// is being returned
+		if ( returnStmt->get_expr() && returnVals.size() == 1 && funcName != "?=?" && ! returnVals.front()->get_type()->get_isLvalue() ) {
+			// ensure return value is not destructed by explicitly creating
+			// an empty SingleInit node wherein maybeConstruct is false
+			ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, returnVals.front()->get_type()->clone(), new ListInit( std::list<Initializer*>(), noDesignators, false ) );
+			stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) );
+
+			// and explicitly create the constructor expression separately
+			UntypedExpr *construct = new UntypedExpr( new NameExpr( "?{}" ) );
+			construct->get_args().push_back( new AddressExpr( new VariableExpr( newObj ) ) );
+			construct->get_args().push_back( returnStmt->get_expr() );
+			stmtsToAdd.push_back(new ExprStmt(noLabels, construct));
+
+			returnStmt->set_expr( new VariableExpr( newObj ) );
+		} // if
+		return returnStmt;
+	}
+
+	DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) {
+		std::list<DeclarationWithType*> oldReturnVals = returnVals;
+		std::string oldFuncName = funcName;
+
+		FunctionType * type = functionDecl->get_functionType();
+		returnVals = type->get_returnVals();
+		funcName = functionDecl->get_name();
+		DeclarationWithType * decl = Mutator::mutate( functionDecl );
+		returnVals = oldReturnVals;
+		funcName = oldFuncName;
+		return decl;
+	}
+
+
+	void CtorDtor::generateCtorDtor( std::list< Declaration * > & translationUnit ) {
+		CtorDtor ctordtor;
+		mutateAll( translationUnit, ctordtor );
+	}
+
+	bool tryConstruct( ObjectDecl * objDecl ) {
+		// xxx - handle designations
+		return ! LinkageSpec::isBuiltin( objDecl->get_linkage() ) &&
+ 			(objDecl->get_init() == NULL ||
+			( objDecl->get_init() != NULL && objDecl->get_init()->get_maybeConstructed() ));
+	}
+	namespace {
+
+		Expression * makeCtorDtorExpr( std::string name, ObjectDecl * objDecl, std::list< Expression * > args ) {
+			UntypedExpr * expr = new UntypedExpr( new NameExpr( name ) );
+			expr->get_args().push_back( new AddressExpr( new VariableExpr( objDecl ) ) );
+			expr->get_args().splice( expr->get_args().end(), args );
+			return expr;
+		}
+
+		class InitExpander : public Visitor {
+		  public:
+		  InitExpander() {}
+		  // ~InitExpander() {}
+			virtual void visit( SingleInit * singleInit );
+			virtual void visit( ListInit * listInit );
+			std::list< Expression * > argList;
+		};
+
+		void InitExpander::visit( SingleInit * singleInit ) {
+			argList.push_back( singleInit->get_value()->clone() );
+		}
+
+		void InitExpander::visit( ListInit * listInit ) {
+			// xxx - for now, assume no nested list inits
+			std::list<Initializer*>::iterator it = listInit->begin_initializers();
+			for ( ; it != listInit->end_initializers(); ++it ) {
+				(*it)->accept( *this );
+			}
+		}
+
+		std::list< Expression * > makeInitList( Initializer * init ) {
+			InitExpander expander;
+			maybeAccept( init, expander );
+			return expander.argList;
+		}
+	}
+
+	DeclarationWithType * CtorDtor::mutate( ObjectDecl * objDecl ) {
+		// hands off if designated or if @=
+		if ( tryConstruct( objDecl ) ) {
+			if ( inFunction ) {
+				if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->get_type() ) ) {
+					// call into makeArrayFunction from validate.cc to generate calls to ctor/dtor for each element of array
+					// TODO: walk initializer and generate appropriate copy ctor if element has initializer
+					std::list< Statement * > ctor;
+					std::list< Statement * > dtor;
+
+					SymTab::makeArrayFunction( NULL, new VariableExpr( objDecl ), at, "?{}", back_inserter( ctor ) );
+					SymTab::makeArrayFunction( NULL, new VariableExpr( objDecl ), at, "^?{}", front_inserter( dtor ), false );
+
+					// Currently makeArrayFunction 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 makeArrayFunction
+					// itself
+					assert( ctor.size() == 1 );
+					assert( dtor.size() == 1 );
+
+					objDecl->set_init( new ConstructorInit( ctor.front(), dtor.front(), objDecl->get_init() ) );
+				} else {
+					// it's sufficient to attempt to call the ctor/dtor for the given object and its initializer
+					Expression * ctor = makeCtorDtorExpr( "?{}", objDecl, makeInitList( objDecl->get_init() ) );
+					Expression * dtor = makeCtorDtorExpr( "^?{}", objDecl, std::list< Expression * >() );
+
+					// 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
+					ExprStmt * ctorStmt = new ExprStmt( noLabels, ctor );
+					ExprStmt * dtorStmt = new ExprStmt( noLabels, dtor );
+					objDecl->set_init( new ConstructorInit( ctorStmt, dtorStmt, objDecl->get_init() ) );
+				}
+			}
+		}
+		return Mutator::mutate( objDecl );
+	}
+
+	DeclarationWithType * CtorDtor::mutate( FunctionDecl *functionDecl ) {
+		// parameters should not be constructed and destructed, so don't mutate FunctionType
+		bool oldInFunc = inFunction;
+		mutateAll( functionDecl->get_oldDecls(), *this );
+		inFunction = true;
+		functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
+		inFunction = oldInFunc;
+		return functionDecl;
+	}
+
+	// should not traverse into any of these declarations to find objects
+	// that need to be constructed or destructed
+	Declaration* CtorDtor::mutate( StructDecl *aggregateDecl ) { return aggregateDecl; }
+	Declaration* CtorDtor::mutate( UnionDecl *aggregateDecl ) { return aggregateDecl; }
+	Declaration* CtorDtor::mutate( EnumDecl *aggregateDecl ) { return aggregateDecl; }
+	Declaration* CtorDtor::mutate( TraitDecl *aggregateDecl ) { return aggregateDecl; }
+	TypeDecl* CtorDtor::mutate( TypeDecl *typeDecl ) { return typeDecl; }
+	Declaration* CtorDtor::mutate( TypedefDecl *typeDecl ) { return typeDecl; }
+	Type* CtorDtor::mutate( FunctionType *funcType ) { return funcType; }
+
+} // namespace InitTweak
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/InitTweak/GenInit.h
===================================================================
--- src/InitTweak/GenInit.h	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
+++ src/InitTweak/GenInit.h	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
@@ -0,0 +1,39 @@
+//
+// 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.
+//
+// RemoveInit.h --
+//
+// Author           : Rodolfo G. Esteves
+// Created On       : Mon May 18 07:44:20 2015
+// Last Modified By : Rob Schluntz
+// Last Modified On : Fri May 06 16:18:22 2016
+// Update Count     : 3
+//
+
+#ifndef GEN_INIT_H
+#define GEN_INIT_H
+
+#include <string>
+#include <list>
+
+#include "SynTree/SynTree.h"
+#include "SynTree/Declaration.h"
+#include "SynTree/Mutator.h"
+
+namespace InitTweak {
+	/// Adds return value temporaries and wraps Initializers in ConstructorInit nodes
+	void genInit( std::list< Declaration * > & translationUnit );
+	/// True if the resolver should try to construct objDecl
+	bool tryConstruct( ObjectDecl * objDecl );
+} // namespace
+
+#endif // INITTWEAK_GENINIT_H
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/InitTweak/InitModel.cc
===================================================================
--- src/InitTweak/InitModel.cc	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
+++ src/InitTweak/InitModel.cc	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
@@ -5,11 +5,11 @@
 // file "LICENCE" distributed with Cforall.
 //
-// InitModel.cc -- 
+// InitModel.cc --
 //
 // Author           : Rodolfo G. Esteves
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue May 19 16:37:08 2015
-// Update Count     : 1
+// Last Modified By : Rob Schluntz
+// Last Modified On : Thu Jan 07 13:38:46 2016
+// Update Count     : 5
 //
 
@@ -198,5 +198,5 @@
 		assert(init == 0 && single != 0);
 		std::list< Expression * > empty;
-		init = new SingleInit( single->get_expr(), empty );
+		init = new SingleInit( single->get_expr(), empty, false ); // cannot be constructed
 		return;
 	}
@@ -214,5 +214,6 @@
 			} // if
 
-		init = new ListInit( contents );
+		std::list< Expression * > desig;
+		init = new ListInit( contents, desig, false ); // cannot be constructed
 		return;
 	}
Index: src/InitTweak/RemoveInit.cc
===================================================================
--- src/InitTweak/RemoveInit.cc	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
+++ 	(revision )
@@ -1,127 +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.
-//
-// RemoveInit.cc -- 
-//
-// Author           : Rob Schluntz
-// Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Tue Dec 15 15:37:26 2015
-// Update Count     : 15
-//
-
-#include "RemoveInit.h"
-#include "SynTree/Declaration.h"
-#include "SynTree/Type.h"
-#include "SynTree/Expression.h"
-#include "SynTree/Statement.h"
-#include "SynTree/Initializer.h"
-#include "SynTree/Mutator.h"
-
-namespace InitTweak {
-	namespace {
-		const std::list<Label> noLabels;
-	}
-	
-	class RemoveInit : public Mutator {
-	  public:
-		RemoveInit();
-		virtual ObjectDecl * mutate(ObjectDecl *objDecl);
-		virtual DeclarationWithType * mutate( FunctionDecl *functionDecl );
-
-		virtual Statement * mutate( ReturnStmt * returnStmt );
-		
-		virtual CompoundStmt * mutate(CompoundStmt * compoundStmt);
-		
-	  protected:
-		std::list< Statement* > stmtsToAddBefore;
-		std::list< Statement* > stmtsToAddAfter;
-		void mutateStatementList( std::list< Statement* > &statements );
-
-		std::list<DeclarationWithType*> returnVals;
-		UniqueName tempNamer;
-		std::string funcName;
-	};
-
-	void tweak( std::list< Declaration * > translationUnit ) {
-		RemoveInit remover;
-		mutateAll( translationUnit, remover );
-	}
-
-	RemoveInit::RemoveInit() : tempNamer( "_retVal" ) {}
-	
-	void RemoveInit::mutateStatementList( std::list< Statement* > &statements ) {
-		for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) {
-			if ( ! stmtsToAddAfter.empty() ) {
-				statements.splice( i, stmtsToAddAfter );
-			} // if
-			*i = (*i)->acceptMutator( *this );
-			if ( ! stmtsToAddBefore.empty() ) {
-				statements.splice( i, stmtsToAddBefore );
-			} // if
-		} // for
-		if ( ! stmtsToAddAfter.empty() ) {
-			statements.splice( statements.end(), stmtsToAddAfter );
-		} // if
-	}
-
-	CompoundStmt *RemoveInit::mutate(CompoundStmt *compoundStmt) {
-		mutateStatementList( compoundStmt->get_kids() );
-		return compoundStmt;
-	}
-
-	// in the case where an object has an initializer and a polymorphic type, insert an assignment immediately after the
-	// declaration. This will (seemingly) cause the later phases to do the right thing with the assignment
-	ObjectDecl *RemoveInit::mutate( ObjectDecl *objDecl ) {
-		if (objDecl->get_init() && dynamic_cast<TypeInstType*>(objDecl->get_type())) {
-			if (SingleInit * single = dynamic_cast<SingleInit*>(objDecl->get_init())) {
-				UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) );
-				assign->get_args().push_back( new AddressExpr (new NameExpr( objDecl->get_name() ) ) );
-				assign->get_args().push_back( single->get_value()->clone() );
-				stmtsToAddAfter.push_back(new ExprStmt(noLabels, assign));
-			} // if
-		} // if
-		return objDecl;
-	}
-
-	Statement *RemoveInit::mutate( ReturnStmt *returnStmt ) {
-		// update for multiple return values
-		assert( returnVals.size() == 0 || returnVals.size() == 1 );
-		// hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address
-		// is being returned
-		if ( returnStmt->get_expr() && returnVals.size() == 1 && funcName != "?=?" && ! returnVals.front()->get_type()->get_isLvalue()  ) {
-			ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, returnVals.front()->get_type()->clone(), 0 );
-			stmtsToAddBefore.push_back( new DeclStmt( noLabels, newObj ) );
-			
-			UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) );
-			assign->get_args().push_back( new AddressExpr (new NameExpr( newObj->get_name() ) ) );
-			assign->get_args().push_back( returnStmt->get_expr() );
-			stmtsToAddBefore.push_back(new ExprStmt(noLabels, assign));
-
-			returnStmt->set_expr( new VariableExpr( newObj ) );
-		} // if
-		return returnStmt;
-	}
-
-	DeclarationWithType* RemoveInit::mutate( FunctionDecl *functionDecl ) {
-		std::list<DeclarationWithType*> oldReturnVals = returnVals;
-		std::string oldFuncName = funcName;
-		
-		FunctionType * type = functionDecl->get_functionType();
-		returnVals = type->get_returnVals();
-		funcName = functionDecl->get_name();
-		DeclarationWithType * decl = Mutator::mutate( functionDecl );
-		returnVals = oldReturnVals;
-		funcName = oldFuncName;
-		return decl;
-	}
-} // namespace InitTweak
-
-// Local Variables: //
-// tab-width: 4 //
-// mode: c++ //
-// compile-command: "make install" //
-// End: //
Index: src/InitTweak/RemoveInit.h
===================================================================
--- src/InitTweak/RemoveInit.h	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
+++ 	(revision )
@@ -1,37 +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.
-//
-// RemoveInit.h -- 
-//
-// Author           : Rodolfo G. Esteves
-// Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Nov 27 17:00:47 2015
-// Update Count     : 2
-//
-
-#ifndef REMOVE_INIT_H
-#define REMOVE_INIT_H
-
-#include <string>
-#include <list>
-
-#include "SynTree/SynTree.h"
-#include "SynTree/Declaration.h"
-#include "SynTree/Mutator.h"
-
-namespace InitTweak {
-	/// Adds assignment statements for polymorphic type initializers
-	void tweak( std::list< Declaration * > translationUnit );
-} // namespace 
-
-#endif // GENPOLY_POLYMUTATOR_H
-
-// Local Variables: //
-// tab-width: 4 //
-// mode: c++ //
-// compile-command: "make install" //
-// End: //
Index: src/InitTweak/module.mk
===================================================================
--- src/InitTweak/module.mk	(revision 03e5d14fed7fb921c0dfadb3761247f19a7f91e8)
+++ src/InitTweak/module.mk	(revision 9e2c1f036fddf8f841b5d1d1b225d3cb03a7ca67)
@@ -11,9 +11,10 @@
 ## Created On       : Mon Jun  1 17:49:17 2015
 ## Last Modified By : Rob Schluntz
-## Last Modified On : Wed May 04 16:03:49 2016
-## Update Count     : 2
+## Last Modified On : Fri May 06 15:59:27 2016
+## Update Count     : 3
 ###############################################################################
 
-SRC += InitTweak/RemoveInit.cc \
+SRC += InitTweak/GenInit.cc \
+	InitTweak/FixInit.cc \
 	InitTweak/FixGlobalInit.cc
 
