diff --git a/src/writer/hlsl/generator_impl_alias_type_test.cc b/src/writer/hlsl/generator_impl_alias_type_test.cc index ae8a6e65f0..2d804310d6 100644 --- a/src/writer/hlsl/generator_impl_alias_type_test.cc +++ b/src/writer/hlsl/generator_impl_alias_type_test.cc @@ -51,16 +51,14 @@ TEST_F(HlslGeneratorImplTest_AliasType, EmitAliasType_Struct) { ast::type::F32Type f32; ast::StructMemberList members; - members.push_back(std::make_unique( - "a", &f32, ast::StructMemberDecorationList{})); + members.push_back( + create("a", &f32, ast::StructMemberDecorationList{})); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("b", &i32, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("b", &i32, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("A", std::move(str)); diff --git a/src/writer/hlsl/generator_impl_array_accessor_test.cc b/src/writer/hlsl/generator_impl_array_accessor_test.cc index b399f7e6cc..5842e7da33 100644 --- a/src/writer/hlsl/generator_impl_array_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_array_accessor_test.cc @@ -31,9 +31,9 @@ using HlslGeneratorImplTest_Expression = TestHelper; TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) { ast::type::I32Type i32; - auto lit = std::make_unique(&i32, 5); - auto idx = std::make_unique(std::move(lit)); - auto ary = std::make_unique("ary"); + auto lit = create(&i32, 5); + auto idx = create(std::move(lit)); + auto ary = create("ary"); ast::ArrayAccessorExpression expr(std::move(ary), std::move(idx)); @@ -42,8 +42,8 @@ TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) { } TEST_F(HlslGeneratorImplTest_Expression, EmitArrayAccessor) { - auto ary = std::make_unique("ary"); - auto idx = std::make_unique("idx"); + auto ary = create("ary"); + auto idx = create("idx"); ast::ArrayAccessorExpression expr(std::move(ary), std::move(idx)); diff --git a/src/writer/hlsl/generator_impl_assign_test.cc b/src/writer/hlsl/generator_impl_assign_test.cc index 8b9da6a3d3..37103d4a3a 100644 --- a/src/writer/hlsl/generator_impl_assign_test.cc +++ b/src/writer/hlsl/generator_impl_assign_test.cc @@ -28,8 +28,8 @@ namespace { using HlslGeneratorImplTest_Assign = TestHelper; TEST_F(HlslGeneratorImplTest_Assign, Emit_Assign) { - auto lhs = std::make_unique("lhs"); - auto rhs = std::make_unique("rhs"); + auto lhs = create("lhs"); + auto rhs = create("rhs"); ast::AssignmentStatement assign(std::move(lhs), std::move(rhs)); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc index fe5b0ad488..c201f4742f 100644 --- a/src/writer/hlsl/generator_impl_binary_test.cc +++ b/src/writer/hlsl/generator_impl_binary_test.cc @@ -54,8 +54,8 @@ using HlslBinaryTest = TestParamHelper; TEST_P(HlslBinaryTest, Emit) { auto params = GetParam(); - auto left = std::make_unique("left"); - auto right = std::make_unique("right"); + auto left = create("left"); + auto right = create("right"); ast::BinaryExpression expr(params.op, std::move(left), std::move(right)); @@ -84,8 +84,8 @@ INSTANTIATE_TEST_SUITE_P( BinaryData{"(left % right)", ast::BinaryOp::kModulo})); TEST_F(HlslGeneratorImplTest_Binary, Logical_And) { - auto left = std::make_unique("left"); - auto right = std::make_unique("right"); + auto left = create("left"); + auto right = create("right"); ast::BinaryExpression expr(ast::BinaryOp::kLogicalAnd, std::move(left), std::move(right)); @@ -101,17 +101,17 @@ if (_tint_tmp) { TEST_F(HlslGeneratorImplTest_Binary, Logical_Multi) { // (a && b) || (c || d) - auto a = std::make_unique("a"); - auto b = std::make_unique("b"); - auto c = std::make_unique("c"); - auto d = std::make_unique("d"); + auto a = create("a"); + auto b = create("b"); + auto c = create("c"); + auto d = create("d"); ast::BinaryExpression expr( ast::BinaryOp::kLogicalOr, - std::make_unique(ast::BinaryOp::kLogicalAnd, - std::move(a), std::move(b)), - std::make_unique(ast::BinaryOp::kLogicalOr, - std::move(c), std::move(d))); + create(ast::BinaryOp::kLogicalAnd, std::move(a), + std::move(b)), + create(ast::BinaryOp::kLogicalOr, std::move(c), + std::move(d))); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); EXPECT_EQ(result(), "(_tint_tmp_0)"); @@ -131,8 +131,8 @@ if (!_tint_tmp_0) { } TEST_F(HlslGeneratorImplTest_Binary, Logical_Or) { - auto left = std::make_unique("left"); - auto right = std::make_unique("right"); + auto left = create("left"); + auto right = create("right"); ast::BinaryExpression expr(ast::BinaryOp::kLogicalOr, std::move(left), std::move(right)); @@ -157,37 +157,36 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) { ast::type::I32Type i32; - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique( - std::make_unique(&i32, 3)))); - auto else_stmt = std::make_unique(std::move(body)); + auto body = create(); + body->append( + create(create( + create(&i32, 3)))); + auto else_stmt = create(std::move(body)); - body = std::make_unique(); - body->append(std::make_unique( - std::make_unique( - std::make_unique(&i32, 2)))); - auto else_if_stmt = std::make_unique( - std::make_unique( - ast::BinaryOp::kLogicalOr, - std::make_unique("b"), - std::make_unique("c")), + body = create(); + body->append( + create(create( + create(&i32, 2)))); + auto else_if_stmt = create( + create(ast::BinaryOp::kLogicalOr, + create("b"), + create("c")), std::move(body)); ast::ElseStatementList else_stmts; else_stmts.push_back(std::move(else_if_stmt)); else_stmts.push_back(std::move(else_stmt)); - body = std::make_unique(); - body->append(std::make_unique( - std::make_unique( - std::make_unique(&i32, 1)))); + body = create(); + body->append( + create(create( + create(&i32, 1)))); - ast::IfStatement expr(std::make_unique( - ast::BinaryOp::kLogicalAnd, - std::make_unique("a"), - std::make_unique("b")), - std::move(body)); + ast::IfStatement expr( + create(ast::BinaryOp::kLogicalAnd, + create("a"), + create("b")), + std::move(body)); expr.set_else_statements(std::move(else_stmts)); ASSERT_TRUE(gen.EmitStatement(out, &expr)) << gen.error(); @@ -213,14 +212,14 @@ if ((_tint_tmp)) { TEST_F(HlslGeneratorImplTest_Binary, Return_WithLogical) { // return (a && b) || c; - auto a = std::make_unique("a"); - auto b = std::make_unique("b"); - auto c = std::make_unique("c"); + auto a = create("a"); + auto b = create("b"); + auto c = create("c"); - ast::ReturnStatement expr(std::make_unique( + ast::ReturnStatement expr(create( ast::BinaryOp::kLogicalOr, - std::make_unique(ast::BinaryOp::kLogicalAnd, - std::move(a), std::move(b)), + create(ast::BinaryOp::kLogicalAnd, std::move(a), + std::move(b)), std::move(c))); ASSERT_TRUE(gen.EmitStatement(out, &expr)) << gen.error(); @@ -238,17 +237,17 @@ return (_tint_tmp_0); TEST_F(HlslGeneratorImplTest_Binary, Assign_WithLogical) { // a = (b || c) && d; - auto a = std::make_unique("a"); - auto b = std::make_unique("b"); - auto c = std::make_unique("c"); - auto d = std::make_unique("d"); + auto a = create("a"); + auto b = create("b"); + auto c = create("c"); + auto d = create("d"); ast::AssignmentStatement expr( std::move(a), - std::make_unique( + create( ast::BinaryOp::kLogicalAnd, - std::make_unique(ast::BinaryOp::kLogicalOr, - std::move(b), std::move(c)), + create(ast::BinaryOp::kLogicalOr, std::move(b), + std::move(c)), std::move(d))); ASSERT_TRUE(gen.EmitStatement(out, &expr)) << gen.error(); @@ -268,16 +267,16 @@ TEST_F(HlslGeneratorImplTest_Binary, Decl_WithLogical) { // var a : bool = (b && c) || d; ast::type::BoolType bool_type; - auto b = std::make_unique("b"); - auto c = std::make_unique("c"); - auto d = std::make_unique("d"); + auto b = create("b"); + auto c = create("c"); + auto d = create("d"); - auto var = std::make_unique("a", ast::StorageClass::kFunction, - &bool_type); - var->set_constructor(std::make_unique( + auto var = + create("a", ast::StorageClass::kFunction, &bool_type); + var->set_constructor(create( ast::BinaryOp::kLogicalOr, - std::make_unique(ast::BinaryOp::kLogicalAnd, - std::move(b), std::move(c)), + create(ast::BinaryOp::kLogicalAnd, std::move(b), + std::move(c)), std::move(d))); ast::VariableDeclStatement expr(std::move(var)); @@ -299,15 +298,15 @@ TEST_F(HlslGeneratorImplTest_Binary, Bitcast_WithLogical) { // as(a && (b || c)) ast::type::I32Type i32; - auto a = std::make_unique("a"); - auto b = std::make_unique("b"); - auto c = std::make_unique("c"); + auto a = create("a"); + auto b = create("b"); + auto c = create("c"); ast::BitcastExpression expr( - &i32, std::make_unique( + &i32, create( ast::BinaryOp::kLogicalAnd, std::move(a), - std::make_unique( - ast::BinaryOp::kLogicalOr, std::move(b), std::move(c)))); + create(ast::BinaryOp::kLogicalOr, + std::move(b), std::move(c)))); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); EXPECT_EQ(pre_result(), R"(bool _tint_tmp = a; @@ -327,32 +326,27 @@ TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) { ast::type::VoidType void_type; - auto func = - std::make_unique("foo", ast::VariableList{}, &void_type); + auto func = create("foo", ast::VariableList{}, &void_type); mod.AddFunction(std::move(func)); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( + ast::BinaryOp::kLogicalAnd, create("a"), + create("b"))); + params.push_back(create( + ast::BinaryOp::kLogicalOr, create("c"), + create("d"))); + params.push_back(create( ast::BinaryOp::kLogicalAnd, - std::make_unique("a"), - std::make_unique("b"))); - params.push_back(std::make_unique( - ast::BinaryOp::kLogicalOr, - std::make_unique("c"), - std::make_unique("d"))); - params.push_back(std::make_unique( - ast::BinaryOp::kLogicalAnd, - std::make_unique( - ast::BinaryOp::kLogicalOr, - std::make_unique("a"), - std::make_unique("c")), - std::make_unique( - ast::BinaryOp::kLogicalOr, - std::make_unique("b"), - std::make_unique("d")))); + create(ast::BinaryOp::kLogicalOr, + create("a"), + create("c")), + create(ast::BinaryOp::kLogicalOr, + create("b"), + create("d")))); - ast::CallStatement expr(std::make_unique( - std::make_unique("foo"), std::move(params))); + ast::CallStatement expr(create( + create("foo"), std::move(params))); ASSERT_TRUE(gen.EmitStatement(out, &expr)) << gen.error(); EXPECT_EQ(result(), R"(bool _tint_tmp = a; diff --git a/src/writer/hlsl/generator_impl_bitcast_test.cc b/src/writer/hlsl/generator_impl_bitcast_test.cc index e7cd7371a5..cfa6aeced7 100644 --- a/src/writer/hlsl/generator_impl_bitcast_test.cc +++ b/src/writer/hlsl/generator_impl_bitcast_test.cc @@ -31,7 +31,7 @@ using HlslGeneratorImplTest_Bitcast = TestHelper; TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) { ast::type::F32Type f32; - auto id = std::make_unique("id"); + auto id = create("id"); ast::BitcastExpression bitcast(&f32, std::move(id)); ASSERT_TRUE(gen.EmitExpression(pre, out, &bitcast)) << gen.error(); @@ -40,7 +40,7 @@ TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) { TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) { ast::type::I32Type i32; - auto id = std::make_unique("id"); + auto id = create("id"); ast::BitcastExpression bitcast(&i32, std::move(id)); ASSERT_TRUE(gen.EmitExpression(pre, out, &bitcast)) << gen.error(); @@ -49,7 +49,7 @@ TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) { TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) { ast::type::U32Type u32; - auto id = std::make_unique("id"); + auto id = create("id"); ast::BitcastExpression bitcast(&u32, std::move(id)); ASSERT_TRUE(gen.EmitExpression(pre, out, &bitcast)) << gen.error(); diff --git a/src/writer/hlsl/generator_impl_block_test.cc b/src/writer/hlsl/generator_impl_block_test.cc index 6d3549a7f2..7f0194e2d4 100644 --- a/src/writer/hlsl/generator_impl_block_test.cc +++ b/src/writer/hlsl/generator_impl_block_test.cc @@ -27,7 +27,7 @@ using HlslGeneratorImplTest_Block = TestHelper; TEST_F(HlslGeneratorImplTest_Block, Emit_Block) { ast::BlockStatement b; - b.append(std::make_unique()); + b.append(create()); gen.increment_indent(); @@ -40,7 +40,7 @@ TEST_F(HlslGeneratorImplTest_Block, Emit_Block) { TEST_F(HlslGeneratorImplTest_Block, Emit_Block_WithoutNewline) { ast::BlockStatement b; - b.append(std::make_unique()); + b.append(create()); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_call_test.cc b/src/writer/hlsl/generator_impl_call_test.cc index 58a8a1e5c8..6a50881d8c 100644 --- a/src/writer/hlsl/generator_impl_call_test.cc +++ b/src/writer/hlsl/generator_impl_call_test.cc @@ -32,11 +32,10 @@ using HlslGeneratorImplTest_Call = TestHelper; TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) { ast::type::VoidType void_type; - auto id = std::make_unique("my_func"); + auto id = create("my_func"); ast::CallExpression call(std::move(id), {}); - auto func = std::make_unique("my_func", ast::VariableList{}, - &void_type); + auto func = create("my_func", ast::VariableList{}, &void_type); mod.AddFunction(std::move(func)); ASSERT_TRUE(gen.EmitExpression(pre, out, &call)) << gen.error(); @@ -46,14 +45,13 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) { TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { ast::type::VoidType void_type; - auto id = std::make_unique("my_func"); + auto id = create("my_func"); ast::ExpressionList params; - params.push_back(std::make_unique("param1")); - params.push_back(std::make_unique("param2")); + params.push_back(create("param1")); + params.push_back(create("param2")); ast::CallExpression call(std::move(id), std::move(params)); - auto func = std::make_unique("my_func", ast::VariableList{}, - &void_type); + auto func = create("my_func", ast::VariableList{}, &void_type); mod.AddFunction(std::move(func)); ASSERT_TRUE(gen.EmitExpression(pre, out, &call)) << gen.error(); @@ -63,15 +61,14 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) { ast::type::VoidType void_type; - auto id = std::make_unique("my_func"); + auto id = create("my_func"); ast::ExpressionList params; - params.push_back(std::make_unique("param1")); - params.push_back(std::make_unique("param2")); + params.push_back(create("param1")); + params.push_back(create("param2")); ast::CallStatement call( - std::make_unique(std::move(id), std::move(params))); + create(std::move(id), std::move(params))); - auto func = std::make_unique("my_func", ast::VariableList{}, - &void_type); + auto func = create("my_func", ast::VariableList{}, &void_type); mod.AddFunction(std::move(func)); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &call)) << gen.error(); diff --git a/src/writer/hlsl/generator_impl_case_test.cc b/src/writer/hlsl/generator_impl_case_test.cc index 686e16e729..8da7d20f96 100644 --- a/src/writer/hlsl/generator_impl_case_test.cc +++ b/src/writer/hlsl/generator_impl_case_test.cc @@ -33,11 +33,11 @@ using HlslGeneratorImplTest_Case = TestHelper; TEST_F(HlslGeneratorImplTest_Case, Emit_Case) { ast::type::I32Type i32; - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); ast::CaseSelectorList lit; - lit.push_back(std::make_unique(&i32, 5)); + lit.push_back(create(&i32, 5)); ast::CaseStatement c(std::move(lit), std::move(body)); gen.increment_indent(); @@ -53,8 +53,8 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) { ast::type::I32Type i32; ast::CaseSelectorList lit; - lit.push_back(std::make_unique(&i32, 5)); - ast::CaseStatement c(std::move(lit), std::make_unique()); + lit.push_back(create(&i32, 5)); + ast::CaseStatement c(std::move(lit), create()); gen.increment_indent(); @@ -68,11 +68,11 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) { TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) { ast::type::I32Type i32; - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); ast::CaseSelectorList lit; - lit.push_back(std::make_unique(&i32, 5)); + lit.push_back(create(&i32, 5)); ast::CaseStatement c(std::move(lit), std::move(body)); gen.increment_indent(); @@ -87,12 +87,12 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) { TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) { ast::type::I32Type i32; - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); ast::CaseSelectorList lit; - lit.push_back(std::make_unique(&i32, 5)); - lit.push_back(std::make_unique(&i32, 6)); + lit.push_back(create(&i32, 5)); + lit.push_back(create(&i32, 6)); ast::CaseStatement c(std::move(lit), std::move(body)); gen.increment_indent(); @@ -108,8 +108,8 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) { TEST_F(HlslGeneratorImplTest_Case, Emit_Case_Default) { ast::CaseStatement c; - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); c.set_body(std::move(body)); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_cast_test.cc b/src/writer/hlsl/generator_impl_cast_test.cc index 9c88e51779..6052494df2 100644 --- a/src/writer/hlsl/generator_impl_cast_test.cc +++ b/src/writer/hlsl/generator_impl_cast_test.cc @@ -32,7 +32,7 @@ TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) { ast::type::F32Type f32; ast::ExpressionList params; - params.push_back(std::make_unique("id")); + params.push_back(create("id")); ast::TypeConstructorExpression cast(&f32, std::move(params)); @@ -45,7 +45,7 @@ TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Vector) { ast::type::VectorType vec3(&f32, 3); ast::ExpressionList params; - params.push_back(std::make_unique("id")); + params.push_back(create("id")); ast::TypeConstructorExpression cast(&vec3, std::move(params)); diff --git a/src/writer/hlsl/generator_impl_constructor_test.cc b/src/writer/hlsl/generator_impl_constructor_test.cc index 1a953d0758..96ccff7167 100644 --- a/src/writer/hlsl/generator_impl_constructor_test.cc +++ b/src/writer/hlsl/generator_impl_constructor_test.cc @@ -37,7 +37,7 @@ using HlslGeneratorImplTest_Constructor = TestHelper; TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) { ast::type::BoolType bool_type; - auto lit = std::make_unique(&bool_type, false); + auto lit = create(&bool_type, false); ast::ScalarConstructorExpression expr(std::move(lit)); ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error(); @@ -46,7 +46,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Bool) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Int) { ast::type::I32Type i32; - auto lit = std::make_unique(&i32, -12345); + auto lit = create(&i32, -12345); ast::ScalarConstructorExpression expr(std::move(lit)); ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error(); @@ -55,7 +55,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Int) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_UInt) { ast::type::U32Type u32; - auto lit = std::make_unique(&u32, 56779); + auto lit = create(&u32, 56779); ast::ScalarConstructorExpression expr(std::move(lit)); ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error(); @@ -65,8 +65,7 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_UInt) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Float) { ast::type::F32Type f32; // Use a number close to 1<<30 but whose decimal representation ends in 0. - auto lit = std::make_unique( - &f32, static_cast((1 << 30) - 4)); + auto lit = create(&f32, static_cast((1 << 30) - 4)); ast::ScalarConstructorExpression expr(std::move(lit)); ASSERT_TRUE(gen.EmitConstructor(pre, out, &expr)) << gen.error(); @@ -76,10 +75,9 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Float) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) { ast::type::F32Type f32; - auto lit = std::make_unique(&f32, -1.2e-5); + auto lit = create(&f32, -1.2e-5); ast::ExpressionList values; - values.push_back( - std::make_unique(std::move(lit))); + values.push_back(create(std::move(lit))); ast::TypeConstructorExpression expr(&f32, std::move(values)); @@ -90,10 +88,9 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Bool) { ast::type::BoolType b; - auto lit = std::make_unique(&b, true); + auto lit = create(&b, true); ast::ExpressionList values; - values.push_back( - std::make_unique(std::move(lit))); + values.push_back(create(std::move(lit))); ast::TypeConstructorExpression expr(&b, std::move(values)); @@ -104,10 +101,9 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Bool) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Int) { ast::type::I32Type i32; - auto lit = std::make_unique(&i32, -12345); + auto lit = create(&i32, -12345); ast::ExpressionList values; - values.push_back( - std::make_unique(std::move(lit))); + values.push_back(create(std::move(lit))); ast::TypeConstructorExpression expr(&i32, std::move(values)); @@ -118,10 +114,9 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Int) { TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Uint) { ast::type::U32Type u32; - auto lit = std::make_unique(&u32, 12345); + auto lit = create(&u32, 12345); ast::ExpressionList values; - values.push_back( - std::make_unique(std::move(lit))); + values.push_back(create(std::move(lit))); ast::TypeConstructorExpression expr(&u32, std::move(values)); @@ -133,16 +128,13 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) { ast::type::F32Type f32; ast::type::VectorType vec(&f32, 3); - auto lit1 = std::make_unique(&f32, 1.f); - auto lit2 = std::make_unique(&f32, 2.f); - auto lit3 = std::make_unique(&f32, 3.f); + auto lit1 = create(&f32, 1.f); + auto lit2 = create(&f32, 2.f); + auto lit3 = create(&f32, 3.f); ast::ExpressionList values; - values.push_back( - std::make_unique(std::move(lit1))); - values.push_back( - std::make_unique(std::move(lit2))); - values.push_back( - std::make_unique(std::move(lit3))); + values.push_back(create(std::move(lit1))); + values.push_back(create(std::move(lit2))); + values.push_back(create(std::move(lit3))); ast::TypeConstructorExpression expr(&vec, std::move(values)); @@ -173,23 +165,20 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) { ast::ExpressionList mat_values; for (size_t i = 0; i < 2; i++) { - auto lit1 = std::make_unique( - &f32, static_cast(1 + (i * 2))); - auto lit2 = std::make_unique( - &f32, static_cast(2 + (i * 2))); - auto lit3 = std::make_unique( - &f32, static_cast(3 + (i * 2))); + auto lit1 = + create(&f32, static_cast(1 + (i * 2))); + auto lit2 = + create(&f32, static_cast(2 + (i * 2))); + auto lit3 = + create(&f32, static_cast(3 + (i * 2))); ast::ExpressionList values; - values.push_back( - std::make_unique(std::move(lit1))); - values.push_back( - std::make_unique(std::move(lit2))); - values.push_back( - std::make_unique(std::move(lit3))); + values.push_back(create(std::move(lit1))); + values.push_back(create(std::move(lit2))); + values.push_back(create(std::move(lit3))); - mat_values.push_back(std::make_unique( - &vec, std::move(values))); + mat_values.push_back( + create(&vec, std::move(values))); } ast::TypeConstructorExpression expr(&mat, std::move(mat_values)); @@ -212,23 +201,20 @@ TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) { ast::ExpressionList ary_values; for (size_t i = 0; i < 3; i++) { - auto lit1 = std::make_unique( - &f32, static_cast(1 + (i * 3))); - auto lit2 = std::make_unique( - &f32, static_cast(2 + (i * 3))); - auto lit3 = std::make_unique( - &f32, static_cast(3 + (i * 3))); + auto lit1 = + create(&f32, static_cast(1 + (i * 3))); + auto lit2 = + create(&f32, static_cast(2 + (i * 3))); + auto lit3 = + create(&f32, static_cast(3 + (i * 3))); ast::ExpressionList values; - values.push_back( - std::make_unique(std::move(lit1))); - values.push_back( - std::make_unique(std::move(lit2))); - values.push_back( - std::make_unique(std::move(lit3))); + values.push_back(create(std::move(lit1))); + values.push_back(create(std::move(lit2))); + values.push_back(create(std::move(lit3))); - ary_values.push_back(std::make_unique( - &vec, std::move(values))); + ary_values.push_back( + create(&vec, std::move(values))); } ast::TypeConstructorExpression expr(&ary, std::move(ary_values)); diff --git a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc index 9347e951a0..1803fd0527 100644 --- a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc +++ b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc @@ -53,16 +53,16 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::F32Type f32; ast::type::I32Type i32; - auto foo_var = std::make_unique( - std::make_unique("foo", ast::StorageClass::kInput, &f32)); + auto foo_var = create( + create("foo", ast::StorageClass::kInput, &f32)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); foo_var->set_decorations(std::move(decos)); - auto bar_var = std::make_unique( - std::make_unique("bar", ast::StorageClass::kInput, &i32)); - decos.push_back(std::make_unique(1, Source{})); + auto bar_var = create( + create("bar", ast::StorageClass::kInput, &i32)); + decos.push_back(create(1, Source{})); bar_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(foo_var.get()); @@ -72,19 +72,18 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(std::move(bar_var)); ast::VariableList params; - auto func = - std::make_unique("vtx_main", std::move(params), &f32); - func->add_decoration(std::make_unique( - ast::PipelineStage::kVertex, Source{})); + auto func = create("vtx_main", std::move(params), &f32); + func->add_decoration( + create(ast::PipelineStage::kVertex, Source{})); auto* func_ptr = func.get(); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("foo"), - std::make_unique("foo"))); - body->append(std::make_unique( - std::make_unique("bar"), - std::make_unique("bar"))); + auto body = create(); + body->append(create( + create("foo"), + create("foo"))); + body->append(create( + create("bar"), + create("bar"))); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -114,16 +113,16 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::F32Type f32; ast::type::I32Type i32; - auto foo_var = std::make_unique( - std::make_unique("foo", ast::StorageClass::kOutput, &f32)); + auto foo_var = create( + create("foo", ast::StorageClass::kOutput, &f32)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); foo_var->set_decorations(std::move(decos)); - auto bar_var = std::make_unique( - std::make_unique("bar", ast::StorageClass::kOutput, &i32)); - decos.push_back(std::make_unique(1, Source{})); + auto bar_var = create( + create("bar", ast::StorageClass::kOutput, &i32)); + decos.push_back(create(1, Source{})); bar_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(foo_var.get()); @@ -133,19 +132,18 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(std::move(bar_var)); ast::VariableList params; - auto func = - std::make_unique("vtx_main", std::move(params), &f32); - func->add_decoration(std::make_unique( - ast::PipelineStage::kVertex, Source{})); + auto func = create("vtx_main", std::move(params), &f32); + func->add_decoration( + create(ast::PipelineStage::kVertex, Source{})); auto* func_ptr = func.get(); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("foo"), - std::make_unique("foo"))); - body->append(std::make_unique( - std::make_unique("bar"), - std::make_unique("bar"))); + auto body = create(); + body->append(create( + create("foo"), + create("foo"))); + body->append(create( + create("bar"), + create("bar"))); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -175,16 +173,16 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::F32Type f32; ast::type::I32Type i32; - auto foo_var = std::make_unique( - std::make_unique("foo", ast::StorageClass::kInput, &f32)); + auto foo_var = create( + create("foo", ast::StorageClass::kInput, &f32)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); foo_var->set_decorations(std::move(decos)); - auto bar_var = std::make_unique( - std::make_unique("bar", ast::StorageClass::kInput, &i32)); - decos.push_back(std::make_unique(1, Source{})); + auto bar_var = create( + create("bar", ast::StorageClass::kInput, &i32)); + decos.push_back(create(1, Source{})); bar_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(foo_var.get()); @@ -194,18 +192,18 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(std::move(bar_var)); ast::VariableList params; - auto func = std::make_unique("main", std::move(params), &f32); - func->add_decoration(std::make_unique( - ast::PipelineStage::kVertex, Source{})); + auto func = create("main", std::move(params), &f32); + func->add_decoration( + create(ast::PipelineStage::kVertex, Source{})); auto* func_ptr = func.get(); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("foo"), - std::make_unique("foo"))); - body->append(std::make_unique( - std::make_unique("bar"), - std::make_unique("bar"))); + auto body = create(); + body->append(create( + create("foo"), + create("foo"))); + body->append(create( + create("bar"), + create("bar"))); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -235,16 +233,16 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::F32Type f32; ast::type::I32Type i32; - auto foo_var = std::make_unique( - std::make_unique("foo", ast::StorageClass::kOutput, &f32)); + auto foo_var = create( + create("foo", ast::StorageClass::kOutput, &f32)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); foo_var->set_decorations(std::move(decos)); - auto bar_var = std::make_unique( - std::make_unique("bar", ast::StorageClass::kOutput, &i32)); - decos.push_back(std::make_unique(1, Source{})); + auto bar_var = create( + create("bar", ast::StorageClass::kOutput, &i32)); + decos.push_back(create(1, Source{})); bar_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(foo_var.get()); @@ -254,18 +252,18 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(std::move(bar_var)); ast::VariableList params; - auto func = std::make_unique("main", std::move(params), &f32); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = create("main", std::move(params), &f32); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); auto* func_ptr = func.get(); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("foo"), - std::make_unique("foo"))); - body->append(std::make_unique( - std::make_unique("bar"), - std::make_unique("bar"))); + auto body = create(); + body->append(create( + create("foo"), + create("foo"))); + body->append(create( + create("bar"), + create("bar"))); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -292,16 +290,16 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::F32Type f32; ast::type::I32Type i32; - auto foo_var = std::make_unique( - std::make_unique("foo", ast::StorageClass::kInput, &f32)); + auto foo_var = create( + create("foo", ast::StorageClass::kInput, &f32)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); foo_var->set_decorations(std::move(decos)); - auto bar_var = std::make_unique( - std::make_unique("bar", ast::StorageClass::kInput, &i32)); - decos.push_back(std::make_unique(1, Source{})); + auto bar_var = create( + create("bar", ast::StorageClass::kInput, &i32)); + decos.push_back(create(1, Source{})); bar_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(foo_var.get()); @@ -311,18 +309,18 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(std::move(bar_var)); ast::VariableList params; - auto func = std::make_unique("main", std::move(params), &f32); - func->add_decoration(std::make_unique( - ast::PipelineStage::kCompute, Source{})); + auto func = create("main", std::move(params), &f32); + func->add_decoration( + create(ast::PipelineStage::kCompute, Source{})); auto* func_ptr = func.get(); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("foo"), - std::make_unique("foo"))); - body->append(std::make_unique( - std::make_unique("bar"), - std::make_unique("bar"))); + auto body = create(); + body->append(create( + create("foo"), + create("foo"))); + body->append(create( + create("bar"), + create("bar"))); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -344,16 +342,16 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::F32Type f32; ast::type::I32Type i32; - auto foo_var = std::make_unique( - std::make_unique("foo", ast::StorageClass::kOutput, &f32)); + auto foo_var = create( + create("foo", ast::StorageClass::kOutput, &f32)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); foo_var->set_decorations(std::move(decos)); - auto bar_var = std::make_unique( - std::make_unique("bar", ast::StorageClass::kOutput, &i32)); - decos.push_back(std::make_unique(1, Source{})); + auto bar_var = create( + create("bar", ast::StorageClass::kOutput, &i32)); + decos.push_back(create(1, Source{})); bar_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(foo_var.get()); @@ -363,18 +361,18 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(std::move(bar_var)); ast::VariableList params; - auto func = std::make_unique("main", std::move(params), &f32); - func->add_decoration(std::make_unique( - ast::PipelineStage::kCompute, Source{})); + auto func = create("main", std::move(params), &f32); + func->add_decoration( + create(ast::PipelineStage::kCompute, Source{})); auto* func_ptr = func.get(); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("foo"), - std::make_unique("foo"))); - body->append(std::make_unique( - std::make_unique("bar"), - std::make_unique("bar"))); + auto body = create(); + body->append(create( + create("foo"), + create("foo"))); + body->append(create( + create("bar"), + create("bar"))); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -403,20 +401,18 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::VoidType void_type; ast::type::VectorType vec4(&f32, 4); - auto coord_var = - std::make_unique(std::make_unique( - "coord", ast::StorageClass::kInput, &vec4)); + auto coord_var = create( + create("coord", ast::StorageClass::kInput, &vec4)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique( - ast::Builtin::kFragCoord, Source{})); + decos.push_back( + create(ast::Builtin::kFragCoord, Source{})); coord_var->set_decorations(std::move(decos)); - auto depth_var = - std::make_unique(std::make_unique( - "depth", ast::StorageClass::kOutput, &f32)); - decos.push_back(std::make_unique( - ast::Builtin::kFragDepth, Source{})); + auto depth_var = create( + create("depth", ast::StorageClass::kOutput, &f32)); + decos.push_back( + create(ast::Builtin::kFragDepth, Source{})); depth_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(coord_var.get()); @@ -426,18 +422,17 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(std::move(depth_var)); ast::VariableList params; - auto func = - std::make_unique("main", std::move(params), &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = create("main", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); auto* func_ptr = func.get(); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("depth"), - std::make_unique( - std::make_unique("coord"), - std::make_unique("x")))); + auto body = create(); + body->append(create( + create("depth"), + create( + create("coord"), + create("x")))); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc index 3df64920a4..a4e9df3fce 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -57,11 +57,10 @@ using HlslGeneratorImplTest_Function = TestHelper; TEST_F(HlslGeneratorImplTest_Function, Emit_Function) { ast::type::VoidType void_type; - auto func = std::make_unique("my_func", ast::VariableList{}, - &void_type); + auto func = create("my_func", ast::VariableList{}, &void_type); - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -78,11 +77,11 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function) { TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) { ast::type::VoidType void_type; - auto func = std::make_unique("GeometryShader", - ast::VariableList{}, &void_type); + auto func = + create("GeometryShader", ast::VariableList{}, &void_type); - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -101,17 +100,14 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) { ast::type::I32Type i32; ast::VariableList params; - params.push_back( - std::make_unique("a", ast::StorageClass::kNone, &f32)); - params.push_back( - std::make_unique("b", ast::StorageClass::kNone, &i32)); + params.push_back(create("a", ast::StorageClass::kNone, &f32)); + params.push_back(create("b", ast::StorageClass::kNone, &i32)); ast::type::VoidType void_type; - auto func = - std::make_unique("my_func", std::move(params), &void_type); + auto func = create("my_func", std::move(params), &void_type); - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -130,16 +126,16 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::VoidType void_type; ast::type::F32Type f32; - auto foo_var = std::make_unique( - std::make_unique("foo", ast::StorageClass::kInput, &f32)); + auto foo_var = create( + create("foo", ast::StorageClass::kInput, &f32)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); foo_var->set_decorations(std::move(decos)); - auto bar_var = std::make_unique( - std::make_unique("bar", ast::StorageClass::kOutput, &f32)); - decos.push_back(std::make_unique(1, Source{})); + auto bar_var = create( + create("bar", ast::StorageClass::kOutput, &f32)); + decos.push_back(create(1, Source{})); bar_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(foo_var.get()); @@ -149,16 +145,15 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(std::move(bar_var)); ast::VariableList params; - auto func = std::make_unique("frag_main", std::move(params), - &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = create("frag_main", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("bar"), - std::make_unique("foo"))); - body->append(std::make_unique()); + auto body = create(); + body->append(create( + create("bar"), + create("foo"))); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -188,20 +183,18 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32Type f32; ast::type::VectorType vec4(&f32, 4); - auto coord_var = - std::make_unique(std::make_unique( - "coord", ast::StorageClass::kInput, &vec4)); + auto coord_var = create( + create("coord", ast::StorageClass::kInput, &vec4)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique( - ast::Builtin::kFragCoord, Source{})); + decos.push_back( + create(ast::Builtin::kFragCoord, Source{})); coord_var->set_decorations(std::move(decos)); - auto depth_var = - std::make_unique(std::make_unique( - "depth", ast::StorageClass::kOutput, &f32)); - decos.push_back(std::make_unique( - ast::Builtin::kFragDepth, Source{})); + auto depth_var = create( + create("depth", ast::StorageClass::kOutput, &f32)); + decos.push_back( + create(ast::Builtin::kFragDepth, Source{})); depth_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(coord_var.get()); @@ -211,18 +204,17 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(std::move(depth_var)); ast::VariableList params; - auto func = std::make_unique("frag_main", std::move(params), - &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = create("frag_main", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("depth"), - std::make_unique( - std::make_unique("coord"), - std::make_unique("x")))); - body->append(std::make_unique()); + auto body = create(); + body->append(create( + create("depth"), + create( + create("coord"), + create("x")))); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -252,33 +244,30 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32Type f32; ast::type::VectorType vec4(&f32, 4); - auto coord_var = - std::make_unique(std::make_unique( - "coord", ast::StorageClass::kUniform, &vec4)); + auto coord_var = create( + create("coord", ast::StorageClass::kUniform, &vec4)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); - decos.push_back(std::make_unique(1, Source{})); + decos.push_back(create(0, Source{})); + decos.push_back(create(1, Source{})); coord_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(coord_var.get()); mod.AddGlobalVariable(std::move(coord_var)); ast::VariableList params; - auto func = std::make_unique("frag_main", std::move(params), - &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = create("frag_main", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); - auto var = - std::make_unique("v", ast::StorageClass::kFunction, &f32); - var->set_constructor(std::make_unique( - std::make_unique("coord"), - std::make_unique("x"))); + auto var = create("v", ast::StorageClass::kFunction, &f32); + var->set_constructor(create( + create("coord"), + create("x"))); - auto body = std::make_unique(); - body->append(std::make_unique(std::move(var))); - body->append(std::make_unique()); + auto body = create(); + body->append(create(std::move(var))); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -304,45 +293,42 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::VectorType vec4(&f32, 4); ast::StructMemberList members; - members.push_back(std::make_unique( + members.push_back(create( "coord", &vec4, ast::StructMemberDecorationList{})); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Uniforms", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "uniforms", ast::StorageClass::kUniform, &s)); + auto coord_var = create( + create("uniforms", ast::StorageClass::kUniform, &s)); mod.AddConstructedType(&s); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); - decos.push_back(std::make_unique(1, Source{})); + decos.push_back(create(0, Source{})); + decos.push_back(create(1, Source{})); coord_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(coord_var.get()); mod.AddGlobalVariable(std::move(coord_var)); ast::VariableList params; - auto func = std::make_unique("frag_main", std::move(params), - &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = create("frag_main", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); - auto var = - std::make_unique("v", ast::StorageClass::kFunction, &f32); - var->set_constructor(std::make_unique( - std::make_unique( - std::make_unique("uniforms"), - std::make_unique("coord")), - std::make_unique("x"))); + auto var = create("v", ast::StorageClass::kFunction, &f32); + var->set_constructor(create( + create( + create("uniforms"), + create("coord")), + create("x"))); - auto body = std::make_unique(); - body->append(std::make_unique(std::move(var))); - body->append(std::make_unique()); + auto body = create(); + body->append(create(std::move(var))); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -371,50 +357,43 @@ TEST_F(HlslGeneratorImplTest_Function, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("b", &f32, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("b", &f32, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s); - auto coord_var = - std::make_unique(std::make_unique( - "coord", ast::StorageClass::kStorageBuffer, &ac)); + auto coord_var = create( + create("coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); - decos.push_back(std::make_unique(1, Source{})); + decos.push_back(create(0, Source{})); + decos.push_back(create(1, Source{})); coord_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(coord_var.get()); mod.AddGlobalVariable(std::move(coord_var)); ast::VariableList params; - auto func = std::make_unique("frag_main", std::move(params), - &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = create("frag_main", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); - auto var = - std::make_unique("v", ast::StorageClass::kFunction, &f32); - var->set_constructor(std::make_unique( - std::make_unique("coord"), - std::make_unique("b"))); + auto var = create("v", ast::StorageClass::kFunction, &f32); + var->set_constructor(create( + create("coord"), + create("b"))); - auto body = std::make_unique(); - body->append(std::make_unique(std::move(var))); - body->append(std::make_unique()); + auto body = create(); + body->append(create(std::move(var))); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -439,50 +418,43 @@ TEST_F(HlslGeneratorImplTest_Function, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("b", &f32, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("b", &f32, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); ast::type::AccessControlType ac(ast::AccessControl::kReadOnly, &s); - auto coord_var = - std::make_unique(std::make_unique( - "coord", ast::StorageClass::kStorageBuffer, &ac)); + auto coord_var = create( + create("coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); - decos.push_back(std::make_unique(1, Source{})); + decos.push_back(create(0, Source{})); + decos.push_back(create(1, Source{})); coord_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(coord_var.get()); mod.AddGlobalVariable(std::move(coord_var)); ast::VariableList params; - auto func = std::make_unique("frag_main", std::move(params), - &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = create("frag_main", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); - auto var = - std::make_unique("v", ast::StorageClass::kFunction, &f32); - var->set_constructor(std::make_unique( - std::make_unique("coord"), - std::make_unique("b"))); + auto var = create("v", ast::StorageClass::kFunction, &f32); + var->set_constructor(create( + create("coord"), + create("b"))); - auto body = std::make_unique(); - body->append(std::make_unique(std::move(var))); - body->append(std::make_unique()); + auto body = create(); + body->append(create(std::move(var))); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -507,30 +479,25 @@ TEST_F(HlslGeneratorImplTest_Function, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("b", &f32, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("b", &f32, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s); - auto coord_var = - std::make_unique(std::make_unique( - "coord", ast::StorageClass::kStorageBuffer, &ac)); + auto coord_var = create( + create("coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); - decos.push_back(std::make_unique(1, Source{})); + decos.push_back(create(0, Source{})); + decos.push_back(create(1, Source{})); coord_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(coord_var.get()); @@ -538,21 +505,20 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(std::move(coord_var)); ast::VariableList params; - auto func = std::make_unique("frag_main", std::move(params), - &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = create("frag_main", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); - auto assign = std::make_unique( - std::make_unique( - std::make_unique("coord"), - std::make_unique("b")), - std::make_unique( - std::make_unique(&f32, 2.0f))); + auto assign = create( + create( + create("coord"), + create("b")), + create( + create(&f32, 2.0f))); - auto body = std::make_unique(); + auto body = create(); body->append(std::move(assign)); - body->append(std::make_unique()); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -575,21 +541,21 @@ TEST_F( ast::type::VoidType void_type; ast::type::F32Type f32; - auto foo_var = std::make_unique( - std::make_unique("foo", ast::StorageClass::kInput, &f32)); + auto foo_var = create( + create("foo", ast::StorageClass::kInput, &f32)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); foo_var->set_decorations(std::move(decos)); - auto bar_var = std::make_unique( - std::make_unique("bar", ast::StorageClass::kOutput, &f32)); - decos.push_back(std::make_unique(1, Source{})); + auto bar_var = create( + create("bar", ast::StorageClass::kOutput, &f32)); + decos.push_back(create(1, Source{})); bar_var->set_decorations(std::move(decos)); - auto val_var = std::make_unique( - std::make_unique("val", ast::StorageClass::kOutput, &f32)); - decos.push_back(std::make_unique(0, Source{})); + auto val_var = create( + create("val", ast::StorageClass::kOutput, &f32)); + decos.push_back(create(0, Source{})); val_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(foo_var.get()); @@ -601,40 +567,37 @@ TEST_F( mod.AddGlobalVariable(std::move(val_var)); ast::VariableList params; - params.push_back(std::make_unique( - "param", ast::StorageClass::kFunction, &f32)); - auto sub_func = - std::make_unique("sub_func", std::move(params), &f32); + params.push_back( + create("param", ast::StorageClass::kFunction, &f32)); + auto sub_func = create("sub_func", std::move(params), &f32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("bar"), - std::make_unique("foo"))); - body->append(std::make_unique( - std::make_unique("val"), - std::make_unique("param"))); - body->append(std::make_unique( - std::make_unique("foo"))); + auto body = create(); + body->append(create( + create("bar"), + create("foo"))); + body->append(create( + create("val"), + create("param"))); + body->append( + create(create("foo"))); sub_func->set_body(std::move(body)); mod.AddFunction(std::move(sub_func)); - auto func_1 = - std::make_unique("ep_1", std::move(params), &void_type); - func_1->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func_1 = create("ep_1", std::move(params), &void_type); + func_1->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); ast::ExpressionList expr; - expr.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); + expr.push_back(create( + create(&f32, 1.0f))); - body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("bar"), - std::make_unique( - std::make_unique("sub_func"), - std::move(expr)))); - body->append(std::make_unique()); + body = create(); + body->append(create( + create("bar"), + create(create("sub_func"), + std::move(expr)))); + body->append(create()); func_1->set_body(std::move(body)); mod.AddFunction(std::move(func_1)); @@ -671,13 +634,12 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32Type f32; ast::type::VectorType vec4(&f32, 4); - auto depth_var = - std::make_unique(std::make_unique( - "depth", ast::StorageClass::kOutput, &f32)); + auto depth_var = create( + create("depth", ast::StorageClass::kOutput, &f32)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique( - ast::Builtin::kFragDepth, Source{})); + decos.push_back( + create(ast::Builtin::kFragDepth, Source{})); depth_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(depth_var.get()); @@ -685,34 +647,31 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(std::move(depth_var)); ast::VariableList params; - params.push_back(std::make_unique( - "param", ast::StorageClass::kFunction, &f32)); - auto sub_func = - std::make_unique("sub_func", std::move(params), &f32); + params.push_back( + create("param", ast::StorageClass::kFunction, &f32)); + auto sub_func = create("sub_func", std::move(params), &f32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("param"))); + auto body = create(); + body->append( + create(create("param"))); sub_func->set_body(std::move(body)); mod.AddFunction(std::move(sub_func)); - auto func_1 = - std::make_unique("ep_1", std::move(params), &void_type); - func_1->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func_1 = create("ep_1", std::move(params), &void_type); + func_1->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); ast::ExpressionList expr; - expr.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); + expr.push_back(create( + create(&f32, 1.0f))); - body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("depth"), - std::make_unique( - std::make_unique("sub_func"), - std::move(expr)))); - body->append(std::make_unique()); + body = create(); + body->append(create( + create("depth"), + create(create("sub_func"), + std::move(expr)))); + body->append(create()); func_1->set_body(std::move(body)); mod.AddFunction(std::move(func_1)); @@ -743,20 +702,18 @@ TEST_F( ast::type::F32Type f32; ast::type::VectorType vec4(&f32, 4); - auto coord_var = - std::make_unique(std::make_unique( - "coord", ast::StorageClass::kInput, &vec4)); + auto coord_var = create( + create("coord", ast::StorageClass::kInput, &vec4)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique( - ast::Builtin::kFragCoord, Source{})); + decos.push_back( + create(ast::Builtin::kFragCoord, Source{})); coord_var->set_decorations(std::move(decos)); - auto depth_var = - std::make_unique(std::make_unique( - "depth", ast::StorageClass::kOutput, &f32)); - decos.push_back(std::make_unique( - ast::Builtin::kFragDepth, Source{})); + auto depth_var = create( + create("depth", ast::StorageClass::kOutput, &f32)); + decos.push_back( + create(ast::Builtin::kFragDepth, Source{})); depth_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(coord_var.get()); @@ -766,39 +723,36 @@ TEST_F( mod.AddGlobalVariable(std::move(depth_var)); ast::VariableList params; - params.push_back(std::make_unique( - "param", ast::StorageClass::kFunction, &f32)); - auto sub_func = - std::make_unique("sub_func", std::move(params), &f32); + params.push_back( + create("param", ast::StorageClass::kFunction, &f32)); + auto sub_func = create("sub_func", std::move(params), &f32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("depth"), - std::make_unique( - std::make_unique("coord"), - std::make_unique("x")))); - body->append(std::make_unique( - std::make_unique("param"))); + auto body = create(); + body->append(create( + create("depth"), + create( + create("coord"), + create("x")))); + body->append( + create(create("param"))); sub_func->set_body(std::move(body)); mod.AddFunction(std::move(sub_func)); - auto func_1 = - std::make_unique("ep_1", std::move(params), &void_type); - func_1->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func_1 = create("ep_1", std::move(params), &void_type); + func_1->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); ast::ExpressionList expr; - expr.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); + expr.push_back(create( + create(&f32, 1.0f))); - body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("depth"), - std::make_unique( - std::make_unique("sub_func"), - std::move(expr)))); - body->append(std::make_unique()); + body = create(); + body->append(create( + create("depth"), + create(create("sub_func"), + std::move(expr)))); + body->append(create()); func_1->set_body(std::move(body)); mod.AddFunction(std::move(func_1)); @@ -833,13 +787,12 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32Type f32; ast::type::VectorType vec4(&f32, 4); - auto coord_var = - std::make_unique(std::make_unique( - "coord", ast::StorageClass::kUniform, &vec4)); + auto coord_var = create( + create("coord", ast::StorageClass::kUniform, &vec4)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); - decos.push_back(std::make_unique(1, Source{})); + decos.push_back(create(0, Source{})); + decos.push_back(create(1, Source{})); coord_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(coord_var.get()); @@ -847,38 +800,34 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(std::move(coord_var)); ast::VariableList params; - params.push_back(std::make_unique( - "param", ast::StorageClass::kFunction, &f32)); - auto sub_func = - std::make_unique("sub_func", std::move(params), &f32); + params.push_back( + create("param", ast::StorageClass::kFunction, &f32)); + auto sub_func = create("sub_func", std::move(params), &f32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique( - std::make_unique("coord"), - std::make_unique("x")))); + auto body = create(); + body->append( + create(create( + create("coord"), + create("x")))); sub_func->set_body(std::move(body)); mod.AddFunction(std::move(sub_func)); - auto func = std::make_unique("frag_main", std::move(params), - &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = create("frag_main", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); ast::ExpressionList expr; - expr.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); + expr.push_back(create( + create(&f32, 1.0f))); - auto var = - std::make_unique("v", ast::StorageClass::kFunction, &f32); - var->set_constructor(std::make_unique( - std::make_unique("sub_func"), - std::move(expr))); + auto var = create("v", ast::StorageClass::kFunction, &f32); + var->set_constructor(create( + create("sub_func"), std::move(expr))); - body = std::make_unique(); - body->append(std::make_unique(std::move(var))); - body->append(std::make_unique()); + body = create(); + body->append(create(std::move(var))); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -907,13 +856,12 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32Type f32; ast::type::VectorType vec4(&f32, 4); ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &vec4); - auto coord_var = - std::make_unique(std::make_unique( - "coord", ast::StorageClass::kStorageBuffer, &ac)); + auto coord_var = create( + create("coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); - decos.push_back(std::make_unique(1, Source{})); + decos.push_back(create(0, Source{})); + decos.push_back(create(1, Source{})); coord_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(coord_var.get()); @@ -921,38 +869,34 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(std::move(coord_var)); ast::VariableList params; - params.push_back(std::make_unique( - "param", ast::StorageClass::kFunction, &f32)); - auto sub_func = - std::make_unique("sub_func", std::move(params), &f32); + params.push_back( + create("param", ast::StorageClass::kFunction, &f32)); + auto sub_func = create("sub_func", std::move(params), &f32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique( - std::make_unique("coord"), - std::make_unique("x")))); + auto body = create(); + body->append( + create(create( + create("coord"), + create("x")))); sub_func->set_body(std::move(body)); mod.AddFunction(std::move(sub_func)); - auto func = std::make_unique("frag_main", std::move(params), - &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = create("frag_main", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); ast::ExpressionList expr; - expr.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); + expr.push_back(create( + create(&f32, 1.0f))); - auto var = - std::make_unique("v", ast::StorageClass::kFunction, &f32); - var->set_constructor(std::make_unique( - std::make_unique("sub_func"), - std::move(expr))); + auto var = create("v", ast::StorageClass::kFunction, &f32); + var->set_constructor(create( + create("sub_func"), std::move(expr))); - body = std::make_unique(); - body->append(std::make_unique(std::move(var))); - body->append(std::make_unique()); + body = create(); + body->append(create(std::move(var))); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -979,40 +923,38 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32Type f32; ast::type::I32Type i32; - auto bar_var = std::make_unique( - std::make_unique("bar", ast::StorageClass::kOutput, &f32)); + auto bar_var = create( + create("bar", ast::StorageClass::kOutput, &f32)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(1, Source{})); + decos.push_back(create(1, Source{})); bar_var->set_decorations(std::move(decos)); td.RegisterVariableForTesting(bar_var.get()); mod.AddGlobalVariable(std::move(bar_var)); ast::VariableList params; - auto func_1 = - std::make_unique("ep_1", std::move(params), &void_type); - func_1->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func_1 = create("ep_1", std::move(params), &void_type); + func_1->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("bar"), - std::make_unique( - std::make_unique(&f32, 1.0f)))); + auto body = create(); + body->append(create( + create("bar"), + create( + create(&f32, 1.0f)))); - auto list = std::make_unique(); - list->append(std::make_unique()); + auto list = create(); + list->append(create()); - body->append(std::make_unique( - std::make_unique( - ast::BinaryOp::kEqual, - std::make_unique( - std::make_unique(&i32, 1)), - std::make_unique( - std::make_unique(&i32, 1))), + body->append(create( + create(ast::BinaryOp::kEqual, + create( + create(&i32, 1)), + create( + create(&i32, 1))), std::move(list))); - body->append(std::make_unique()); + body->append(create()); func_1->set_body(std::move(body)); mod.AddFunction(std::move(func_1)); @@ -1039,10 +981,10 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_FunctionDecoration_EntryPoint_WithNameCollision) { ast::type::VoidType void_type; - auto func = std::make_unique("GeometryShader", - ast::VariableList{}, &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + auto func = + create("GeometryShader", ast::VariableList{}, &void_type); + func->add_decoration( + create(ast::PipelineStage::kFragment, Source{})); mod.AddFunction(std::move(func)); @@ -1058,13 +1000,12 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::VoidType void_type; ast::VariableList params; - auto func = - std::make_unique("main", std::move(params), &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kCompute, Source{})); + auto func = create("main", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kCompute, Source{})); - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -1084,15 +1025,13 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::VoidType void_type; ast::VariableList params; - auto func = - std::make_unique("main", std::move(params), &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kCompute, Source{})); + auto func = create("main", std::move(params), &void_type); func->add_decoration( - std::make_unique(2u, 4u, 6u, Source{})); + create(ast::PipelineStage::kCompute, Source{})); + func->add_decoration(create(2u, 4u, 6u, Source{})); - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -1112,15 +1051,13 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) { ast::type::ArrayType ary(&f32, 5); ast::VariableList params; - params.push_back( - std::make_unique("a", ast::StorageClass::kNone, &ary)); + params.push_back(create("a", ast::StorageClass::kNone, &ary)); ast::type::VoidType void_type; - auto func = - std::make_unique("my_func", std::move(params), &void_type); + auto func = create("my_func", std::move(params), &void_type); - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -1157,27 +1094,23 @@ TEST_F(HlslGeneratorImplTest_Function, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("d", &f32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("d", &f32, std::move(a_deco))); ast::StructDecorationList s_decos; - s_decos.push_back(std::make_unique(Source{})); + s_decos.push_back(create(Source{})); - auto str = - std::make_unique(std::move(s_decos), std::move(members)); + auto str = create(std::move(s_decos), std::move(members)); ast::type::StructType s("Data", std::move(str)); ast::type::AccessControlType ac(ast::AccessControl::kReadWrite, &s); - auto data_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &ac)); + auto data_var = create( + create("data", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); + decos.push_back(create(0, Source{})); data_var->set_decorations(std::move(decos)); mod.AddConstructedType(&s); @@ -1186,20 +1119,18 @@ TEST_F(HlslGeneratorImplTest_Function, { ast::VariableList params; - auto func = - std::make_unique("a", std::move(params), &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kCompute, Source{})); + auto func = create("a", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kCompute, Source{})); - auto var = std::make_unique( - "v", ast::StorageClass::kFunction, &f32); - var->set_constructor(std::make_unique( - std::make_unique("data"), - std::make_unique("d"))); + auto var = create("v", ast::StorageClass::kFunction, &f32); + var->set_constructor(create( + create("data"), + create("d"))); - auto body = std::make_unique(); - body->append(std::make_unique(std::move(var))); - body->append(std::make_unique()); + auto body = create(); + body->append(create(std::move(var))); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); @@ -1207,20 +1138,18 @@ TEST_F(HlslGeneratorImplTest_Function, { ast::VariableList params; - auto func = - std::make_unique("b", std::move(params), &void_type); - func->add_decoration(std::make_unique( - ast::PipelineStage::kCompute, Source{})); + auto func = create("b", std::move(params), &void_type); + func->add_decoration( + create(ast::PipelineStage::kCompute, Source{})); - auto var = std::make_unique( - "v", ast::StorageClass::kFunction, &f32); - var->set_constructor(std::make_unique( - std::make_unique("data"), - std::make_unique("d"))); + auto var = create("v", ast::StorageClass::kFunction, &f32); + var->set_constructor(create( + create("data"), + create("d"))); - auto body = std::make_unique(); - body->append(std::make_unique(std::move(var))); - body->append(std::make_unique()); + auto body = create(); + body->append(create(std::move(var))); + body->append(create()); func->set_body(std::move(body)); mod.AddFunction(std::move(func)); diff --git a/src/writer/hlsl/generator_impl_if_test.cc b/src/writer/hlsl/generator_impl_if_test.cc index f531cd6220..f1a4277b30 100644 --- a/src/writer/hlsl/generator_impl_if_test.cc +++ b/src/writer/hlsl/generator_impl_if_test.cc @@ -27,9 +27,9 @@ namespace { using HlslGeneratorImplTest_If = TestHelper; TEST_F(HlslGeneratorImplTest_If, Emit_If) { - auto cond = std::make_unique("cond"); - auto body = std::make_unique(); - body->append(std::make_unique()); + auto cond = create("cond"); + auto body = create(); + body->append(create()); ast::IfStatement i(std::move(cond), std::move(body)); gen.increment_indent(); @@ -42,17 +42,17 @@ TEST_F(HlslGeneratorImplTest_If, Emit_If) { } TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElseIf) { - auto else_cond = std::make_unique("else_cond"); - auto else_body = std::make_unique(); - else_body->append(std::make_unique()); + auto else_cond = create("else_cond"); + auto else_body = create(); + else_body->append(create()); ast::ElseStatementList elses; - elses.push_back(std::make_unique(std::move(else_cond), - std::move(else_body))); + elses.push_back( + create(std::move(else_cond), std::move(else_body))); - auto cond = std::make_unique("cond"); - auto body = std::make_unique(); - body->append(std::make_unique()); + auto cond = create("cond"); + auto body = create(); + body->append(create()); ast::IfStatement i(std::move(cond), std::move(body)); i.set_else_statements(std::move(elses)); @@ -71,15 +71,15 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElseIf) { } TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElse) { - auto else_body = std::make_unique(); - else_body->append(std::make_unique()); + auto else_body = create(); + else_body->append(create()); ast::ElseStatementList elses; - elses.push_back(std::make_unique(std::move(else_body))); + elses.push_back(create(std::move(else_body))); - auto cond = std::make_unique("cond"); - auto body = std::make_unique(); - body->append(std::make_unique()); + auto cond = create("cond"); + auto body = create(); + body->append(create()); ast::IfStatement i(std::move(cond), std::move(body)); i.set_else_statements(std::move(elses)); @@ -96,22 +96,22 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElse) { } TEST_F(HlslGeneratorImplTest_If, Emit_IfWithMultiple) { - auto else_cond = std::make_unique("else_cond"); + auto else_cond = create("else_cond"); - auto else_body = std::make_unique(); - else_body->append(std::make_unique()); + auto else_body = create(); + else_body->append(create()); - auto else_body_2 = std::make_unique(); - else_body_2->append(std::make_unique()); + auto else_body_2 = create(); + else_body_2->append(create()); ast::ElseStatementList elses; - elses.push_back(std::make_unique(std::move(else_cond), - std::move(else_body))); - elses.push_back(std::make_unique(std::move(else_body_2))); + elses.push_back( + create(std::move(else_cond), std::move(else_body))); + elses.push_back(create(std::move(else_body_2))); - auto cond = std::make_unique("cond"); - auto body = std::make_unique(); - body->append(std::make_unique()); + auto cond = create("cond"); + auto body = create(); + body->append(create()); ast::IfStatement i(std::move(cond), std::move(body)); i.set_else_statements(std::move(elses)); diff --git a/src/writer/hlsl/generator_impl_import_test.cc b/src/writer/hlsl/generator_impl_import_test.cc index 152a64abf7..7df6c9e55e 100644 --- a/src/writer/hlsl/generator_impl_import_test.cc +++ b/src/writer/hlsl/generator_impl_import_test.cc @@ -54,10 +54,10 @@ TEST_P(HlslImportData_SingleParamTest, FloatScalar) { ast::type::F32Type f32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); + params.push_back(create( + create(&f32, 1.f))); - auto ident = std::make_unique(param.name); + auto ident = create(param.name); ast::CallExpression expr(std::move(ident), std::move(params)); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -99,12 +99,11 @@ TEST_P(HlslImportData_SingleIntParamTest, IntScalar) { ast::type::I32Type i32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&i32, 1))); + params.push_back(create( + create(&i32, 1))); - ast::CallExpression expr( - std::make_unique(param.name), - std::move(params)); + ast::CallExpression expr(create(param.name), + std::move(params)); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error(); @@ -121,14 +120,13 @@ TEST_P(HlslImportData_DualParamTest, FloatScalar) { ast::type::F32Type f32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.f))); + params.push_back(create( + create(&f32, 1.f))); + params.push_back(create( + create(&f32, 2.f))); - ast::CallExpression expr( - std::make_unique(param.name), - std::move(params)); + ast::CallExpression expr(create(param.name), + std::move(params)); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error(); @@ -153,29 +151,28 @@ TEST_P(HlslImportData_DualParam_VectorTest, FloatVector) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList type_params; - type_params.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - type_params.push_back(std::make_unique( - std::make_unique(&f32, 2.f))); - type_params.push_back(std::make_unique( - std::make_unique(&f32, 3.f))); + type_params.push_back(create( + create(&f32, 1.f))); + type_params.push_back(create( + create(&f32, 2.f))); + type_params.push_back(create( + create(&f32, 3.f))); ast::ExpressionList params; - params.push_back(std::make_unique( - &vec, std::move(type_params))); + params.push_back( + create(&vec, std::move(type_params))); - type_params.push_back(std::make_unique( - std::make_unique(&f32, 4.f))); - type_params.push_back(std::make_unique( - std::make_unique(&f32, 5.f))); - type_params.push_back(std::make_unique( - std::make_unique(&f32, 6.f))); - params.push_back(std::make_unique( - &vec, std::move(type_params))); + type_params.push_back(create( + create(&f32, 4.f))); + type_params.push_back(create( + create(&f32, 5.f))); + type_params.push_back(create( + create(&f32, 6.f))); + params.push_back( + create(&vec, std::move(type_params))); - ast::CallExpression expr( - std::make_unique(param.name), - std::move(params)); + ast::CallExpression expr(create(param.name), + std::move(params)); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error(); @@ -195,14 +192,13 @@ TEST_P(HlslImportData_DualParam_Int_Test, IntScalar) { ast::type::I32Type i32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&i32, 1))); - params.push_back(std::make_unique( - std::make_unique(&i32, 2))); + params.push_back(create( + create(&i32, 1))); + params.push_back(create( + create(&i32, 2))); - ast::CallExpression expr( - std::make_unique(param.name), - std::move(params)); + ast::CallExpression expr(create(param.name), + std::move(params)); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error(); @@ -220,16 +216,15 @@ TEST_P(HlslImportData_TripleParamTest, FloatScalar) { ast::type::F32Type f32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.f))); - params.push_back(std::make_unique( - std::make_unique(&f32, 3.f))); + params.push_back(create( + create(&f32, 1.f))); + params.push_back(create( + create(&f32, 2.f))); + params.push_back(create( + create(&f32, 3.f))); - ast::CallExpression expr( - std::make_unique(param.name), - std::move(params)); + ast::CallExpression expr(create(param.name), + std::move(params)); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error(); @@ -255,16 +250,15 @@ TEST_P(HlslImportData_TripleParam_Int_Test, IntScalar) { ast::type::I32Type i32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&i32, 1))); - params.push_back(std::make_unique( - std::make_unique(&i32, 2))); - params.push_back(std::make_unique( - std::make_unique(&i32, 3))); + params.push_back(create( + create(&i32, 1))); + params.push_back(create( + create(&i32, 2))); + params.push_back(create( + create(&i32, 3))); - ast::CallExpression expr( - std::make_unique(param.name), - std::move(params)); + ast::CallExpression expr(create(param.name), + std::move(params)); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ASSERT_TRUE(gen.EmitCall(pre, out, &expr)) << gen.error(); @@ -278,15 +272,13 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_Determinant) { ast::type::F32Type f32; ast::type::MatrixType mat(&f32, 3, 3); - auto var = std::make_unique( - "var", ast::StorageClass::kFunction, &mat); + auto var = create("var", ast::StorageClass::kFunction, &mat); ast::ExpressionList params; - params.push_back(std::make_unique("var")); + params.push_back(create("var")); - ast::CallExpression expr( - std::make_unique("determinant"), - std::move(params)); + ast::CallExpression expr(create("determinant"), + std::move(params)); mod.AddGlobalVariable(std::move(var)); diff --git a/src/writer/hlsl/generator_impl_intrinsic_test.cc b/src/writer/hlsl/generator_impl_intrinsic_test.cc index 37e4eba6cf..6b4a678cd5 100644 --- a/src/writer/hlsl/generator_impl_intrinsic_test.cc +++ b/src/writer/hlsl/generator_impl_intrinsic_test.cc @@ -76,18 +76,15 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, DISABLED_Intrinsic_OuterProduct) { ast::type::VectorType vec2(&f32, 2); ast::type::VectorType vec3(&f32, 3); - auto a = - std::make_unique("a", ast::StorageClass::kNone, &vec2); - auto b = - std::make_unique("b", ast::StorageClass::kNone, &vec3); + auto a = create("a", ast::StorageClass::kNone, &vec2); + auto b = create("b", ast::StorageClass::kNone, &vec3); ast::ExpressionList params; - params.push_back(std::make_unique("a")); - params.push_back(std::make_unique("b")); + params.push_back(create("a")); + params.push_back(create("b")); - ast::CallExpression call( - std::make_unique("outer_product"), - std::move(params)); + ast::CallExpression call(create("outer_product"), + std::move(params)); td.RegisterVariableForTesting(a.get()); td.RegisterVariableForTesting(b.get()); @@ -112,10 +109,10 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Intrinsic_Call) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList params; - params.push_back(std::make_unique("param1")); - params.push_back(std::make_unique("param2")); + params.push_back(create("param1")); + params.push_back(create("param2")); - ast::CallExpression call(std::make_unique("dot"), + ast::CallExpression call(create("dot"), std::move(params)); ast::Variable v1("param1", ast::StorageClass::kFunction, &vec); diff --git a/src/writer/hlsl/generator_impl_loop_test.cc b/src/writer/hlsl/generator_impl_loop_test.cc index 7496064771..7416cd15d5 100644 --- a/src/writer/hlsl/generator_impl_loop_test.cc +++ b/src/writer/hlsl/generator_impl_loop_test.cc @@ -34,8 +34,8 @@ namespace { using HlslGeneratorImplTest_Loop = TestHelper; TEST_F(HlslGeneratorImplTest_Loop, Emit_Loop) { - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); ast::LoopStatement l(std::move(body), {}); gen.increment_indent(); @@ -48,11 +48,11 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_Loop) { } TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) { - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); - auto continuing = std::make_unique(); - continuing->append(std::make_unique()); + auto continuing = create(); + continuing->append(create()); ast::LoopStatement l(std::move(body), std::move(continuing)); gen.increment_indent(); @@ -75,24 +75,24 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) { TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) { ast::type::F32Type f32; - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); - auto continuing = std::make_unique(); - continuing->append(std::make_unique()); + auto continuing = create(); + continuing->append(create()); - auto inner = std::make_unique(std::move(body), - std::move(continuing)); + auto inner = + create(std::move(body), std::move(continuing)); - body = std::make_unique(); + body = create(); body->append(std::move(inner)); - auto lhs = std::make_unique("lhs"); - auto rhs = std::make_unique("rhs"); + auto lhs = create("lhs"); + auto rhs = create("rhs"); - continuing = std::make_unique(); - continuing->append(std::make_unique( - std::move(lhs), std::move(rhs))); + continuing = create(); + continuing->append( + create(std::move(lhs), std::move(rhs))); ast::LoopStatement outer(std::move(body), std::move(continuing)); gen.increment_indent(); @@ -146,23 +146,21 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) { ast::type::F32Type f32; - auto var = std::make_unique( - "lhs", ast::StorageClass::kFunction, &f32); - var->set_constructor(std::make_unique( - std::make_unique(&f32, 2.4))); + auto var = create("lhs", ast::StorageClass::kFunction, &f32); + var->set_constructor(create( + create(&f32, 2.4))); - auto body = std::make_unique(); - body->append(std::make_unique(std::move(var))); - body->append(std::make_unique( - std::make_unique("other", ast::StorageClass::kFunction, - &f32))); + auto body = create(); + body->append(create(std::move(var))); + body->append(create( + create("other", ast::StorageClass::kFunction, &f32))); - auto lhs = std::make_unique("lhs"); - auto rhs = std::make_unique("rhs"); + auto lhs = create("lhs"); + auto rhs = create("rhs"); - auto continuing = std::make_unique(); - continuing->append(std::make_unique( - std::move(lhs), std::move(rhs))); + auto continuing = create(); + continuing->append( + create(std::move(lhs), std::move(rhs))); ast::LoopStatement outer(std::move(body), std::move(continuing)); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc index 57112e87e0..61f1df5cef 100644 --- a/src/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc @@ -51,21 +51,19 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) { ast::StructMemberList members; ast::StructMemberDecorationList deco; - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("mem", &f32, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("mem", &f32, std::move(deco))); - auto strct = std::make_unique(); + auto strct = create(); strct->set_members(std::move(members)); ast::type::StructType s("Str", std::move(strct)); - auto str_var = std::make_unique( - std::make_unique("str", ast::StorageClass::kPrivate, &s)); + auto str_var = create( + create("str", ast::StorageClass::kPrivate, &s)); - auto str = std::make_unique("str"); - auto mem = std::make_unique("mem"); + auto str = create("str"); + auto mem = create("mem"); ast::MemberAccessorExpression expr(std::move(str), std::move(mem)); @@ -93,29 +91,23 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("b", &f32, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("b", &f32, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); - ast::MemberAccessorExpression expr( - std::make_unique("data"), - std::make_unique("b")); + ast::MemberAccessorExpression expr(create("data"), + create("b")); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -143,29 +135,23 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("b", &f32, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("b", &f32, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); - ast::MemberAccessorExpression expr( - std::make_unique("data"), - std::make_unique("a")); + ast::MemberAccessorExpression expr(create("data"), + create("a")); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -196,32 +182,27 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("z", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("z", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("a", &mat, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("a", &mat, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto b_var = - std::make_unique("b", ast::StorageClass::kPrivate, &mat); + auto b_var = create("b", ast::StorageClass::kPrivate, &mat); - auto coord_var = std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s); + auto coord_var = + create("data", ast::StorageClass::kStorageBuffer, &s); - auto lhs = std::make_unique( - std::make_unique("data"), - std::make_unique("a")); - auto rhs = std::make_unique("b"); + auto lhs = create( + create("data"), + create("a")); + auto rhs = create("b"); ast::AssignmentStatement assign(std::move(lhs), std::move(rhs)); @@ -261,31 +242,26 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("z", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("z", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("a", &mat, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("a", &mat, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); - auto lhs = std::make_unique( - std::make_unique("data"), - std::make_unique("a")); - auto rhs = std::make_unique( - &mat, ast::ExpressionList{}); + auto lhs = create( + create("data"), + create("a")); + auto rhs = + create(&mat, ast::ExpressionList{}); ast::AssignmentStatement assign(std::move(lhs), std::move(rhs)); @@ -322,29 +298,23 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("z", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("z", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("a", &mat, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("a", &mat, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); - ast::MemberAccessorExpression expr( - std::make_unique("data"), - std::make_unique("a")); + ast::MemberAccessorExpression expr(create("data"), + create("a")); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -379,29 +349,23 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("z", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("z", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("a", &mat, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("a", &mat, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); - ast::MemberAccessorExpression expr( - std::make_unique("data"), - std::make_unique("a")); + ast::MemberAccessorExpression expr(create("data"), + create("a")); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -433,23 +397,19 @@ TEST_F( ast::StructMemberList members; ast::StructMemberDecorationList deco; - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &mat, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("a", &mat, std::move(deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); - ast::MemberAccessorExpression expr( - std::make_unique("data"), - std::make_unique("a")); + ast::MemberAccessorExpression expr(create("data"), + create("a")); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -480,35 +440,30 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("z", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("z", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(16, Source{})); - members.push_back( - std::make_unique("a", &mat, std::move(b_deco))); + b_deco.push_back(create(16, Source{})); + members.push_back(create("a", &mat, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); ast::ArrayAccessorExpression expr( - std::make_unique( - std::make_unique( - std::make_unique("data"), - std::make_unique("a")), - std::make_unique( - std::make_unique(&i32, 2))), - std::make_unique( - std::make_unique(&i32, 1))); + create( + create( + create("data"), + create("a")), + create( + create(&i32, 2))), + create( + create(&i32, 1))); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -534,31 +489,28 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::I32Type i32; ast::type::ArrayType ary(&i32, 5); ast::ArrayDecorationList decos; - decos.push_back(std::make_unique(4, Source{})); + decos.push_back(create(4, Source{})); ary.set_decorations(std::move(decos)); ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &ary, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &ary, std::move(a_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); ast::ArrayAccessorExpression expr( - std::make_unique( - std::make_unique("data"), - std::make_unique("a")), - std::make_unique( - std::make_unique(&i32, 2))); + create( + create("data"), + create("a")), + create( + create(&i32, 2))); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -584,39 +536,36 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::I32Type i32; ast::type::ArrayType ary(&i32, 5); ast::ArrayDecorationList decos; - decos.push_back(std::make_unique(4, Source{})); + decos.push_back(create(4, Source{})); ary.set_decorations(std::move(decos)); ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &ary, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &ary, std::move(a_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); ast::ArrayAccessorExpression expr( - std::make_unique( - std::make_unique("data"), - std::make_unique("a")), - std::make_unique( + create( + create("data"), + create("a")), + create( ast::BinaryOp::kSubtract, - std::make_unique( + create( ast::BinaryOp::kAdd, - std::make_unique( - std::make_unique(&i32, 2)), - std::make_unique( - std::make_unique(&i32, 4))), - std::make_unique( - std::make_unique(&i32, 3)))); + create( + create(&i32, 2)), + create( + create(&i32, 4))), + create( + create(&i32, 3)))); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -645,25 +594,20 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("b", &f32, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("b", &f32, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -671,11 +615,11 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); - auto lhs = std::make_unique( - std::make_unique("data"), - std::make_unique("b")); - auto rhs = std::make_unique( - std::make_unique(&f32, 2.0f)); + auto lhs = create( + create("data"), + create("b")); + auto rhs = create( + create(&f32, 2.0f)); ast::AssignmentStatement assign(std::move(lhs), std::move(rhs)); ASSERT_TRUE(td.DetermineResultType(&assign)); @@ -698,24 +642,21 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::I32Type i32; ast::type::ArrayType ary(&i32, 5); ast::ArrayDecorationList decos; - decos.push_back(std::make_unique(4, Source{})); + decos.push_back(create(4, Source{})); ary.set_decorations(std::move(decos)); ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &ary, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &ary, std::move(a_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -723,14 +664,14 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); - auto lhs = std::make_unique( - std::make_unique( - std::make_unique("data"), - std::make_unique("a")), - std::make_unique( - std::make_unique(&i32, 2))); - auto rhs = std::make_unique( - std::make_unique(&i32, 2)); + auto lhs = create( + create( + create("data"), + create("a")), + create( + create(&i32, 2))); + auto rhs = create( + create(&i32, 2)); ast::AssignmentStatement assign(std::move(lhs), std::move(rhs)); ASSERT_TRUE(td.DetermineResultType(&assign)) << td.error(); @@ -755,25 +696,20 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &i32, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &i32, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("b", &f32, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("b", &f32, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -781,11 +717,11 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); - auto lhs = std::make_unique( - std::make_unique("data"), - std::make_unique("a")); - auto rhs = std::make_unique( - std::make_unique(&i32, 2)); + auto lhs = create( + create("data"), + create("a")); + auto rhs = create( + create(&i32, 2)); ast::AssignmentStatement assign(std::move(lhs), std::move(rhs)); ASSERT_TRUE(td.DetermineResultType(&assign)); @@ -812,25 +748,20 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &ivec3, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &ivec3, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(16, Source{})); - members.push_back( - std::make_unique("b", &fvec3, std::move(b_deco))); + b_deco.push_back(create(16, Source{})); + members.push_back(create("b", &fvec3, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -838,9 +769,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); - ast::MemberAccessorExpression expr( - std::make_unique("data"), - std::make_unique("b")); + ast::MemberAccessorExpression expr(create("data"), + create("b")); ASSERT_TRUE(td.DetermineResultType(&expr)); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); @@ -865,25 +795,20 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList a_deco; - a_deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &ivec3, std::move(a_deco))); + a_deco.push_back(create(0, Source{})); + members.push_back(create("a", &ivec3, std::move(a_deco))); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(16, Source{})); - members.push_back( - std::make_unique("b", &fvec3, std::move(b_deco))); + b_deco.push_back(create(16, Source{})); + members.push_back(create("b", &fvec3, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("Data", std::move(str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &s)); + auto coord_var = create( + create("data", ast::StorageClass::kStorageBuffer, &s)); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -891,22 +816,18 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); - auto lit1 = std::make_unique(&f32, 1.f); - auto lit2 = std::make_unique(&f32, 2.f); - auto lit3 = std::make_unique(&f32, 3.f); + auto lit1 = create(&f32, 1.f); + auto lit2 = create(&f32, 2.f); + auto lit3 = create(&f32, 3.f); ast::ExpressionList values; - values.push_back( - std::make_unique(std::move(lit1))); - values.push_back( - std::make_unique(std::move(lit2))); - values.push_back( - std::make_unique(std::move(lit3))); + values.push_back(create(std::move(lit1))); + values.push_back(create(std::move(lit2))); + values.push_back(create(std::move(lit3))); - auto lhs = std::make_unique( - std::make_unique("data"), - std::make_unique("b")); - auto rhs = std::make_unique( - &fvec3, std::move(values)); + auto lhs = create( + create("data"), + create("b")); + auto rhs = create(&fvec3, std::move(values)); ast::AssignmentStatement assign(std::move(lhs), std::move(rhs)); @@ -940,39 +861,32 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList deco; - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &ivec3, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("a", &ivec3, std::move(deco))); - deco.push_back( - std::make_unique(16, Source{})); - members.push_back( - std::make_unique("b", &fvec3, std::move(deco))); + deco.push_back(create(16, Source{})); + members.push_back(create("b", &fvec3, std::move(deco))); - auto data_str = std::make_unique(); + auto data_str = create(); data_str->set_members(std::move(members)); ast::type::StructType data("Data", std::move(data_str)); ast::type::ArrayType ary(&data, 4); ast::ArrayDecorationList decos; - decos.push_back(std::make_unique(32, Source{})); + decos.push_back(create(32, Source{})); ary.set_decorations(std::move(decos)); - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("c", &ary, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("c", &ary, std::move(deco))); - auto pre_str = std::make_unique(); + auto pre_str = create(); pre_str->set_members(std::move(members)); ast::type::StructType pre_struct("Pre", std::move(pre_str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + auto coord_var = create(create( + "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -981,13 +895,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); ast::MemberAccessorExpression expr( - std::make_unique( - std::make_unique( - std::make_unique("data"), - std::make_unique("c")), - std::make_unique( - std::make_unique(&i32, 2))), - std::make_unique("b")); + create( + create( + create("data"), + create("c")), + create( + create(&i32, 2))), + create("b")); ASSERT_TRUE(td.DetermineResultType(&expr)); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); @@ -1016,39 +930,32 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList deco; - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &ivec3, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("a", &ivec3, std::move(deco))); - deco.push_back( - std::make_unique(16, Source{})); - members.push_back( - std::make_unique("b", &fvec3, std::move(deco))); + deco.push_back(create(16, Source{})); + members.push_back(create("b", &fvec3, std::move(deco))); - auto data_str = std::make_unique(); + auto data_str = create(); data_str->set_members(std::move(members)); ast::type::StructType data("Data", std::move(data_str)); ast::type::ArrayType ary(&data, 4); ast::ArrayDecorationList decos; - decos.push_back(std::make_unique(32, Source{})); + decos.push_back(create(32, Source{})); ary.set_decorations(std::move(decos)); - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("c", &ary, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("c", &ary, std::move(deco))); - auto pre_str = std::make_unique(); + auto pre_str = create(); pre_str->set_members(std::move(members)); ast::type::StructType pre_struct("Pre", std::move(pre_str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + auto coord_var = create(create( + "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -1057,15 +964,15 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); ast::MemberAccessorExpression expr( - std::make_unique( - std::make_unique( - std::make_unique( - std::make_unique("data"), - std::make_unique("c")), - std::make_unique( - std::make_unique(&i32, 2))), - std::make_unique("b")), - std::make_unique("xy")); + create( + create( + create( + create("data"), + create("c")), + create( + create(&i32, 2))), + create("b")), + create("xy")); ASSERT_TRUE(td.DetermineResultType(&expr)); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); @@ -1095,39 +1002,32 @@ TEST_F( ast::StructMemberList members; ast::StructMemberDecorationList deco; - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &ivec3, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("a", &ivec3, std::move(deco))); - deco.push_back( - std::make_unique(16, Source{})); - members.push_back( - std::make_unique("b", &fvec3, std::move(deco))); + deco.push_back(create(16, Source{})); + members.push_back(create("b", &fvec3, std::move(deco))); - auto data_str = std::make_unique(); + auto data_str = create(); data_str->set_members(std::move(members)); ast::type::StructType data("Data", std::move(data_str)); ast::type::ArrayType ary(&data, 4); ast::ArrayDecorationList decos; - decos.push_back(std::make_unique(32, Source{})); + decos.push_back(create(32, Source{})); ary.set_decorations(std::move(decos)); - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("c", &ary, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("c", &ary, std::move(deco))); - auto pre_str = std::make_unique(); + auto pre_str = create(); pre_str->set_members(std::move(members)); ast::type::StructType pre_struct("Pre", std::move(pre_str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + auto coord_var = create(create( + "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -1136,15 +1036,15 @@ TEST_F( ASSERT_TRUE(td.Determine()) << td.error(); ast::MemberAccessorExpression expr( - std::make_unique( - std::make_unique( - std::make_unique( - std::make_unique("data"), - std::make_unique("c")), - std::make_unique( - std::make_unique(&i32, 2))), - std::make_unique("b")), - std::make_unique("g")); + create( + create( + create( + create("data"), + create("c")), + create( + create(&i32, 2))), + create("b")), + create("g")); ASSERT_TRUE(td.DetermineResultType(&expr)); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); @@ -1173,39 +1073,32 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList deco; - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &ivec3, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("a", &ivec3, std::move(deco))); - deco.push_back( - std::make_unique(16, Source{})); - members.push_back( - std::make_unique("b", &fvec3, std::move(deco))); + deco.push_back(create(16, Source{})); + members.push_back(create("b", &fvec3, std::move(deco))); - auto data_str = std::make_unique(); + auto data_str = create(); data_str->set_members(std::move(members)); ast::type::StructType data("Data", std::move(data_str)); ast::type::ArrayType ary(&data, 4); ast::ArrayDecorationList decos; - decos.push_back(std::make_unique(32, Source{})); + decos.push_back(create(32, Source{})); ary.set_decorations(std::move(decos)); - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("c", &ary, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("c", &ary, std::move(deco))); - auto pre_str = std::make_unique(); + auto pre_str = create(); pre_str->set_members(std::move(members)); ast::type::StructType pre_struct("Pre", std::move(pre_str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + auto coord_var = create(create( + "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -1214,16 +1107,16 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); ast::ArrayAccessorExpression expr( - std::make_unique( - std::make_unique( - std::make_unique( - std::make_unique("data"), - std::make_unique("c")), - std::make_unique( - std::make_unique(&i32, 2))), - std::make_unique("b")), - std::make_unique( - std::make_unique(&i32, 1))); + create( + create( + create( + create("data"), + create("c")), + create( + create(&i32, 2))), + create("b")), + create( + create(&i32, 1))); ASSERT_TRUE(td.DetermineResultType(&expr)); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); @@ -1252,39 +1145,32 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList deco; - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &ivec3, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("a", &ivec3, std::move(deco))); - deco.push_back( - std::make_unique(16, Source{})); - members.push_back( - std::make_unique("b", &fvec3, std::move(deco))); + deco.push_back(create(16, Source{})); + members.push_back(create("b", &fvec3, std::move(deco))); - auto data_str = std::make_unique(); + auto data_str = create(); data_str->set_members(std::move(members)); ast::type::StructType data("Data", std::move(data_str)); ast::type::ArrayType ary(&data, 4); ast::ArrayDecorationList decos; - decos.push_back(std::make_unique(32, Source{})); + decos.push_back(create(32, Source{})); ary.set_decorations(std::move(decos)); - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("c", &ary, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("c", &ary, std::move(deco))); - auto pre_str = std::make_unique(); + auto pre_str = create(); pre_str->set_members(std::move(members)); ast::type::StructType pre_struct("Pre", std::move(pre_str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + auto coord_var = create(create( + "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -1292,28 +1178,24 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); - auto lhs = std::make_unique( - std::make_unique( - std::make_unique( - std::make_unique("data"), - std::make_unique("c")), - std::make_unique( - std::make_unique(&i32, 2))), - std::make_unique("b")); + auto lhs = create( + create( + create( + create("data"), + create("c")), + create( + create(&i32, 2))), + create("b")); - auto lit1 = std::make_unique(&f32, 1.f); - auto lit2 = std::make_unique(&f32, 2.f); - auto lit3 = std::make_unique(&f32, 3.f); + auto lit1 = create(&f32, 1.f); + auto lit2 = create(&f32, 2.f); + auto lit3 = create(&f32, 3.f); ast::ExpressionList values; - values.push_back( - std::make_unique(std::move(lit1))); - values.push_back( - std::make_unique(std::move(lit2))); - values.push_back( - std::make_unique(std::move(lit3))); + values.push_back(create(std::move(lit1))); + values.push_back(create(std::move(lit2))); + values.push_back(create(std::move(lit3))); - auto rhs = std::make_unique( - &fvec3, std::move(values)); + auto rhs = create(&fvec3, std::move(values)); ast::AssignmentStatement assign(std::move(lhs), std::move(rhs)); @@ -1347,39 +1229,32 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList deco; - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("a", &ivec3, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("a", &ivec3, std::move(deco))); - deco.push_back( - std::make_unique(16, Source{})); - members.push_back( - std::make_unique("b", &fvec3, std::move(deco))); + deco.push_back(create(16, Source{})); + members.push_back(create("b", &fvec3, std::move(deco))); - auto data_str = std::make_unique(); + auto data_str = create(); data_str->set_members(std::move(members)); ast::type::StructType data("Data", std::move(data_str)); ast::type::ArrayType ary(&data, 4); ast::ArrayDecorationList decos; - decos.push_back(std::make_unique(32, Source{})); + decos.push_back(create(32, Source{})); ary.set_decorations(std::move(decos)); - deco.push_back( - std::make_unique(0, Source{})); - members.push_back( - std::make_unique("c", &ary, std::move(deco))); + deco.push_back(create(0, Source{})); + members.push_back(create("c", &ary, std::move(deco))); - auto pre_str = std::make_unique(); + auto pre_str = create(); pre_str->set_members(std::move(members)); ast::type::StructType pre_struct("Pre", std::move(pre_str)); - auto coord_var = - std::make_unique(std::make_unique( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + auto coord_var = create(create( + "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var.get()); gen.register_global(coord_var.get()); @@ -1387,19 +1262,19 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); - auto lhs = std::make_unique( - std::make_unique( - std::make_unique( - std::make_unique( - std::make_unique("data"), - std::make_unique("c")), - std::make_unique( - std::make_unique(&i32, 2))), - std::make_unique("b")), - std::make_unique("y")); + auto lhs = create( + create( + create( + create( + create("data"), + create("c")), + create( + create(&i32, 2))), + create("b")), + create("y")); - auto rhs = std::make_unique( - std::make_unique(&i32, 1.f)); + auto rhs = create( + create(&i32, 1.f)); ast::AssignmentStatement assign(std::move(lhs), std::move(rhs)); diff --git a/src/writer/hlsl/generator_impl_module_constant_test.cc b/src/writer/hlsl/generator_impl_module_constant_test.cc index 93dd49c741..f4e2e4326d 100644 --- a/src/writer/hlsl/generator_impl_module_constant_test.cc +++ b/src/writer/hlsl/generator_impl_module_constant_test.cc @@ -38,18 +38,17 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) { ast::type::ArrayType ary(&f32, 3); ast::ExpressionList exprs; - exprs.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - exprs.push_back(std::make_unique( - std::make_unique(&f32, 2.0f))); - exprs.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + exprs.push_back(create( + create(&f32, 1.0f))); + exprs.push_back(create( + create(&f32, 2.0f))); + exprs.push_back(create( + create(&f32, 3.0f))); - auto var = - std::make_unique("pos", ast::StorageClass::kNone, &ary); + auto var = create("pos", ast::StorageClass::kNone, &ary); var->set_is_const(true); var->set_constructor( - std::make_unique(&ary, std::move(exprs))); + create(&ary, std::move(exprs))); ASSERT_TRUE(gen.EmitProgramConstVariable(out, var.get())) << gen.error(); EXPECT_EQ( @@ -61,14 +60,14 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) { ast::type::F32Type f32; ast::VariableDecorationList decos; - decos.push_back(std::make_unique(23, Source{})); + decos.push_back(create(23, Source{})); - auto var = std::make_unique( - std::make_unique("pos", ast::StorageClass::kNone, &f32)); + auto var = create( + create("pos", ast::StorageClass::kNone, &f32)); var->set_decorations(std::move(decos)); var->set_is_const(true); - var->set_constructor(std::make_unique( - std::make_unique(&f32, 3.0f))); + var->set_constructor(create( + create(&f32, 3.0f))); ASSERT_TRUE(gen.EmitProgramConstVariable(out, var.get())) << gen.error(); EXPECT_EQ(result(), R"(#ifndef WGSL_SPEC_CONSTANT_23 @@ -83,10 +82,10 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoConstructor) { ast::type::F32Type f32; ast::VariableDecorationList decos; - decos.push_back(std::make_unique(23, Source{})); + decos.push_back(create(23, Source{})); - auto var = std::make_unique( - std::make_unique("pos", ast::StorageClass::kNone, &f32)); + auto var = create( + create("pos", ast::StorageClass::kNone, &f32)); var->set_decorations(std::move(decos)); var->set_is_const(true); diff --git a/src/writer/hlsl/generator_impl_return_test.cc b/src/writer/hlsl/generator_impl_return_test.cc index ee90420399..7488c3c37e 100644 --- a/src/writer/hlsl/generator_impl_return_test.cc +++ b/src/writer/hlsl/generator_impl_return_test.cc @@ -36,7 +36,7 @@ TEST_F(HlslGeneratorImplTest_Return, Emit_Return) { } TEST_F(HlslGeneratorImplTest_Return, Emit_ReturnWithValue) { - auto expr = std::make_unique("expr"); + auto expr = create("expr"); ast::ReturnStatement r(std::move(expr)); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_switch_test.cc b/src/writer/hlsl/generator_impl_switch_test.cc index 3768c0d844..005f3d3789 100644 --- a/src/writer/hlsl/generator_impl_switch_test.cc +++ b/src/writer/hlsl/generator_impl_switch_test.cc @@ -31,26 +31,26 @@ namespace { using HlslGeneratorImplTest_Switch = TestHelper; TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) { - auto def = std::make_unique(); - auto def_body = std::make_unique(); - def_body->append(std::make_unique()); + auto def = create(); + auto def_body = create(); + def_body->append(create()); def->set_body(std::move(def_body)); ast::type::I32Type i32; ast::CaseSelectorList case_val; - case_val.push_back(std::make_unique(&i32, 5)); + case_val.push_back(create(&i32, 5)); - auto case_body = std::make_unique(); - case_body->append(std::make_unique()); + auto case_body = create(); + case_body->append(create()); - auto case_stmt = std::make_unique(std::move(case_val), - std::move(case_body)); + auto case_stmt = + create(std::move(case_val), std::move(case_body)); ast::CaseStatementList body; body.push_back(std::move(case_stmt)); body.push_back(std::move(def)); - auto cond = std::make_unique("cond"); + auto cond = create("cond"); ast::SwitchStatement s(std::move(cond), std::move(body)); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc index 22a6613103..a92a5ed031 100644 --- a/src/writer/hlsl/generator_impl_test.cc +++ b/src/writer/hlsl/generator_impl_test.cc @@ -29,8 +29,7 @@ using HlslGeneratorImplTest = TestHelper; TEST_F(HlslGeneratorImplTest, Generate) { ast::type::VoidType void_type; - auto func = std::make_unique("my_func", ast::VariableList{}, - &void_type); + auto func = create("my_func", ast::VariableList{}, &void_type); mod.AddFunction(std::move(func)); ASSERT_TRUE(gen.Generate(out)) << gen.error(); diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc index ecab2d432b..2fec741b83 100644 --- a/src/writer/hlsl/generator_impl_type_test.cc +++ b/src/writer/hlsl/generator_impl_type_test.cc @@ -174,16 +174,14 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) { ast::type::F32Type f32; ast::StructMemberList members; - members.push_back(std::make_unique( - "a", &i32, ast::StructMemberDecorationList{})); + members.push_back( + create("a", &i32, ast::StructMemberDecorationList{})); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("b", &f32, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("b", &f32, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("S", std::move(str)); @@ -201,16 +199,14 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) { ast::type::F32Type f32; ast::StructMemberList members; - members.push_back(std::make_unique( - "a", &i32, ast::StructMemberDecorationList{})); + members.push_back( + create("a", &i32, ast::StructMemberDecorationList{})); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("b", &f32, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("b", &f32, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("S", std::move(str)); @@ -224,24 +220,18 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) { ast::type::F32Type f32; ast::StructMemberDecorationList decos; - decos.push_back( - std::make_unique(4, Source{})); + decos.push_back(create(4, Source{})); ast::StructMemberList members; - members.push_back( - std::make_unique("a", &i32, std::move(decos))); + members.push_back(create("a", &i32, std::move(decos))); - decos.push_back( - std::make_unique(32, Source{})); - members.push_back( - std::make_unique("b", &f32, std::move(decos))); + decos.push_back(create(32, Source{})); + members.push_back(create("b", &f32, std::move(decos))); - decos.push_back( - std::make_unique(128, Source{})); - members.push_back( - std::make_unique("c", &f32, std::move(decos))); + decos.push_back(create(128, Source{})); + members.push_back(create("c", &f32, std::move(decos))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("S", std::move(str)); @@ -262,14 +252,14 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) { ast::type::F32Type f32; ast::StructMemberList members; - members.push_back(std::make_unique( + members.push_back(create( "double", &i32, ast::StructMemberDecorationList{})); ast::StructMemberDecorationList b_deco; members.push_back( - std::make_unique("float", &f32, std::move(b_deco))); + create("float", &f32, std::move(b_deco))); - auto str = std::make_unique(); + auto str = create(); str->set_members(std::move(members)); ast::type::StructType s("S", std::move(str)); @@ -288,20 +278,17 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) { ast::type::F32Type f32; ast::StructMemberList members; - members.push_back(std::make_unique( - "a", &i32, ast::StructMemberDecorationList{})); + members.push_back( + create("a", &i32, ast::StructMemberDecorationList{})); ast::StructMemberDecorationList b_deco; - b_deco.push_back( - std::make_unique(4, Source{})); - members.push_back( - std::make_unique("b", &f32, std::move(b_deco))); + b_deco.push_back(create(4, Source{})); + members.push_back(create("b", &f32, std::move(b_deco))); ast::StructDecorationList decos; - decos.push_back(std::make_unique(Source{})); + decos.push_back(create(Source{})); - auto str = - std::make_unique(std::move(decos), std::move(members)); + auto str = create(std::move(decos), std::move(members)); ast::type::StructType s("S", std::move(str)); diff --git a/src/writer/hlsl/generator_impl_unary_op_test.cc b/src/writer/hlsl/generator_impl_unary_op_test.cc index 751e23f8cc..8fbf8261e0 100644 --- a/src/writer/hlsl/generator_impl_unary_op_test.cc +++ b/src/writer/hlsl/generator_impl_unary_op_test.cc @@ -37,7 +37,7 @@ using HlslUnaryOpTest = TestParamHelper; TEST_P(HlslUnaryOpTest, Emit) { auto params = GetParam(); - auto expr = std::make_unique("expr"); + auto expr = create("expr"); ast::UnaryOpExpression op(params.op, std::move(expr)); ASSERT_TRUE(gen.EmitExpression(pre, out, &op)) << gen.error(); diff --git a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc index 81df7648d6..651efd47e5 100644 --- a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc @@ -34,8 +34,7 @@ using HlslGeneratorImplTest_VariableDecl = TestHelper; TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) { ast::type::F32Type f32; - auto var = - std::make_unique("a", ast::StorageClass::kNone, &f32); + auto var = create("a", ast::StorageClass::kNone, &f32); ast::VariableDeclStatement stmt(std::move(var)); gen.increment_indent(); @@ -46,8 +45,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) { TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) { ast::type::F32Type f32; - auto var = - std::make_unique("a", ast::StorageClass::kNone, &f32); + auto var = create("a", ast::StorageClass::kNone, &f32); var->set_is_const(true); ast::VariableDeclStatement stmt(std::move(var)); @@ -61,8 +59,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) { ast::type::F32Type f32; ast::type::ArrayType ary(&f32, 5); - auto var = - std::make_unique("a", ast::StorageClass::kNone, &ary); + auto var = create("a", ast::StorageClass::kNone, &ary); ast::VariableDeclStatement stmt(std::move(var)); gen.increment_indent(); @@ -74,8 +71,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) { TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Function) { ast::type::F32Type f32; - auto var = - std::make_unique("a", ast::StorageClass::kFunction, &f32); + auto var = create("a", ast::StorageClass::kFunction, &f32); ast::VariableDeclStatement stmt(std::move(var)); gen.increment_indent(); @@ -86,8 +82,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) { ast::type::F32Type f32; - auto var = - std::make_unique("a", ast::StorageClass::kPrivate, &f32); + auto var = create("a", ast::StorageClass::kPrivate, &f32); ast::VariableDeclStatement stmt(std::move(var)); gen.increment_indent(); @@ -98,11 +93,10 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) { TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initializer_Private) { - auto ident = std::make_unique("initializer"); + auto ident = create("initializer"); ast::type::F32Type f32; - auto var = - std::make_unique("a", ast::StorageClass::kNone, &f32); + auto var = create("a", ast::StorageClass::kNone, &f32); var->set_constructor(std::move(ident)); ast::VariableDeclStatement stmt(std::move(var)); @@ -118,10 +112,9 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, ast::ExpressionList values; auto zero_vec = - std::make_unique(&vec, std::move(values)); + create(&vec, std::move(values)); - auto var = - std::make_unique("a", ast::StorageClass::kNone, &vec); + auto var = create("a", ast::StorageClass::kNone, &vec); var->set_constructor(std::move(zero_vec)); ast::VariableDeclStatement stmt(std::move(var)); @@ -137,10 +130,9 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, ast::ExpressionList values; auto zero_mat = - std::make_unique(&mat, std::move(values)); + create(&mat, std::move(values)); - auto var = - std::make_unique("a", ast::StorageClass::kNone, &mat); + auto var = create("a", ast::StorageClass::kNone, &mat); var->set_constructor(std::move(zero_mat)); ast::VariableDeclStatement stmt(std::move(var)); diff --git a/src/writer/hlsl/test_helper.h b/src/writer/hlsl/test_helper.h index d83cee102d..121f4979e3 100644 --- a/src/writer/hlsl/test_helper.h +++ b/src/writer/hlsl/test_helper.h @@ -15,8 +15,10 @@ #ifndef SRC_WRITER_HLSL_TEST_HELPER_H_ #define SRC_WRITER_HLSL_TEST_HELPER_H_ +#include #include #include +#include #include "gtest/gtest.h" #include "src/ast/module.h" @@ -29,8 +31,8 @@ namespace writer { namespace hlsl { /// Helper class for testing -template -class TestHelperBase : public T { +template +class TestHelperBase : public BODY { public: TestHelperBase() : td(&ctx, &mod), gen(&ctx, &mod) {} ~TestHelperBase() = default; @@ -41,6 +43,13 @@ class TestHelperBase : public T { /// @returns the pre result string std::string pre_result() const { return pre.str(); } + /// @return a `std::unique_ptr` to a new `T` constructed with `args` + /// @param args the arguments to forward to the constructor for `T` + template + std::unique_ptr create(ARGS&&... args) { + return std::make_unique(std::forward(args)...); + } + /// The context Context ctx; /// The module