Index: src/GenPoly/BoxNew.cpp
===================================================================
--- src/GenPoly/BoxNew.cpp	(revision e85a72b8af411168ff8c331b0a5810e02b5c3e10)
+++ src/GenPoly/BoxNew.cpp	(revision 0bf0b9780fde0c94b2f64272197674ee7f3e3618)
@@ -95,25 +95,20 @@
 /// Adds parameters for otype size and alignment to a function type.
 void addSTypeParams(
-		ast::FunctionDecl * decl,
+		ast::vector<ast::DeclWithType> & params,
 		ast::vector<ast::TypeDecl> const & sizedParams ) {
-	// TODO: Can we fold this into buildLayoutFunction to avoid rebuilding?
-	ast::FunctionType * type = ast::mutate( decl->type.get() );
 	for ( ast::ptr<ast::TypeDecl> const & sizedParam : sizedParams ) {
 		ast::TypeInstType inst( sizedParam );
 		std::string paramName = Mangle::mangleType( &inst );
-		decl->params.emplace_back( new ast::ObjectDecl(
+		params.emplace_back( new ast::ObjectDecl(
 			sizedParam->location,
 			sizeofName( paramName ),
 			makeSizeAlignType()
 		) );
-		type->params.emplace_back( makeSizeAlignType() );
-		decl->params.emplace_back( new ast::ObjectDecl(
+		params.emplace_back( new ast::ObjectDecl(
 			sizedParam->location,
 			alignofName( paramName ),
 			makeSizeAlignType()
 		) );
-		type->params.emplace_back( makeSizeAlignType() );
-	}
-	decl->type = type;
+	}
 }
 
@@ -129,7 +124,7 @@
 };
 
-// TODO: Is there a better way to handle the different besides a flag?
 LayoutData buildLayoutFunction(
 		CodeLocation const & location, ast::AggregateDecl const * aggr,
+		ast::vector<ast::TypeDecl> const & sizedParams,
 		bool isInFunction, bool isStruct ) {
 	ast::ObjectDecl * sizeParam = new ast::ObjectDecl(
@@ -153,4 +148,5 @@
 		params.push_back( offsetParam );
 	}
+	addSTypeParams( params, sizedParams );
 
 	// Routines at global scope marked "static" to prevent multiple
@@ -238,6 +234,6 @@
 
 	// Build layout function signature.
-	LayoutData layout =
-		buildLayoutFunction( location, decl, isInFunction(), true );
+	LayoutData layout = buildLayoutFunction(
+		location, decl, sizedParams, isInFunction(), true );
 	ast::FunctionDecl * layoutDecl = layout.function;
 	// Also return these or extract them from the parameter list?
@@ -246,5 +242,4 @@
 	ast::ObjectDecl const * offsetofParam = layout.offsetofParam;
 	assert( nullptr != layout.offsetofParam );
-	addSTypeParams( layoutDecl, sizedParams );
 
 	// Calculate structure layout in function body.
@@ -313,6 +308,6 @@
 
 	// Build layout function signature.
-	LayoutData layout =
-		buildLayoutFunction( location, decl, isInFunction(), false );
+	LayoutData layout = buildLayoutFunction(
+		location, decl, sizedParams, isInFunction(), false );
 	ast::FunctionDecl * layoutDecl = layout.function;
 	// Also return these or extract them from the parameter list?
@@ -320,5 +315,4 @@
 	ast::ObjectDecl const * alignofParam = layout.alignofParam;
 	assert( nullptr == layout.offsetofParam );
-	addSTypeParams( layoutDecl, sizedParams );
 
 	// Calculate union layout in function body.
