Index: src/CodeGen/CodeGenerator.cc
===================================================================
--- src/CodeGen/CodeGenerator.cc	(revision 934fa0fc6af3737f7f5b45e08f4b84e1e8259312)
+++ 	(revision )
@@ -1,1255 +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.
-//
-// CodeGenerator.cc --
-//
-// Author           : Richard C. Bilson
-// Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Andrew Beach
-// Last Modified On : Wed Jun 29 14:34:00 2022
-// Update Count     : 542
-//
-#include "CodeGenerator.h"
-
-#include <cassert>                   // for assert, assertf
-#include <list>                      // for _List_iterator, list, list<>::it...
-#include <sstream>                   // for stringstream
-
-#include "AST/Decl.hpp"              // for DeclWithType
-#include "Common/UniqueName.h"       // for UniqueName
-#include "GenType.h"                 // for genType
-#include "InitTweak/InitTweak.h"     // for getPointerBase
-#include "OperatorTable.h"           // for OperatorInfo, operatorLookup
-#include "SynTree/LinkageSpec.h"     // for Spec, Intrinsic
-#include "SynTree/Attribute.h"       // for Attribute
-#include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
-#include "SynTree/Constant.h"        // for Constant
-#include "SynTree/Declaration.h"     // for DeclarationWithType, TypeDecl
-#include "SynTree/Expression.h"      // for Expression, UntypedExpr, Applica...
-#include "SynTree/Initializer.h"     // for Initializer, ListInit, Designation
-#include "SynTree/Label.h"           // for Label, operator<<
-#include "SynTree/Statement.h"       // for Statement, AsmStmt, BranchStmt
-#include "SynTree/Type.h"            // for Type, Type::StorageClasses, Func...
-
-using namespace std;
-
-namespace CodeGen {
-	int CodeGenerator::tabsize = 4;
-
-	// The kinds of statements that would ideally be followed by whitespace.
-	bool wantSpacing( Statement * stmt) {
-		return dynamic_cast< IfStmt * >( stmt ) || dynamic_cast< CompoundStmt * >( stmt ) ||
-			dynamic_cast< WhileDoStmt * >( stmt ) || dynamic_cast< ForStmt * >( stmt ) || dynamic_cast< SwitchStmt *>( stmt );
-	}
-
-	void CodeGenerator::extension( Expression * expr ) {
-		if ( expr->get_extension() ) {
-			output << "__extension__ ";
-		} // if
-	} // extension
-
-	void CodeGenerator::extension( Declaration * decl ) {
-		if ( decl->get_extension() ) {
-			output << "__extension__ ";
-		} // if
-	} // extension
-
-	void CodeGenerator::asmName( DeclarationWithType * decl ) {
-		if ( ConstantExpr * asmName = dynamic_cast<ConstantExpr *>(decl->get_asmName()) ) {
-			output << " asm ( " << asmName->get_constant()->get_value() << " )";
-		} // if
-	} // extension
-
-	CodeGenerator::LabelPrinter & CodeGenerator::LabelPrinter::operator()( std::list< Label > & l ) {
-		labels = &l;
-		return *this;
-	}
-
-	ostream & operator<<( ostream & output, CodeGenerator::LabelPrinter & printLabels ) {
-		std::list< Label > & labs = *printLabels.labels;
-		// l.unique(); // assumes a sorted list. Why not use set? Does order matter?
-		for ( Label & l : labs ) {
-			output << l.get_name() + ": ";
-			printLabels.cg.genAttributes( l.get_attributes() );
-		} // for
-		return output;
-	}
-
-	// Using updateLocation at the beginning of a node and endl within a node should become the method of formating.
-	void CodeGenerator::updateLocation( CodeLocation const & to ) {
-		// skip if linemarks shouldn't appear or if codelocation is unset
-		if ( !options.lineMarks || to.isUnset() ) return;
-
-		if ( currentLocation.followedBy( to, 0 ) ) {
-			return;
-		} else if ( currentLocation.followedBy( to, 1 ) ) {
-			output << "\n" << indent;
-			currentLocation.first_line += 1;
-		} else if ( currentLocation.followedBy( to, 2 ) ) {
-			output << "\n\n" << indent;
-			currentLocation.first_line += 2;
-		} else {
-			output << "\n# " << to.first_line << " \"" << to.filename
-				   << "\"\n" << indent;
-			currentLocation = to;
-		}
-		output << std::flush;
-	}
-
-	void CodeGenerator::updateLocation( BaseSyntaxNode const * to ) {
-		updateLocation( to->location );
-	}
-
-	// replace endl
-	ostream & CodeGenerator::LineEnder::operator()( ostream & os ) const {
-		// if ( !cg.lineMarks ) {
-		// 	os << "\n" << cg.indent << std::flush;
-		// }
-		os << "\n" << std::flush;
-		cg.currentLocation.first_line++;
-		// os << "/* did endl; current loc is: " << cg.currentLocation.first_line << "*/";
-		return os;
-	}
-
-	CodeGenerator::CodeGenerator( std::ostream & os, bool pretty, bool genC, bool lineMarks, bool printExprTypes ) : indent( 0, CodeGenerator::tabsize ), output( os ), printLabels( *this ), options( pretty, genC, lineMarks, printExprTypes ), endl( *this ) {}
-	CodeGenerator::CodeGenerator( std::ostream & os, const Options &options ) : indent( 0, CodeGenerator::tabsize ), output( os ), printLabels( *this ), options(options), endl( *this ) {}
-
-	string CodeGenerator::mangleName( DeclarationWithType * decl ) {
-		// GCC builtins should always be printed unmangled
-		if ( options.pretty || decl->linkage.is_gcc_builtin ) return decl->name;
-		if ( LinkageSpec::isMangled(decl->linkage) && decl->mangleName != "" ) {
-			// need to incorporate scope level in order to differentiate names for destructors
-			return decl->get_scopedMangleName();
-		} else {
-			return decl->name;
-		} // if
-	}
-
-	void CodeGenerator::genAttributes( list< Attribute * > & attributes ) {
-		if ( attributes.empty() ) return;
-		output << "__attribute__ ((";
-		for ( list< Attribute * >::iterator attr( attributes.begin() );; ) {
-			output << (*attr)->name;
-			if ( ! (*attr)->parameters.empty() ) {
-				output << "(";
-				genCommaList( (*attr)->parameters.begin(), (*attr)->parameters.end() );
-				output << ")";
-			} // if
-			if ( ++attr == attributes.end() ) break;
-			output << ",";								// separator
-		} // for
-		output << ")) ";
-	} // CodeGenerator::genAttributes
-
-	// *** BaseSyntaxNode
-	void CodeGenerator::previsit( BaseSyntaxNode * node ) {
-		// turn off automatic recursion for all nodes, to allow each visitor to
-		// precisely control the order in which its children are visited.
-		visit_children = false;
-		updateLocation( node );
-	}
-
-	// *** BaseSyntaxNode
-	void CodeGenerator::postvisit( BaseSyntaxNode * node ) {
-		std::stringstream ss;
-		node->print( ss );
-		assertf( false, "Unhandled node reached in CodeGenerator: %s", ss.str().c_str() );
-	}
-
-	// *** Expression
-	void CodeGenerator::previsit( Expression * node ) {
-		previsit( (BaseSyntaxNode *)node );
-		GuardAction( [this, node](){
-				if ( options.printExprTypes && node->result ) {
-					output << " /* " << genType( node->result, "", options ) << " */ ";
-				}
-			} );
-	}
-
-	// *** Declarations
-	void CodeGenerator::postvisit( FunctionDecl * functionDecl ) {
-		// deleted decls should never be used, so don't print them
-		if ( functionDecl->isDeleted && options.genC ) return;
-		extension( functionDecl );
-		genAttributes( functionDecl->get_attributes() );
-
-		handleStorageClass( functionDecl );
-		functionDecl->get_funcSpec().print( output );
-
-		Options subOptions = options;
-		subOptions.anonymousUnused = functionDecl->has_body();
-		output << genType( functionDecl->get_functionType(), mangleName( functionDecl ), subOptions );
-
-		asmName( functionDecl );
-
-		if ( functionDecl->get_statements() ) {
-			functionDecl->get_statements()->accept( *visitor );
-		} // if
-		if ( functionDecl->isDeleted ) {
-			output << " = void";
-		}
-	}
-
-	void CodeGenerator::postvisit( ObjectDecl * objectDecl ) {
-		// deleted decls should never be used, so don't print them
-		if ( objectDecl->isDeleted && options.genC ) return;
-
-		// gcc allows an empty declarator (no name) for bit-fields and C states: 6.7.2.1 Structure and union specifiers,
-		// point 4, page 113: If the (bit field) value is zero, the declaration shall have no declarator.  For anything
-		// else, the anonymous name refers to the anonymous object for plan9 inheritance.
-		if ( objectDecl->get_name().empty() && options.genC && ! objectDecl->get_bitfieldWidth() ) {
-			// only generate an anonymous name when generating C code, otherwise it clutters the output too much
-			static UniqueName name = { "__anonymous_object" };
-			objectDecl->set_name( name.newName() );
-			// Stops unused parameter warnings.
-			if ( options.anonymousUnused ) {
-				objectDecl->attributes.push_back( new Attribute( "unused" ) );
-			}
-		}
-
-		extension( objectDecl );
-		genAttributes( objectDecl->get_attributes() );
-
-		handleStorageClass( objectDecl );
-		output << genType( objectDecl->get_type(), mangleName( objectDecl ), options.pretty, options.genC );
-
-		asmName( objectDecl );
-
-		if ( objectDecl->get_init() ) {
-			output << " = ";
-			objectDecl->get_init()->accept( *visitor );
-		} // if
-		if ( objectDecl->isDeleted ) {
-			output << " = void";
-		}
-
-		if ( objectDecl->get_bitfieldWidth() ) {
-			output << ":";
-			objectDecl->get_bitfieldWidth()->accept( *visitor );
-		} // if
-	}
-
-	void CodeGenerator::handleAggregate( AggregateDecl * aggDecl, const std::string & kind ) {
-		if( ! aggDecl->parameters.empty() && ! options.genC ) {
-			// assertf( ! genC, "Aggregate type parameters should not reach code generation." );
-			output << "forall(";
-			genCommaList( aggDecl->parameters.begin(), aggDecl->parameters.end() );
-			output << ")" << endl;
-			output << indent;
-		}
-
-		output << kind;
-		genAttributes( aggDecl->attributes );
-		output << aggDecl->name;
-
-		if ( aggDecl->has_body() ) {
-			std::list< Declaration * > & memb = aggDecl->members;
-			output << " {" << endl;
-
-			++indent;
-			for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++ ) {
-				output << indent;
-				(*i)->accept( *visitor );
-				output << ";" << endl;
-			} // for
-
-			--indent;
-
-			output << indent << "}";
-		} // if
-	}
-
-	void CodeGenerator::postvisit( StructDecl * structDecl ) {
-		extension( structDecl );
-		handleAggregate( structDecl, "struct " );
-	}
-
-	void CodeGenerator::postvisit( UnionDecl * unionDecl ) {
-		extension( unionDecl );
-		handleAggregate( unionDecl, "union " );
-	}
-
-	template<typename pass_type>
-	inline void genEnumInitializer( PassVisitor<pass_type> * visitor, Type * baseType, std::ostream & output,
-	Initializer * init, long long * cur_val, Options options) {
-		auto baseTypeAsBasic = baseType ? dynamic_cast<BasicType *>( baseType ) : nullptr;
-		if ( init ) { // If value has an explicit initiazatior 
-			output << " = "; 
-			output << "(" << genType(baseType, "", options) << ")";
-			init->accept( *visitor );
-			if ( baseTypeAsBasic && baseTypeAsBasic->isInteger() ) { // if it is an integral type and initilizer offered, 
-			// need to update the cur_val
-				Expression* expr = ((SingleInit *)(init))->value;
-				while ( auto temp = dynamic_cast<CastExpr *>(expr) ) { // unwrap introduced cast
-					expr = temp->arg;
-				}
-				*cur_val = ((ConstantExpr *)expr)->constant.get_ival()+1;
-			}
-		} else if ( baseTypeAsBasic && baseTypeAsBasic->isInteger() ) { // integral implicitly init to cur_val + 1
-			output << " = " << "(" << genType(baseType, "", options) << ")";
-			output << (*cur_val)++;
-		}
-	}
-
-	void CodeGenerator::postvisit( EnumDecl * enumDecl ) {
-		extension( enumDecl );
-		std::list< Declaration* > &memb = enumDecl->get_members();
-		if (enumDecl->base && ! memb.empty()) {
-			long long cur_val = 0;
-			for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
-				ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i );
-				assert( obj );
-				output << "static ";
-				output << genType(enumDecl->base, mangleName( obj ), options);
-				genEnumInitializer( visitor, enumDecl->base, output, obj->get_init(), &cur_val, options);
-				output << ";" << endl;
-			} // for
-		} else {
-			output << "enum ";
-			genAttributes( enumDecl->get_attributes() );
-
-			output << enumDecl->get_name();
-
-			if ( ! memb.empty() ) {
-				output << " {" << endl;
-
-				++indent;
-				for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end();  i++) {
-					ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i );
-					assert( obj );
-					output << indent << mangleName( obj );
-					if ( obj->get_init() ) {
-						output << " = ";
-						obj->get_init()->accept( *visitor );
-					} // if
-					output << "," << endl;
-				} // for
-			--indent;
-			output << indent << "}";
-			} // if
-		} // if
-	}
-
-	void CodeGenerator::postvisit( TraitDecl * traitDecl ) {
-		assertf( ! options.genC, "TraitDecls should not reach code generation." );
-		extension( traitDecl );
-		handleAggregate( traitDecl, "trait " );
-	}
-
-	void CodeGenerator::postvisit( TypedefDecl * typeDecl ) {
-		assertf( ! options.genC, "Typedefs are removed and substituted in earlier passes." );
-		output << "typedef ";
-		output << genType( typeDecl->get_base(), typeDecl->get_name(), options ) << endl;
-	}
-
-	void CodeGenerator::postvisit( TypeDecl * typeDecl ) {
-		assertf( ! options.genC, "TypeDecls should not reach code generation." );
-		output << typeDecl->genTypeString() << " " << typeDecl->name;
-		if ( typeDecl->sized ) {
-			output << " | sized(" << typeDecl->name << ")";
-		}
-		if ( ! typeDecl->assertions.empty() ) {
-			output << " | { ";
-			for ( DeclarationWithType * assert :  typeDecl->assertions ) {
-				assert->accept( *visitor );
-				output << "; ";
-			}
-			output << " }";
-		}
-	}
-
-	void CodeGenerator::postvisit( StaticAssertDecl * assertDecl ) {
-		output << "_Static_assert(";
-		assertDecl->condition->accept( *visitor );
-		output << ", ";
-		assertDecl->message->accept( *visitor );
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( Designation * designation ) {
-		std::list< Expression * > designators = designation->get_designators();
-		if ( designators.size() == 0 ) return;
-		for ( Expression * des : designators ) {
-			if ( dynamic_cast< NameExpr * >( des ) || dynamic_cast< VariableExpr * >( des ) ) {
-				// if expression is a NameExpr or VariableExpr, then initializing aggregate member
-				output << ".";
-				des->accept( *visitor );
-			} else {
-				// otherwise, it has to be a ConstantExpr or CastExpr, initializing array element
-				output << "[";
-				des->accept( *visitor );
-				output << "]";
-			} // if
-		} // for
-		output << " = ";
-	}
-
-	void CodeGenerator::postvisit( SingleInit * init ) {
-		init->get_value()->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( ListInit * init ) {
-		auto initBegin = init->begin();
-		auto initEnd = init->end();
-		auto desigBegin = init->get_designations().begin();
-		auto desigEnd = init->get_designations().end();
-
-		output << "{ ";
-		for ( ; initBegin != initEnd && desigBegin != desigEnd; ) {
-			(*desigBegin)->accept( *visitor );
-			(*initBegin)->accept( *visitor );
-			++initBegin, ++desigBegin;
-			if ( initBegin != initEnd ) {
-				output << ", ";
-			}
-		}
-		output << " }";
-		assertf( initBegin == initEnd && desigBegin == desigEnd, "Initializers and designators not the same length. %s", toString( init ).c_str() );
-	}
-
-	void CodeGenerator::postvisit( ConstructorInit * init ){
-		assertf( ! options.genC, "ConstructorInit nodes should not reach code generation." );
-		// pseudo-output for constructor/destructor pairs
-		output << "<ctorinit>{" << endl << ++indent << "ctor: ";
-		maybeAccept( init->get_ctor(), *visitor );
-		output << ", " << endl << indent << "dtor: ";
-		maybeAccept( init->get_dtor(), *visitor );
-		output << endl << --indent << "}";
-	}
-
-	void CodeGenerator::postvisit( Constant * constant ) {
-		output << constant->get_value();
-	}
-
-	// *** Expressions
-	void CodeGenerator::postvisit( ApplicationExpr * applicationExpr ) {
-		extension( applicationExpr );
-		if ( VariableExpr * varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) {
-			const OperatorInfo * opInfo;
-			if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && ( opInfo = operatorLookup( varExpr->get_var()->get_name() ) ) ) {
-				std::list< Expression* >::iterator arg = applicationExpr->get_args().begin();
-				switch ( opInfo->type ) {
-				  case OT_INDEX:
-					assert( applicationExpr->get_args().size() == 2 );
-					(*arg++)->accept( *visitor );
-					output << "[";
-					(*arg)->accept( *visitor );
-					output << "]";
-					break;
-
-				  case OT_CALL:
-					// there are no intrinsic definitions of the function call operator
-					assert( false );
-					break;
-
-				  case OT_CTOR:
-				  case OT_DTOR:
-					if ( applicationExpr->get_args().size() == 1 ) {
-						// the expression fed into a single parameter constructor or destructor may contain side
-						// effects, so must still output this expression
-						output << "(";
-						(*arg++)->accept( *visitor );
-						output << ") /* " << opInfo->inputName << " */";
-					} else if ( applicationExpr->get_args().size() == 2 ) {
-						// intrinsic two parameter constructors are essentially bitwise assignment
-						output << "(";
-						(*arg++)->accept( *visitor );
-						output << opInfo->symbol;
-						(*arg)->accept( *visitor );
-						output << ") /* " << opInfo->inputName << " */";
-					} else {
-						// no constructors with 0 or more than 2 parameters
-						assert( false );
-					} // if
-					break;
-
-				  case OT_PREFIX:
-				  case OT_PREFIXASSIGN:
-					assert( applicationExpr->get_args().size() == 1 );
-					output << "(";
-					output << opInfo->symbol;
-					(*arg)->accept( *visitor );
-					output << ")";
-					break;
-
-				  case OT_POSTFIX:
-				  case OT_POSTFIXASSIGN:
-					assert( applicationExpr->get_args().size() == 1 );
-					(*arg)->accept( *visitor );
-					output << opInfo->symbol;
-					break;
-
-
-				  case OT_INFIX:
-				  case OT_INFIXASSIGN:
-					assert( applicationExpr->get_args().size() == 2 );
-					output << "(";
-					(*arg++)->accept( *visitor );
-					output << opInfo->symbol;
-					(*arg)->accept( *visitor );
-					output << ")";
-					break;
-
-				  case OT_CONSTANT:
-				  case OT_LABELADDRESS:
-					// there are no intrinsic definitions of 0/1 or label addresses as functions
-					assert( false );
-				} // switch
-			} else if( varExpr->get_var()->get_linkage() == LinkageSpec::BuiltinCFA && varExpr->get_var()->get_name() == "intptr" ) {
-				// THIS is a hack to make it a constant until a proper constexpr solution is created
-				output << "((void*)";
-				std::list< Expression* >::iterator arg = applicationExpr->get_args().begin();
-				(*arg++)->accept( *visitor );
-				output << ")";
-			} else {
-				varExpr->accept( *visitor );
-				output << "(";
-				genCommaList( applicationExpr->get_args().begin(), applicationExpr->get_args().end() );
-				output << ")";
-			} // if
-		} else {
-			applicationExpr->get_function()->accept( *visitor );
-			output << "(";
-			genCommaList( applicationExpr->get_args().begin(), applicationExpr->get_args().end() );
-			output << ")";
-		} // if
-	}
-
-	void CodeGenerator::postvisit( UntypedExpr * untypedExpr ) {
-		extension( untypedExpr );
-		if ( NameExpr * nameExpr = dynamic_cast< NameExpr* >( untypedExpr->function ) ) {
-			const OperatorInfo * opInfo = operatorLookup( nameExpr->name );
-			if ( opInfo ) {
-				std::list< Expression* >::iterator arg = untypedExpr->args.begin();
-				switch ( opInfo->type ) {
-				  case OT_INDEX:
-					assert( untypedExpr->args.size() == 2 );
-					(*arg++)->accept( *visitor );
-					output << "[";
-					(*arg)->accept( *visitor );
-					output << "]";
-					break;
-
-				  case OT_CALL:
-					assert( false );
-
-				  case OT_CTOR:
-				  case OT_DTOR:
-					if ( untypedExpr->args.size() == 1 ) {
-						// the expression fed into a single parameter constructor or destructor may contain side
-						// effects, so must still output this expression
-						output << "(";
-						(*arg++)->accept( *visitor );
-						output << ") /* " << opInfo->inputName << " */";
-					} else if ( untypedExpr->get_args().size() == 2 ) {
-						// intrinsic two parameter constructors are essentially bitwise assignment
-						output << "(";
-						(*arg++)->accept( *visitor );
-						output << opInfo->symbol;
-						(*arg)->accept( *visitor );
-						output << ") /* " << opInfo->inputName << " */";
-					} else {
-						// no constructors with 0 or more than 2 parameters
-						assertf( ! options.genC, "UntypedExpr constructor/destructor with 0 or more than 2 parameters." );
-						output << "(";
-						(*arg++)->accept( *visitor );
-						output << opInfo->symbol << "{ ";
-						genCommaList( arg, untypedExpr->args.end() );
-						output << "}) /* " << opInfo->inputName << " */";
-					} // if
-					break;
-
-				  case OT_PREFIX:
-				  case OT_PREFIXASSIGN:
-				  case OT_LABELADDRESS:
-					assert( untypedExpr->args.size() == 1 );
-					output << "(";
-					output << opInfo->symbol;
-					(*arg)->accept( *visitor );
-					output << ")";
-					break;
-
-				  case OT_POSTFIX:
-				  case OT_POSTFIXASSIGN:
-					assert( untypedExpr->args.size() == 1 );
-					(*arg)->accept( *visitor );
-					output << opInfo->symbol;
-					break;
-
-				  case OT_INFIX:
-				  case OT_INFIXASSIGN:
-					assert( untypedExpr->args.size() == 2 );
-					output << "(";
-					(*arg++)->accept( *visitor );
-					output << opInfo->symbol;
-					(*arg)->accept( *visitor );
-					output << ")";
-					break;
-
-				  case OT_CONSTANT:
-					// there are no intrinsic definitions of 0 or 1 as functions
-					assert( false );
-				} // switch
-			} else {
-				// builtin routines
-				nameExpr->accept( *visitor );
-				output << "(";
-				genCommaList( untypedExpr->args.begin(), untypedExpr->args.end() );
-				output << ")";
-			} // if
-		} else {
-			untypedExpr->function->accept( *visitor );
-			output << "(";
-			genCommaList( untypedExpr->args.begin(), untypedExpr->args.end() );
-			output << ")";
-		} // if
-	}
-
-	void CodeGenerator::postvisit( RangeExpr * rangeExpr ) {
-		rangeExpr->low->accept( *visitor );
-		output << " ... ";
-		rangeExpr->high->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( NameExpr * nameExpr ) {
-		extension( nameExpr );
-		const OperatorInfo * opInfo = operatorLookup( nameExpr->name );
-		if ( opInfo ) {
-			if ( opInfo->type == OT_CONSTANT ) {
-				output << opInfo->symbol;
-			} else {
-				output << opInfo->outputName;
-			}
-		} else {
-			output << nameExpr->get_name();
-		} // if
-	}
-
-	void CodeGenerator::postvisit( DimensionExpr * dimensionExpr ) {
-		extension( dimensionExpr );
-		output << "/*non-type*/" << dimensionExpr->get_name();
-	}
-
-	void CodeGenerator::postvisit( AddressExpr * addressExpr ) {
-		extension( addressExpr );
-		output << "(&";
-		addressExpr->arg->accept( *visitor );
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( LabelAddressExpr *addressExpr ) {
-		extension( addressExpr );
-		output << "(&&" << addressExpr->arg << ")";
-	}
-
-	void CodeGenerator::postvisit( CastExpr * castExpr ) {
-		extension( castExpr );
-		output << "(";
-		if ( castExpr->get_result()->isVoid() ) {
-			output << "(void)";
-		} else {
-			// at least one result type of cast.
-			// Note: previously, lvalue casts were skipped. Since it's now impossible for the user to write
-			// an lvalue cast, this has been taken out.
-			output << "(";
-			output << genType( castExpr->get_result(), "", options );
-			output << ")";
-		} // if
-		castExpr->arg->accept( *visitor );
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( KeywordCastExpr * castExpr ) {
-		assertf( ! options.genC, "KeywordCast should not reach code generation." );
-		extension( castExpr );
-		output << "((" << castExpr->targetString() << " &)";
-		castExpr->arg->accept( *visitor );
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( VirtualCastExpr * castExpr ) {
-		assertf( ! options.genC, "VirtualCastExpr should not reach code generation." );
-		extension( castExpr );
-		output << "(virtual ";
-		castExpr->get_arg()->accept( *visitor );
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( UntypedMemberExpr * memberExpr ) {
-		assertf( ! options.genC, "UntypedMemberExpr should not reach code generation." );
-		extension( memberExpr );
-		memberExpr->get_aggregate()->accept( *visitor );
-		output << ".";
-		memberExpr->get_member()->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( MemberExpr * memberExpr ) {
-		extension( memberExpr );
-		memberExpr->get_aggregate()->accept( *visitor );
-		output << "." << mangleName( memberExpr->get_member() );
-	}
-
-	void CodeGenerator::postvisit( VariableExpr * variableExpr ) {
-		extension( variableExpr );
-		const OperatorInfo * opInfo;
-		if( dynamic_cast<ZeroType*>( variableExpr->get_var()->get_type() ) ) {
-			output << "0";
-		} else if ( variableExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && (opInfo = operatorLookup( variableExpr->get_var()->get_name() )) && opInfo->type == OT_CONSTANT ) {
-			output << opInfo->symbol;
-		} else {
-			output << mangleName( variableExpr->get_var() );
-		} // if
-	}
-
-	void CodeGenerator::postvisit( ConstantExpr * constantExpr ) {
-		assert( constantExpr->get_constant() );
-		extension( constantExpr );
-		constantExpr->get_constant()->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( SizeofExpr * sizeofExpr ) {
-		extension( sizeofExpr );
-		output << "sizeof(";
-		if ( sizeofExpr->get_isType() ) {
-			output << genType( sizeofExpr->get_type(), "", options );
-		} else {
-			sizeofExpr->get_expr()->accept( *visitor );
-		} // if
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( AlignofExpr * alignofExpr ) {
-		// use GCC extension to avoid bumping std to C11
-		extension( alignofExpr );
-		output << "__alignof__(";
-		if ( alignofExpr->get_isType() ) {
-			output << genType( alignofExpr->get_type(), "", options );
-		} else {
-			alignofExpr->get_expr()->accept( *visitor );
-		} // if
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( UntypedOffsetofExpr * offsetofExpr ) {
-		assertf( ! options.genC, "UntypedOffsetofExpr should not reach code generation." );
-		output << "offsetof(";
-		output << genType( offsetofExpr->get_type(), "", options );
-		output << ", " << offsetofExpr->get_member();
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( OffsetofExpr * offsetofExpr ) {
-		// use GCC builtin
-		output << "__builtin_offsetof(";
-		output << genType( offsetofExpr->get_type(), "", options );
-		output << ", " << mangleName( offsetofExpr->get_member() );
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( OffsetPackExpr * offsetPackExpr ) {
-		assertf( ! options.genC, "OffsetPackExpr should not reach code generation." );
-		output << "__CFA_offsetpack(" << genType( offsetPackExpr->get_type(), "", options ) << ")";
-	}
-
-	void CodeGenerator::postvisit( LogicalExpr * logicalExpr ) {
-		extension( logicalExpr );
-		output << "(";
-		logicalExpr->get_arg1()->accept( *visitor );
-		if ( logicalExpr->get_isAnd() ) {
-			output << " && ";
-		} else {
-			output << " || ";
-		} // if
-		logicalExpr->get_arg2()->accept( *visitor );
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( ConditionalExpr * conditionalExpr ) {
-		extension( conditionalExpr );
-		output << "(";
-		conditionalExpr->get_arg1()->accept( *visitor );
-		output << " ? ";
-		conditionalExpr->get_arg2()->accept( *visitor );
-		output << " : ";
-		conditionalExpr->get_arg3()->accept( *visitor );
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( CommaExpr * commaExpr ) {
-		extension( commaExpr );
-		output << "(";
-		if ( options.genC ) {
-			// arg1 of a CommaExpr is never used, so it can be safely cast to void to reduce gcc warnings.
-			commaExpr->set_arg1( new CastExpr( commaExpr->get_arg1() ) );
-		}
-		commaExpr->get_arg1()->accept( *visitor );
-		output << " , ";
-		commaExpr->get_arg2()->accept( *visitor );
-		output << ")";
-	}
-
-	void CodeGenerator::postvisit( TupleAssignExpr * tupleExpr ) {
-		assertf( ! options.genC, "TupleAssignExpr should not reach code generation." );
-		tupleExpr->stmtExpr->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( UntypedTupleExpr * tupleExpr ) {
-		assertf( ! options.genC, "UntypedTupleExpr should not reach code generation." );
-		extension( tupleExpr );
-		output << "[";
-		genCommaList( tupleExpr->get_exprs().begin(), tupleExpr->get_exprs().end() );
-		output << "]";
-	}
-
-	void CodeGenerator::postvisit( TupleExpr * tupleExpr ) {
-		assertf( ! options.genC, "TupleExpr should not reach code generation." );
-		extension( tupleExpr );
-		output << "[";
-		genCommaList( tupleExpr->get_exprs().begin(), tupleExpr->get_exprs().end() );
-		output << "]";
-	}
-
-	void CodeGenerator::postvisit( TupleIndexExpr * tupleExpr ) {
-		assertf( ! options.genC, "TupleIndexExpr should not reach code generation." );
-		extension( tupleExpr );
-		tupleExpr->get_tuple()->accept( *visitor );
-		output << "." << tupleExpr->get_index();
-	}
-
-	void CodeGenerator::postvisit( TypeExpr * typeExpr ) {
-		// if ( options.genC ) std::cerr << "typeexpr still exists: " << typeExpr << std::endl;
-		// assertf( ! options.genC, "TypeExpr should not reach code generation." );
-		if ( ! options.genC ) {
-			output << genType( typeExpr->get_type(), "", options );
-		}
-	}
-
-	void CodeGenerator::postvisit( AsmExpr * asmExpr ) {
-		if ( !asmExpr->inout.empty() ) {
-			output << "[ ";
-			output << asmExpr->inout;
-			output << " ] ";
-		} // if
-		asmExpr->constraint->accept( *visitor );
-		output << " ( ";
-		asmExpr->operand->accept( *visitor );
-		output << " )";
-	}
-
-	void CodeGenerator::postvisit( CompoundLiteralExpr *compLitExpr ) {
-		assert( compLitExpr->get_result() && dynamic_cast< ListInit * > ( compLitExpr->get_initializer() ) );
-		output << "(" << genType( compLitExpr->get_result(), "", options ) << ")";
-		compLitExpr->get_initializer()->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( UniqueExpr * unqExpr ) {
-		assertf( ! options.genC, "Unique expressions should not reach code generation." );
-		output << "unq<" << unqExpr->get_id() << ">{ ";
-		unqExpr->get_expr()->accept( *visitor );
-		output << " }";
-	}
-
-	void CodeGenerator::postvisit( StmtExpr * stmtExpr ) {
-		std::list< Statement * > & stmts = stmtExpr->statements->kids;
-		output << "({" << endl;
-		++indent;
-		unsigned int numStmts = stmts.size();
-		unsigned int i = 0;
-		for ( Statement * stmt : stmts ) {
-			output << indent << printLabels( stmt->get_labels() );
-			if ( i+1 == numStmts ) {
-				// last statement in a statement expression needs to be handled specially -
-				// cannot cast to void, otherwise the expression statement has no value
-				if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) {
-					exprStmt->expr->accept( *visitor );
-					output << ";" << endl;
-					++i;
-					break;
-				}
-			}
-			stmt->accept( *visitor );
-			output << endl;
-			if ( wantSpacing( stmt ) ) {
-				output << endl;
-			} // if
-			++i;
-		}
-		--indent;
-		output << indent << "})";
-	}
-
-	void CodeGenerator::postvisit( ConstructorExpr * expr ) {
-		assertf( ! options.genC, "Unique expressions should not reach code generation." );
-		expr->callExpr->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( DeletedExpr * expr ) {
-		assertf( ! options.genC, "Deleted expressions should not reach code generation." );
-		expr->expr->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( DefaultArgExpr * arg ) {
-		assertf( ! options.genC, "Default argument expressions should not reach code generation." );
-		arg->expr->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( GenericExpr * expr ) {
-		assertf( ! options.genC, "C11 _Generic expressions should not reach code generation." );
-		output << "_Generic(";
-		expr->control->accept( *visitor );
-		output << ", ";
-		unsigned int numAssocs = expr->associations.size();
-		unsigned int i = 0;
-		for ( GenericExpr::Association & assoc : expr->associations ) {
-			if (assoc.isDefault) {
-				output << "default: ";
-			} else {
-				output << genType( assoc.type, "", options ) << ": ";
-			}
-			assoc.expr->accept( *visitor );
-			if ( i+1 != numAssocs ) {
-				output << ", ";
-			}
-			i++;
-		}
-		output << ")";
-	}
-
-	// *** Statements
-	void CodeGenerator::postvisit( CompoundStmt * compoundStmt ) {
-		std::list<Statement*> ks = compoundStmt->get_kids();
-		output << "{" << endl;
-
-		++indent;
-
-		for ( std::list<Statement *>::iterator i = ks.begin(); i != ks.end();  i++ ) {
-			output << indent << printLabels( (*i)->get_labels() );
-			(*i)->accept( *visitor );
-
-			output << endl;
-			if ( wantSpacing( *i ) ) {
-				output << endl;
-			} // if
-		} // for
-		--indent;
-
-		output << indent << "}";
-	}
-
-	void CodeGenerator::postvisit( ExprStmt * exprStmt ) {
-		assert( exprStmt );
-		if ( options.genC ) {
-			// cast the top-level expression to void to reduce gcc warnings.
-			exprStmt->set_expr( new CastExpr( exprStmt->get_expr() ) );
-		}
-		exprStmt->get_expr()->accept( *visitor );
-		output << ";";
-	}
-
-	void CodeGenerator::postvisit( AsmStmt * asmStmt ) {
-		output << "asm ";
-		if ( asmStmt->get_voltile() ) output << "volatile ";
-		if ( ! asmStmt->get_gotolabels().empty()  ) output << "goto ";
-		output << "( ";
-		if ( asmStmt->get_instruction() ) asmStmt->get_instruction()->accept( *visitor );
-		output << " : ";
-		genCommaList( asmStmt->get_output().begin(), asmStmt->get_output().end() );
-		output << " : ";
-		genCommaList( asmStmt->get_input().begin(), asmStmt->get_input().end() );
-		output << " : ";
-		genCommaList( asmStmt->get_clobber().begin(), asmStmt->get_clobber().end() );
-		if ( ! asmStmt->get_gotolabels().empty() ) {
-			output << " : ";
-			for ( std::list<Label>::iterator begin = asmStmt->get_gotolabels().begin();; ) {
-				output << *begin++;
-				if ( begin == asmStmt->get_gotolabels().end() ) break;
-				output << ", ";
-			} // for
-		} // if
-		output << " );";
-	}
-
-	void CodeGenerator::postvisit( AsmDecl * asmDecl ) {
-		output << "asm ";
-		AsmStmt * asmStmt = asmDecl->get_stmt();
-		output << "( ";
-		if ( asmStmt->get_instruction() ) asmStmt->get_instruction()->accept( *visitor );
-		output << " )";
-	}
-
-	void CodeGenerator::postvisit( DirectiveDecl * directiveDecl ) {
-		output << endl << directiveDecl->get_stmt()->directive;	// endl prevents spaces before directive
-	}
-
-	void CodeGenerator::postvisit( DirectiveStmt * dirStmt ) {
-		output << endl << dirStmt->directive;			// endl prevents spaces before directive
-	}
-
-	void CodeGenerator::postvisit( IfStmt * ifStmt ) {
-		output << "if ( ";
-		ifStmt->get_condition()->accept( *visitor );
-		output << " ) ";
-
-		ifStmt->get_then()->accept( *visitor );
-
-		if ( ifStmt->get_else() != 0) {
-			output << " else ";
-			ifStmt->get_else()->accept( *visitor );
-		} // if
-	}
-
-	void CodeGenerator::postvisit( SwitchStmt * switchStmt ) {
-		output << "switch ( ";
-		switchStmt->get_condition()->accept( *visitor );
-		output << " ) ";
-
-		output << "{" << endl;
-		++indent;
-		acceptAll( switchStmt->get_statements(), *visitor );
-		--indent;
-		output << indent << "}";
-	}
-
-	void CodeGenerator::postvisit( CaseStmt * caseStmt ) {
-		updateLocation( caseStmt );
-		output << indent;
-		if ( caseStmt->isDefault()) {
-			output << "default";
-		} else {
-			output << "case ";
-			caseStmt->get_condition()->accept( *visitor );
-		} // if
-		output << ":" << endl;
-
-		std::list<Statement *> sts = caseStmt->get_statements();
-
-		++indent;
-		for ( std::list<Statement *>::iterator i = sts.begin(); i != sts.end();  i++) {
-			output << indent << printLabels( (*i)->get_labels() ) ;
-			(*i)->accept( *visitor );
-			output << endl;
-		} // for
-		--indent;
-	}
-
-	void CodeGenerator::postvisit( BranchStmt * branchStmt ) {
-		switch ( branchStmt->get_type()) {
-		  case BranchStmt::Goto:
-			if ( ! branchStmt->get_target().empty() )
-				output << "goto " << branchStmt->get_target();
-			else {
-				if ( branchStmt->get_computedTarget() != 0 ) {
-					output << "goto *";
-					branchStmt->get_computedTarget()->accept( *visitor );
-				} // if
-			} // if
-			break;
-		  case BranchStmt::Break:
-			output << "break";
-			break;
-		  case BranchStmt::Continue:
-			output << "continue";
-			break;
-		  case BranchStmt::FallThrough:
-		  case BranchStmt::FallThroughDefault:
-			assertf( ! options.genC, "fallthru should not reach code generation." );
-			output << "fallthru";
-			break;
-		  default: ;									// prevent warning
-		} // switch
-		// print branch target for labelled break/continue/fallthru in debug mode
-		if ( ! options.genC && branchStmt->get_type() != BranchStmt::Goto ) {
-			if ( ! branchStmt->get_target().empty() ) {
-				output << " " << branchStmt->get_target();
-			} else if ( branchStmt->get_type() == BranchStmt::FallThrough ) {
-				output << " default";
-			}
-		}
-		output << ";";
-	}
-
-	void CodeGenerator::postvisit( ReturnStmt * returnStmt ) {
-		output << "return ";
-		maybeAccept( returnStmt->get_expr(), *visitor );
-		output << ";";
-	}
-
-	void CodeGenerator::postvisit( ThrowStmt * throwStmt ) {
-		assertf( ! options.genC, "Throw statements should not reach code generation." );
-
-		output << ((throwStmt->get_kind() == ThrowStmt::Terminate) ?
-				   "throw" : "throwResume");
-		if (throwStmt->get_expr()) {
-			output << " ";
-			throwStmt->get_expr()->accept( *visitor );
-		}
-		if (throwStmt->get_target()) {
-			output << " _At ";
-			throwStmt->get_target()->accept( *visitor );
-		}
-		output << ";";
-	}
-	void CodeGenerator::postvisit( CatchStmt * stmt ) {
-		assertf( ! options.genC, "Catch statements should not reach code generation." );
-
-		output << ((stmt->get_kind() == CatchStmt::Terminate) ?
-				   "catch" : "catchResume");
-		output << "( ";
-		stmt->decl->accept( *visitor );
-		output << " ) ";
-
-		if( stmt->cond ) {
-			output << "if/when(?) (";
-			stmt->cond->accept( *visitor );
-			output << ") ";
-		}
-		stmt->body->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( WaitForStmt * stmt ) {
-		assertf( ! options.genC, "Waitfor statements should not reach code generation." );
-
-		bool first = true;
-		for( auto & clause : stmt->clauses ) {
-			if(first) { output << "or "; first = false; }
-			if( clause.condition ) {
-				output << "when(";
-				stmt->timeout.condition->accept( *visitor );
-				output << ") ";
-			}
-			output << "waitfor(";
-			clause.target.function->accept( *visitor );
-			for( Expression * expr : clause.target.arguments ) {
-				output << ",";
-				expr->accept( *visitor );
-			}
-			output << ") ";
-			clause.statement->accept( *visitor );
-		}
-
-		if( stmt->timeout.statement ) {
-			output << "or ";
-			if( stmt->timeout.condition ) {
-				output << "when(";
-				stmt->timeout.condition->accept( *visitor );
-				output << ") ";
-			}
-			output << "timeout(";
-			stmt->timeout.time->accept( *visitor );
-			output << ") ";
-			stmt->timeout.statement->accept( *visitor );
-		}
-
-		if( stmt->orelse.statement ) {
-			output << "or ";
-			if( stmt->orelse.condition ) {
-				output << "when(";
-				stmt->orelse.condition->accept( *visitor );
-				output << ")";
-			}
-			output << "else ";
-			stmt->orelse.statement->accept( *visitor );
-		}
-	}
-
-	void CodeGenerator::postvisit( WithStmt * with ) {
-		assertf( ! options.genC, "WithStmts should not reach code generation." );
-
-		output << "with ( ";
-		genCommaList( with->exprs.begin(), with->exprs.end() );
-		output << " ) ";
-		with->stmt->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( WhileDoStmt * whileDoStmt ) {
-		if ( whileDoStmt->get_isDoWhile() ) {
-			output << "do";
-		} else {
-			output << "while (";
-			whileDoStmt->get_condition()->accept( *visitor );
-			output << ")";
-		} // if
-		output << " ";
-
-		output << CodeGenerator::printLabels( whileDoStmt->get_body()->get_labels() );
-		whileDoStmt->get_body()->accept( *visitor );
-
-		output << indent;
-
-		if ( whileDoStmt->get_isDoWhile() ) {
-			output << " while (";
-			whileDoStmt->get_condition()->accept( *visitor );
-			output << ");";
-		} // if
-	}
-
-	void CodeGenerator::postvisit( ForStmt * forStmt ) {
-		// initialization is always hoisted, so don't bother doing anything with that
-		output << "for (;";
-
-		if ( forStmt->get_condition() != 0 ) {
-			forStmt->get_condition()->accept( *visitor );
-		} // if
-		output << ";";
-
-		if ( forStmt->get_increment() != 0 ) {
-			// cast the top-level expression to void to reduce gcc warnings.
-			Expression * expr = new CastExpr( forStmt->get_increment() );
-			expr->accept( *visitor );
-		} // if
-		output << ") ";
-
-		if ( forStmt->get_body() != 0 ) {
-			output << CodeGenerator::printLabels( forStmt->get_body()->get_labels() );
-			forStmt->get_body()->accept( *visitor );
-		} // if
-	}
-
-	void CodeGenerator::postvisit( __attribute__((unused)) NullStmt * nullStmt ) {
-		//output << indent << CodeGenerator::printLabels( nullStmt->get_labels() );
-		output << "/* null statement */ ;";
-	}
-
-	void CodeGenerator::postvisit( DeclStmt * declStmt ) {
-		declStmt->get_decl()->accept( *visitor );
-
-		if ( doSemicolon( declStmt->get_decl() ) ) {
-			output << ";";
-		} // if
-	}
-
-	void CodeGenerator::postvisit( ImplicitCtorDtorStmt * stmt ) {
-		assertf( ! options.genC, "ImplicitCtorDtorStmts should not reach code generation." );
-		stmt->callStmt->accept( *visitor );
-	}
-
-	void CodeGenerator::postvisit( MutexStmt * stmt ) {
-		assertf( ! options.genC, "ImplicitCtorDtorStmts should not reach code generation." );
-		stmt->stmt->accept( *visitor );
-	}
-
-	void CodeGenerator::handleStorageClass( DeclarationWithType * decl ) {
-		if ( decl->get_storageClasses().any() ) {
-			decl->get_storageClasses().print( output );
-		} // if
-	} // CodeGenerator::handleStorageClass
-
-	std::string genName( DeclarationWithType * decl ) {
-		const OperatorInfo * opInfo = operatorLookup( decl->get_name() );
-		if ( opInfo ) {
-			return opInfo->outputName;
-		} else {
-			return decl->get_name();
-		} // if
-	}
-
-} // namespace CodeGen
-
-// Local Variables: //
-// tab-width: 4 //
-// mode: c++ //
-// compile-command: "make install" //
-// End: //
Index: src/CodeGen/CodeGenerator.h
===================================================================
--- src/CodeGen/CodeGenerator.h	(revision 934fa0fc6af3737f7f5b45e08f4b84e1e8259312)
+++ 	(revision )
@@ -1,198 +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.
-//
-// CodeGenerator.h --
-//
-// Author           : Richard C. Bilson
-// Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Andrew Beach
-// Last Modified On : Wed Jun 29 14:32:00 2022
-// Update Count     : 65
-//
-
-#pragma once
-
-#include <list>                   // for list
-#include <ostream>                // for ostream, operator<<
-#include <string>                 // for string
-
-#include "CodeGen/Options.h"      // for Options
-#include "Common/Indenter.h"      // for Indenter
-#include "Common/PassVisitor.h"   // for PassVisitor
-#include "SynTree/Declaration.h"  // for DeclarationWithType (ptr only), Fun...
-#include "SynTree/Visitor.h"      // for Visitor
-#include "SynTree/SynTree.h"      // for Visitor Nodes
-
-namespace ast {
-	class DeclWithType;
-}
-
-namespace CodeGen {
-	struct CodeGenerator : public WithShortCircuiting, public WithGuards, public WithVisitorRef<CodeGenerator> {
-		static int tabsize;
-
-		CodeGenerator( std::ostream &os, bool pretty = false, bool genC = false, bool lineMarks = false, bool printExprTypes = false );
-		CodeGenerator( std::ostream &os, const Options &options );
-
-		//*** Turn off visit_children for all nodes
-		void previsit( BaseSyntaxNode * );
-
-		//*** Error for unhandled node types
-		void postvisit( BaseSyntaxNode * );
-
-		//*** print type for all expressions
-		void previsit( Expression * node );
-
-		//*** Declaration
-		void postvisit( StructDecl * );
-		void postvisit( FunctionDecl * );
-		void postvisit( ObjectDecl * );
-		void postvisit( UnionDecl * aggregateDecl );
-		void postvisit( EnumDecl * aggregateDecl );
-		void postvisit( TraitDecl * aggregateDecl );
-		void postvisit( TypedefDecl * typeDecl );
-		void postvisit( TypeDecl * typeDecl );
-		void postvisit( StaticAssertDecl * assertDecl );
-
-		//*** Initializer
-		void postvisit( Designation * );
-		void postvisit( SingleInit * );
-		void postvisit( ListInit * );
-		void postvisit( ConstructorInit * );
-
-		//*** Constant
-		void postvisit( Constant * );
-
-		//*** Expression
-		void postvisit( ApplicationExpr *applicationExpr );
-		void postvisit( UntypedExpr *untypedExpr );
-		void postvisit( RangeExpr * rangeExpr );
-		void postvisit( NameExpr *nameExpr );
-		void postvisit( AddressExpr *addressExpr );
-		void postvisit( LabelAddressExpr *addressExpr );
-		void postvisit( CastExpr *castExpr );
-		void postvisit( KeywordCastExpr * castExpr );
-		void postvisit( VirtualCastExpr *castExpr );
-		void postvisit( UntypedMemberExpr *memberExpr );
-		void postvisit( MemberExpr *memberExpr );
-		void postvisit( VariableExpr *variableExpr );
-		void postvisit( ConstantExpr *constantExpr );
-		void postvisit( SizeofExpr *sizeofExpr );
-		void postvisit( AlignofExpr *alignofExpr );
-		void postvisit( UntypedOffsetofExpr *offsetofExpr );
-		void postvisit( OffsetofExpr *offsetofExpr );
-		void postvisit( OffsetPackExpr *offsetPackExpr );
-		void postvisit( LogicalExpr *logicalExpr );
-		void postvisit( ConditionalExpr *conditionalExpr );
-		void postvisit( CommaExpr *commaExpr );
-		void postvisit( CompoundLiteralExpr *compLitExpr );
-		void postvisit( UniqueExpr * );
-		void postvisit( TupleAssignExpr * tupleExpr );
-		void postvisit( UntypedTupleExpr *tupleExpr );
-		void postvisit( TupleExpr *tupleExpr );
-		void postvisit( TupleIndexExpr * tupleExpr );
-		void postvisit( TypeExpr *typeExpr );
-		void postvisit( DimensionExpr *dimensionExpr );
-		void postvisit( AsmExpr * );
-		void postvisit( StmtExpr * );
-		void postvisit( ConstructorExpr * );
-		void postvisit( DeletedExpr * );
-		void postvisit( DefaultArgExpr * );
-		void postvisit( GenericExpr * );
-
-		//*** Statements
-		void postvisit( CompoundStmt * );
-		void postvisit( ExprStmt * );
-		void postvisit( AsmStmt * );
-		void postvisit( DirectiveStmt * );
-		void postvisit( AsmDecl * );					// special: statement in declaration context
-		void postvisit( DirectiveDecl * );				// special: statement in declaration context
-		void postvisit( IfStmt * );
-		void postvisit( SwitchStmt * );
-		void postvisit( CaseStmt * );
-		void postvisit( BranchStmt * );
-		void postvisit( ReturnStmt * );
-		void postvisit( ThrowStmt * );
-		void postvisit( CatchStmt * );
-		void postvisit( WaitForStmt * );
-		void postvisit( WithStmt * );
-		void postvisit( WhileDoStmt * );
-		void postvisit( ForStmt * );
-		void postvisit( NullStmt * );
-		void postvisit( DeclStmt * );
-		void postvisit( ImplicitCtorDtorStmt * );
-		void postvisit( MutexStmt * stmt );
-
-		void genAttributes( std::list< Attribute * > & attributes );
-
-		template< class Iterator > void genCommaList( Iterator begin, Iterator end );
-
-		struct LabelPrinter {
-			LabelPrinter(CodeGenerator &cg) : cg(cg), labels( 0 ) {}
-			LabelPrinter & operator()( std::list< Label > & l );
-			CodeGenerator & cg;
-			std::list< Label > * labels;
-		};
-
-		void asmName( DeclarationWithType *decl );
-
-		void extension( Expression *expr );
-		void extension( Declaration *decl );
-
-		void updateLocation( BaseSyntaxNode const * to );
-		struct LineEnder {
-			CodeGenerator & cg;
-			LineEnder( CodeGenerator & cg ) : cg( cg ) {}
-			std::ostream & operator()(std::ostream &) const;
-		};
-	  private:
-		Indenter indent;
-		std::ostream & output;
-		LabelPrinter printLabels;
-		Options options;
-	  public:
-		LineEnder endl;
-	  private:
-
-		CodeLocation currentLocation;
-		void updateLocation( CodeLocation const & to );
-
-		void handleStorageClass( DeclarationWithType *decl );
-		void handleAggregate( AggregateDecl *aggDecl, const std::string & kind );
-		void handleTypedef( NamedTypeDecl *namedType );
-		std::string mangleName( DeclarationWithType * decl );
-	}; // CodeGenerator
-
-	template< class Iterator >
-	void CodeGenerator::genCommaList( Iterator begin, Iterator end ) {
-		if ( begin == end ) return;
-		for ( ;; ) {
-			(*begin++)->accept( *visitor );
-			if ( begin == end ) break;
-			output << ", ";								// separator
-		} // for
-	} // genCommaList
-
-	inline bool doSemicolon( Declaration* decl ) {
-		if ( FunctionDecl* func = dynamic_cast< FunctionDecl* >( decl ) ) {
-			return ! func->get_statements();
-		} // if
-		return true;
-	} // doSemicolon
-
-	/// returns C-compatible name of declaration
-	std::string genName( DeclarationWithType * decl );
-
-	inline std::ostream & operator<<( std::ostream & os, const CodeGenerator::LineEnder & endl ) {
-		return endl( os );
-	}
-} // namespace CodeGen
-
-// Local Variables: //
-// tab-width: 4 //
-// mode: c++ //
-// compile-command: "make install" //
-// End: //
Index: src/CodeGen/FixMain.cc
===================================================================
--- src/CodeGen/FixMain.cc	(revision 934fa0fc6af3737f7f5b45e08f4b84e1e8259312)
+++ src/CodeGen/FixMain.cc	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -25,9 +25,6 @@
 #include "AST/Type.hpp"
 #include "AST/Vector.hpp"
-#include "Common/PassVisitor.h"
 #include "Common/SemanticError.h"  // for SemanticError
 #include "CodeGen/GenType.h"       // for GenType
-#include "SynTree/Declaration.h"   // for FunctionDecl, operator<<
-#include "SynTree/Type.h"          // for FunctionType
 #include "SymTab/Mangler.h"
 
@@ -35,17 +32,4 @@
 
 namespace {
-
-struct FindMainCore {
-	FunctionDecl * main_signature = nullptr;
-
-	void previsit( FunctionDecl * decl ) {
-		if ( FixMain::isMain( decl ) ) {
-			if ( main_signature ) {
-				SemanticError( decl, "Multiple definition of main routine\n" );
-			}
-			main_signature = decl;
-		}
-	}
-};
 
 struct FindMainCore_new {
@@ -65,39 +49,4 @@
 	return genType( types[at], "", Options( false, false, false, false ) );
 }
-
-}
-
-	template<typename container>
-	std::string genTypeAt(const container& p, size_t idx) {
-		return genType((*std::next(p.begin(), idx))->get_type(), "");
-	}
-
-	void FixMain::fix( std::list< Declaration * > & translationUnit,
-			std::ostream &os, const char* bootloader_filename ) {
-		PassVisitor< FindMainCore > main_finder;
-		acceptAll( translationUnit, main_finder );
-		FunctionDecl * main_signature = main_finder.pass.main_signature;
-
-		if( main_signature ) {
-			os << "static inline int invoke_main(int argc, char* argv[], char* envp[]) { (void)argc; (void)argv; (void)envp; return ";
-			main_signature->mangleName = SymTab::Mangler::mangle(main_signature);
-
-			os << main_signature->get_scopedMangleName() << "(";
-			const auto& params = main_signature->get_functionType()->get_parameters();
-			switch(params.size()) {
-				case 3: os << "(" << genTypeAt(params, 0) << ")argc, (" << genTypeAt(params, 1) << ")argv, (" << genTypeAt(params, 2) << ")envp"; break;
-				case 2: os << "(" << genTypeAt(params, 0) << ")argc, (" << genTypeAt(params, 1) << ")argv"; break;
-				case 0: break;
-				default : assert(false);
-			}
-			os << "); }\n";
-
-			std::ifstream bootloader(bootloader_filename, std::ios::in);
-			assertf( bootloader.is_open(), "cannot open bootloader.c\n" );
-			os << bootloader.rdbuf();
-		}
-	}
-
-namespace {
 
 ast::ObjectDecl * makeIntObj(){
@@ -159,11 +108,4 @@
 } // namespace
 
-bool FixMain::isMain( FunctionDecl * decl ) {
-	if ( std::string("main") != decl->name ) {
-		return false;
-	}
-	return is_main( SymTab::Mangler::mangle( decl, true, true ) );
-}
-
 bool FixMain::isMain( const ast::FunctionDecl * decl ) {
 	if ( std::string("main") != decl->name ) {
Index: src/CodeGen/FixMain.h
===================================================================
--- src/CodeGen/FixMain.h	(revision 934fa0fc6af3737f7f5b45e08f4b84e1e8259312)
+++ src/CodeGen/FixMain.h	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -21,8 +21,5 @@
 
 #include "AST/LinkageSpec.hpp"
-#include "SynTree/LinkageSpec.h"
 
-class Declaration;
-class FunctionDecl;
 namespace ast {
 	class FunctionDecl;
@@ -34,7 +31,4 @@
 class FixMain {
 public :
-	static inline LinkageSpec::Spec mainLinkage() {
-		return replace_main ? LinkageSpec::Cforall : LinkageSpec::C;
-	}
 	static inline ast::Linkage::Spec getMainLinkage() {
 		return replace_main ? ast::Linkage::Cforall : ast::Linkage::C;
@@ -45,9 +39,6 @@
 	}
 
-	static bool isMain(FunctionDecl* decl);
 	static bool isMain(const ast::FunctionDecl * decl);
 
-	static void fix( std::list< Declaration * > & decls,
-			std::ostream &os, const char* bootloader_filename );
 	static void fix( ast::TranslationUnit & translationUnit,
 			std::ostream &os, const char * bootloader_filename );
Index: src/CodeGen/FixNames.cc
===================================================================
--- src/CodeGen/FixNames.cc	(revision 934fa0fc6af3737f7f5b45e08f4b84e1e8259312)
+++ src/CodeGen/FixNames.cc	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -22,68 +22,10 @@
 #include "AST/Expr.hpp"
 #include "AST/Pass.hpp"
-#include "Common/PassVisitor.h"
 #include "Common/SemanticError.h"  // for SemanticError
 #include "FixMain.h"               // for FixMain
 #include "SymTab/Mangler.h"        // for Mangler
-#include "SynTree/LinkageSpec.h"   // for Cforall, isMangled
-#include "SynTree/Constant.h"      // for Constant
-#include "SynTree/Declaration.h"   // for FunctionDecl, ObjectDecl, Declarat...
-#include "SynTree/Expression.h"    // for ConstantExpr
-#include "SynTree/Label.h"         // for Label, noLabels
-#include "SynTree/Statement.h"     // for ReturnStmt, CompoundStmt
-#include "SynTree/Type.h"          // for Type, BasicType, Type::Qualifiers
-#include "SynTree/Visitor.h"       // for Visitor, acceptAll
 #include "CompilationState.h"
 
 namespace CodeGen {
-	class FixNames : public WithGuards {
-	  public:
-		void postvisit( ObjectDecl *objectDecl );
-		void postvisit( FunctionDecl *functionDecl );
-
-		void previsit( CompoundStmt *compoundStmt );
-	  private:
-		int scopeLevel = 1;
-
-		void fixDWT( DeclarationWithType *dwt );
-	};
-
-	void fixNames( std::list< Declaration* > & translationUnit ) {
-		PassVisitor<FixNames> fixer;
-		acceptAll( translationUnit, fixer );
-	}
-
-	void FixNames::fixDWT( DeclarationWithType * dwt ) {
-		if ( dwt->get_name() != "" ) {
-			if ( LinkageSpec::isMangled( dwt->get_linkage() ) ) {
-				if (!useNewAST) {
-					dwt->set_mangleName( SymTab::Mangler::mangle( dwt ) );
-				}
-				dwt->set_scopeLevel( scopeLevel );
-			} // if
-		} // if
-	}
-
-	void FixNames::postvisit( ObjectDecl * objectDecl ) {
-		fixDWT( objectDecl );
-	}
-
-	void FixNames::postvisit( FunctionDecl * functionDecl ) {
-		fixDWT( functionDecl );
-
-		if ( FixMain::isMain( functionDecl ) ) {
-			int nargs = functionDecl->get_functionType()->get_parameters().size();
-			if( !(nargs == 0 || nargs == 2 || nargs == 3) ) {
-				SemanticError(functionDecl, "Main expected to have 0, 2 or 3 arguments\n");
-			}
-			functionDecl->get_statements()->get_kids().push_back( new ReturnStmt( new ConstantExpr( Constant::from_int( 0 ) ) ) );
-		}
-	}
-
-	void FixNames::previsit( CompoundStmt * ) {
-		scopeLevel++;
-		GuardAction( [this](){ scopeLevel--; } );
-	}
-
 /// Does work with the main function and scopeLevels.
 class FixNames_new final {
Index: src/CodeGen/GenType.cc
===================================================================
--- src/CodeGen/GenType.cc	(revision 934fa0fc6af3737f7f5b45e08f4b84e1e8259312)
+++ src/CodeGen/GenType.cc	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -21,339 +21,8 @@
 #include "AST/Print.hpp"          // for print
 #include "AST/Vector.hpp"         // for vector
-#include "CodeGenerator.h"        // for CodeGenerator
 #include "CodeGeneratorNew.hpp"   // for CodeGenerator_new
 #include "Common/UniqueName.h"    // for UniqueName
-#include "SynTree/Declaration.h"  // for DeclarationWithType
-#include "SynTree/Expression.h"   // for Expression
-#include "SynTree/Type.h"         // for PointerType, Type, FunctionType
-#include "SynTree/Visitor.h"      // for Visitor
 
 namespace CodeGen {
-	struct GenType : public WithVisitorRef<GenType>, public WithShortCircuiting {
-		std::string typeString;
-		GenType( const std::string &typeString, const Options &options );
-
-		void previsit( BaseSyntaxNode * );
-		void postvisit( BaseSyntaxNode * );
-
-		void postvisit( FunctionType * funcType );
-		void postvisit( VoidType * voidType );
-		void postvisit( BasicType * basicType );
-		void postvisit( PointerType * pointerType );
-		void postvisit( ArrayType * arrayType );
-		void postvisit( ReferenceType * refType );
-		void postvisit( StructInstType * structInst );
-		void postvisit( UnionInstType * unionInst );
-		void postvisit( EnumInstType * enumInst );
-		void postvisit( TypeInstType * typeInst );
-		void postvisit( TupleType  * tupleType );
-		void postvisit( VarArgsType * varArgsType );
-		void postvisit( ZeroType * zeroType );
-		void postvisit( OneType * oneType );
-		void postvisit( GlobalScopeType * globalType );
-		void postvisit( TraitInstType * inst );
-		void postvisit( TypeofType * typeof );
-		void postvisit( VTableType * vtable );
-		void postvisit( QualifiedType * qualType );
-
-	  private:
-		void handleQualifiers( Type *type );
-		std::string handleGeneric( ReferenceToType * refType );
-		void genArray( const Type::Qualifiers &qualifiers, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
-
-		Options options;
-	};
-
-	std::string genType( Type *type, const std::string &baseString, const Options &options ) {
-		PassVisitor<GenType> gt( baseString, options );
-		std::ostringstream os;
-
-		if ( ! type->get_attributes().empty() ) {
-			PassVisitor<CodeGenerator> cg( os, options );
-			cg.pass.genAttributes( type->get_attributes() );
-		} // if
-
-		type->accept( gt );
-		return os.str() + gt.pass.typeString;
-	}
-
-	std::string genType( Type *type, const std::string &baseString, bool pretty, bool genC , bool lineMarks ) {
-		return genType( type, baseString, Options(pretty, genC, lineMarks, false ) );
-	}
-
-	std::string genPrettyType( Type * type, const std::string & baseString ) {
-		return genType( type, baseString, true, false );
-	}
-
-	GenType::GenType( const std::string &typeString, const Options &options ) : typeString( typeString ), options( options ) {}
-
-	// *** BaseSyntaxNode
-	void GenType::previsit( BaseSyntaxNode * ) {
-		// turn off automatic recursion for all nodes, to allow each visitor to
-		// precisely control the order in which its children are visited.
-		visit_children = false;
-	}
-
-	void GenType::postvisit( BaseSyntaxNode * node ) {
-		std::stringstream ss;
-		node->print( ss );
-		assertf( false, "Unhandled node reached in GenType: %s", ss.str().c_str() );
-	}
-
-	void GenType::postvisit( VoidType * voidType ) {
-		typeString = "void " + typeString;
-		handleQualifiers( voidType );
-	}
-
-	void GenType::postvisit( BasicType * basicType ) {
-		BasicType::Kind kind = basicType->kind;
-		assert( 0 <= kind && kind < BasicType::NUMBER_OF_BASIC_TYPES );
-		typeString = std::string( BasicType::typeNames[kind] ) + " " + typeString;
-		handleQualifiers( basicType );
-	}
-
-	void GenType::genArray( const Type::Qualifiers & qualifiers, Type * base, Expression *dimension, bool isVarLen, bool isStatic ) {
-		std::ostringstream os;
-		if ( typeString != "" ) {
-			if ( typeString[ 0 ] == '*' ) {
-				os << "(" << typeString << ")";
-			} else {
-				os << typeString;
-			} // if
-		} // if
-		os << "[";
-
-		if ( isStatic ) {
-			os << "static ";
-		} // if
-		if ( qualifiers.is_const ) {
-			os << "const ";
-		} // if
-		if ( qualifiers.is_volatile ) {
-			os << "volatile ";
-		} // if
-		if ( qualifiers.is_restrict ) {
-			os << "__restrict ";
-		} // if
-		if ( qualifiers.is_atomic ) {
-			os << "_Atomic ";
-		} // if
-		if ( dimension != 0 ) {
-			PassVisitor<CodeGenerator> cg( os, options );
-			dimension->accept( cg );
-		} else if ( isVarLen ) {
-			// no dimension expression on a VLA means it came in with the * token
-			os << "*";
-		} // if
-		os << "]";
-
-		typeString = os.str();
-
-		base->accept( *visitor );
-	}
-
-	void GenType::postvisit( PointerType * pointerType ) {
-		assert( pointerType->base != 0);
-		if ( pointerType->get_isStatic() || pointerType->get_isVarLen() || pointerType->dimension ) {
-			genArray( pointerType->get_qualifiers(), pointerType->base, pointerType->dimension, pointerType->get_isVarLen(), pointerType->get_isStatic() );
-		} else {
-			handleQualifiers( pointerType );
-			if ( typeString[ 0 ] == '?' ) {
-				typeString = "* " + typeString;
-			} else {
-				typeString = "*" + typeString;
-			} // if
-			pointerType->base->accept( *visitor );
-		} // if
-	}
-
-	void GenType::postvisit( ArrayType * arrayType ) {
-		genArray( arrayType->get_qualifiers(), arrayType->base, arrayType->dimension, arrayType->get_isVarLen(), arrayType->get_isStatic() );
-	}
-
-	void GenType::postvisit( ReferenceType * refType ) {
-		assert( 0 != refType->base );
-		assertf( ! options.genC, "Reference types should not reach code generation." );
-		handleQualifiers( refType );
-		typeString = "&" + typeString;
-		refType->base->accept( *visitor );
-	}
-
-	void GenType::postvisit( FunctionType * funcType ) {
-		std::ostringstream os;
-
-		if ( typeString != "" ) {
-			if ( typeString[ 0 ] == '*' ) {
-				os << "(" << typeString << ")";
-			} else {
-				os << typeString;
-			} // if
-		} // if
-
-		/************* parameters ***************/
-
-		const std::list<DeclarationWithType *> &pars = funcType->parameters;
-
-		if ( pars.empty() ) {
-			if ( funcType->get_isVarArgs() ) {
-				os << "()";
-			} else {
-				os << "(void)";
-			} // if
-		} else {
-			PassVisitor<CodeGenerator> cg( os, options );
-			os << "(" ;
-
-			cg.pass.genCommaList( pars.begin(), pars.end() );
-
-			if ( funcType->get_isVarArgs() ) {
-				os << ", ...";
-			} // if
-			os << ")";
-		} // if
-
-		typeString = os.str();
-
-		if ( funcType->returnVals.size() == 0 ) {
-			typeString = "void " + typeString;
-		} else {
-			funcType->returnVals.front()->get_type()->accept( *visitor );
-		} // if
-
-		// add forall
-		if( ! funcType->forall.empty() && ! options.genC ) {
-			// assertf( ! genC, "Aggregate type parameters should not reach code generation." );
-			std::ostringstream os;
-			PassVisitor<CodeGenerator> cg( os, options );
-			os << "forall(";
-			cg.pass.genCommaList( funcType->forall.begin(), funcType->forall.end() );
-			os << ")" << std::endl;
-			typeString = os.str() + typeString;
-		}
-	}
-
-	std::string GenType::handleGeneric( ReferenceToType * refType ) {
-		if ( ! refType->parameters.empty() ) {
-			std::ostringstream os;
-			PassVisitor<CodeGenerator> cg( os, options );
-			os << "(";
-			cg.pass.genCommaList( refType->parameters.begin(), refType->parameters.end() );
-			os << ") ";
-			return os.str();
-		}
-		return "";
-	}
-
-	void GenType::postvisit( StructInstType * structInst )  {
-		typeString = structInst->name + handleGeneric( structInst ) + " " + typeString;
-		if ( options.genC ) typeString = "struct " + typeString;
-		handleQualifiers( structInst );
-	}
-
-	void GenType::postvisit( UnionInstType * unionInst ) {
-		typeString = unionInst->name + handleGeneric( unionInst ) + " " + typeString;
-		if ( options.genC ) typeString = "union " + typeString;
-		handleQualifiers( unionInst );
-	}
-
-	void GenType::postvisit( EnumInstType * enumInst ) {
-		if ( enumInst->baseEnum && enumInst->baseEnum->base ) {
-			typeString = genType(enumInst->baseEnum->base, typeString, options);
-		} else {
-			typeString = enumInst->name + " " + typeString;
-			if ( options.genC ) {
-				typeString = "enum " + typeString;
-			}
-		}
-		handleQualifiers( enumInst );
-	}
-
-	void GenType::postvisit( TypeInstType * typeInst ) {
-		assertf( ! options.genC, "Type instance types should not reach code generation." );
-		typeString = typeInst->name + " " + typeString;
-		handleQualifiers( typeInst );
-	}
-
-	void GenType::postvisit( TupleType * tupleType ) {
-		assertf( ! options.genC, "Tuple types should not reach code generation." );
-		unsigned int i = 0;
-		std::ostringstream os;
-		os << "[";
-		for ( Type * t : *tupleType ) {
-			i++;
-			os << genType( t, "", options ) << (i == tupleType->size() ? "" : ", ");
-		}
-		os << "] ";
-		typeString = os.str() + typeString;
-	}
-
-	void GenType::postvisit( VarArgsType * varArgsType ) {
-		typeString = "__builtin_va_list " + typeString;
-		handleQualifiers( varArgsType );
-	}
-
-	void GenType::postvisit( ZeroType * zeroType ) {
-		// ideally these wouldn't hit codegen at all, but should be safe to make them ints
-		typeString = (options.pretty ? "zero_t " : "long int ") + typeString;
-		handleQualifiers( zeroType );
-	}
-
-	void GenType::postvisit( OneType * oneType ) {
-		// ideally these wouldn't hit codegen at all, but should be safe to make them ints
-		typeString = (options.pretty ? "one_t " : "long int ") + typeString;
-		handleQualifiers( oneType );
-	}
-
-	void GenType::postvisit( GlobalScopeType * globalType ) {
-		assertf( ! options.genC, "Global scope type should not reach code generation." );
-		handleQualifiers( globalType );
-	}
-
-	void GenType::postvisit( TraitInstType * inst ) {
-		assertf( ! options.genC, "Trait types should not reach code generation." );
-		typeString = inst->name + " " + typeString;
-		handleQualifiers( inst );
-	}
-
-	void GenType::postvisit( TypeofType * typeof ) {
-		std::ostringstream os;
-		PassVisitor<CodeGenerator> cg( os, options );
-		os << "typeof(";
-		typeof->expr->accept( cg );
-		os << ") " << typeString;
-		typeString = os.str();
-		handleQualifiers( typeof );
-	}
-
-	void GenType::postvisit( VTableType * vtable ) {
-		assertf( ! options.genC, "Virtual table types should not reach code generation." );
-		std::ostringstream os;
-		os << "vtable(" << genType( vtable->base, "", options ) << ") " << typeString;
-		typeString = os.str();
-		handleQualifiers( vtable );
-	}
-
-	void GenType::postvisit( QualifiedType * qualType ) {
-		assertf( ! options.genC, "Qualified types should not reach code generation." );
-		std::ostringstream os;
-		os << genType( qualType->parent, "", options ) << "." << genType( qualType->child, "", options ) << typeString;
-		typeString = os.str();
-		handleQualifiers( qualType );
-	}
-
-	void GenType::handleQualifiers( Type * type ) {
-		if ( type->get_const() ) {
-			typeString = "const " + typeString;
-		} // if
-		if ( type->get_volatile() ) {
-			typeString = "volatile " + typeString;
-		} // if
-		if ( type->get_restrict() ) {
-			typeString = "__restrict " + typeString;
-		} // if
-		if ( type->get_atomic() ) {
-			typeString = "_Atomic " + typeString;
-		} // if
-	}
 
 namespace {
Index: src/CodeGen/Generate.cc
===================================================================
--- src/CodeGen/Generate.cc	(revision 934fa0fc6af3737f7f5b45e08f4b84e1e8259312)
+++ src/CodeGen/Generate.cc	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -20,78 +20,9 @@
 
 #include "CodeGeneratorNew.hpp"      // for CodeGenerator_new, doSemicolon, ...
-#include "CodeGenerator.h"           // for CodeGenerator, doSemicolon, oper...
 #include "GenType.h"                 // for genPrettyType
-#include "Common/PassVisitor.h"      // for PassVisitor
-#include "SynTree/LinkageSpec.h"     // for isBuiltin, isGeneratable
-#include "SynTree/BaseSyntaxNode.h"  // for BaseSyntaxNode
-#include "SynTree/Declaration.h"     // for Declaration
-#include "SynTree/Type.h"            // for Type
 
 using namespace std;
 
 namespace CodeGen {
-	namespace {
-		/// Removes misc. nodes that should not exist in CodeGen
-		struct TreeCleaner {
-			void premutate( CompoundStmt * stmt );
-			Statement * postmutate( ImplicitCtorDtorStmt * stmt );
-
-			static bool shouldClean( Declaration * );
-		};
-
-		void cleanTree( std::list< Declaration * > & translationUnit ) {
-			PassVisitor<TreeCleaner> cleaner;
-			filter( translationUnit, [](Declaration * decl) { return TreeCleaner::shouldClean(decl); }, false );
-			mutateAll( translationUnit, cleaner );
-		} // cleanTree
-	} // namespace
-
-	void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC, bool lineMarks, bool printExprTypes ) {
-		cleanTree( translationUnit );
-
-		PassVisitor<CodeGenerator> cgv( os, pretty, generateC, lineMarks, printExprTypes );
-		for ( auto & dcl : translationUnit ) {
-			if ( LinkageSpec::isGeneratable( dcl->get_linkage() ) && (doIntrinsics || ! LinkageSpec::isBuiltin( dcl->get_linkage() ) ) ) {
-				cgv.pass.updateLocation( dcl );
-				dcl->accept(cgv);
-				if ( doSemicolon( dcl ) ) {
-					os << ";";
-				} // if
-				os << cgv.pass.endl;
-			} // if
-		} // for
-	}
-
-	void generate( BaseSyntaxNode * node, std::ostream & os ) {
-		if ( Type * type = dynamic_cast< Type * >( node ) ) {
-			os << genPrettyType( type, "" );
-		} else {
-			PassVisitor<CodeGenerator> cgv( os, true, false, false, false );
-			node->accept( cgv );
-		}
-		os << std::endl;
-	}
-
-	namespace {
-		void TreeCleaner::premutate( CompoundStmt * cstmt ) {
-			filter( cstmt->kids, [](Statement * stmt) {
-				if ( DeclStmt * declStmt = dynamic_cast< DeclStmt * >( stmt ) ) {
-					return shouldClean( declStmt->decl );
-				}
-				return false;
-			}, false );
-		}
-
-		Statement * TreeCleaner::postmutate( ImplicitCtorDtorStmt * stmt ) {
-			Statement * callStmt = nullptr;
-			std::swap( stmt->callStmt, callStmt );
-			delete stmt;
-			return callStmt;
-		}
-
-		bool TreeCleaner::shouldClean( Declaration * decl ) {
-			return dynamic_cast< TraitDecl * >( decl );
-		}
-	} // namespace
 
 namespace {
Index: src/CodeGen/Generate.h
===================================================================
--- src/CodeGen/Generate.h	(revision 934fa0fc6af3737f7f5b45e08f4b84e1e8259312)
+++ src/CodeGen/Generate.h	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -27,9 +27,4 @@
 
 namespace CodeGen {
-	/// Generates code. doIntrinsics determines if intrinsic functions are printed, pretty formats output nicely (e.g., uses unmangled names, etc.), generateC is true when the output must consist only of C code (allows some assertions, etc.)
-	void generate( std::list< Declaration* > translationUnit, std::ostream &os, bool doIntrinsics, bool pretty, bool generateC = false , bool lineMarks = false, bool printTypeExpr = false );
-
-	/// Generate code for a single node -- helpful for debugging in gdb
-	void generate( BaseSyntaxNode * node, std::ostream & os );
 
 /// Generates all code in transUnit and writing it to the os.
Index: src/CodeGen/LinkOnce.cc
===================================================================
--- src/CodeGen/LinkOnce.cc	(revision 934fa0fc6af3737f7f5b45e08f4b84e1e8259312)
+++ src/CodeGen/LinkOnce.cc	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -22,50 +22,8 @@
 #include "AST/Expr.hpp"
 #include "AST/Pass.hpp"
-#include "Common/PassVisitor.h"       // for PassVisitor, WithShortCircuiting
 
 namespace CodeGen {
 
 namespace {
-
-bool is_cfa_linkonce_old( Attribute const * attr ) {
-	return std::string("cfa_linkonce") == attr->name;
-}
-
-bool is_section_attribute_old( Attribute const * attr ) {
-	return std::string("section") == attr->name;
-}
-
-class LinkOnceVisitorCore : public WithShortCircuiting {
-public:
-	void previsit( Declaration * ) {
-		visit_children = false;
-	}
-
-	void previsit( DeclarationWithType * decl ) {
-		std::list< Attribute * > & attributes = decl->attributes;
-		// See if we can find the element:
-		auto found = std::find_if(attributes.begin(), attributes.end(), is_cfa_linkonce_old );
-		if ( attributes.end() != found ) {
-			// Remove any other sections:
-			attributes.remove_if( is_section_attribute_old );
-			// Iterator to the cfa_linkonce attribute should still be valid.
-			Attribute * attribute = *found;
-			assert( attribute->parameters.empty() );
-			assert( !decl->mangleName.empty() );
-			// Overwrite the attribute in place.
-			const std::string section_name = ".gnu.linkonce." + decl->mangleName;
-			attribute->name = "section";
-			attribute->parameters.push_back(
-				new ConstantExpr( Constant::from_string( section_name ) )
-			);
-
-			// Unconditionnaly add "visibility(default)" to anything with gnu.linkonce
-			// visibility is a mess otherwise
-			attributes.push_back(new Attribute("visibility", {new ConstantExpr( Constant::from_string( "default" ) )}));
-
-		}
-		visit_children = false;
-	}
-};
 
 bool is_cfa_linkonce( ast::Attribute const * attr ) {
@@ -122,9 +80,4 @@
 } // namespace
 
-void translateLinkOnce( std::list< Declaration *> & translationUnit ) {
-	PassVisitor<LinkOnceVisitorCore> translator;
-	acceptAll( translationUnit, translator );
-}
-
 void translateLinkOnce( ast::TranslationUnit & translationUnit ) {
 	ast::Pass<LinkOnceCore>::run( translationUnit );
Index: src/CodeGen/LinkOnce.h
===================================================================
--- src/CodeGen/LinkOnce.h	(revision 934fa0fc6af3737f7f5b45e08f4b84e1e8259312)
+++ src/CodeGen/LinkOnce.h	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -20,7 +20,5 @@
 // for now its almost the only attribute we handle.
 
-#include <list>  // for list
 
-class Declaration;
 namespace ast {
 	class TranslationUnit;
@@ -29,5 +27,4 @@
 namespace CodeGen {
 
-void translateLinkOnce( std::list< Declaration *> & translationUnit );
 void translateLinkOnce( ast::TranslationUnit & translationUnit );
 /* Convert the cfa_linkonce attribute on top level declaration into
Index: src/CodeGen/module.mk
===================================================================
--- src/CodeGen/module.mk	(revision 934fa0fc6af3737f7f5b45e08f4b84e1e8259312)
+++ src/CodeGen/module.mk	(revision f5ec35a86ccf3e8ce04ba27d5834c2383512980d)
@@ -16,6 +16,4 @@
 
 SRC_CODEGEN = \
-	CodeGen/CodeGenerator.cc \
-	CodeGen/CodeGenerator.h \
 	CodeGen/CodeGeneratorNew.cpp \
 	CodeGen/CodeGeneratorNew.hpp \
