From 16b1b9438d91a1b1392c0d94613154d6844cf449 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Sat, 14 Nov 2020 01:09:04 +0000 Subject: [PATCH] writer/spirv tests: Replace std::make_unique -> create create() is currently just a simple forwarder to std::make_unique<>, but will be later replaced with a function that returns a raw pointer, and owned by the context. Bug: tint:322 Change-Id: I5321553847b6a7d47ac211ba093d219c7f3bb9bd Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32673 Commit-Queue: dan sinclair Reviewed-by: dan sinclair --- .../spirv/builder_accessor_expression_test.cc | 281 +++-- src/writer/spirv/builder_assign_test.cc | 109 +- .../spirv/builder_binary_expression_test.cc | 423 +++---- .../spirv/builder_bitcast_expression_test.cc | 12 +- src/writer/spirv/builder_block_test.cc | 36 +- src/writer/spirv/builder_call_test.cc | 52 +- .../builder_constructor_expression_test.cc | 1084 ++++++++--------- .../spirv/builder_function_decoration_test.cc | 78 +- src/writer/spirv/builder_function_test.cc | 80 +- .../spirv/builder_function_variable_test.cc | 49 +- .../spirv/builder_global_variable_test.cc | 145 +-- .../spirv/builder_ident_expression_test.cc | 42 +- src/writer/spirv/builder_if_test.cc | 247 ++-- src/writer/spirv/builder_intrinsic_test.cc | 42 +- src/writer/spirv/builder_loop_test.cc | 53 +- src/writer/spirv/builder_return_test.cc | 18 +- src/writer/spirv/builder_switch_test.cc | 237 ++-- src/writer/spirv/builder_type_test.cc | 92 +- .../spirv/builder_unary_op_expression_test.cc | 26 +- src/writer/spirv/test_helper.h | 14 +- 20 files changed, 1499 insertions(+), 1621 deletions(-) diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc index 4f2dde6efe..f0e5b0bd2f 100644 --- a/src/writer/spirv/builder_accessor_expression_test.cc +++ b/src/writer/spirv/builder_accessor_expression_test.cc @@ -56,9 +56,9 @@ TEST_F(BuilderTest, ArrayAccessor) { ast::Variable var("ary", ast::StorageClass::kFunction, &vec3); - auto ary = std::make_unique("ary"); - auto idx_expr = std::make_unique( - std::make_unique(&i32, 1)); + auto ary = create("ary"); + auto idx_expr = create( + create(&i32, 1)); ast::ArrayAccessorExpression expr(std::move(ary), std::move(idx_expr)); @@ -98,8 +98,8 @@ TEST_F(BuilderTest, Accessor_Array_LoadIndex) { ast::Variable var("ary", ast::StorageClass::kFunction, &vec3); ast::Variable idx("idx", ast::StorageClass::kFunction, &i32); - auto ary = std::make_unique("ary"); - auto idx_expr = std::make_unique("idx"); + auto ary = create("ary"); + auto idx_expr = create("idx"); ast::ArrayAccessorExpression expr(std::move(ary), std::move(idx_expr)); @@ -142,15 +142,15 @@ TEST_F(BuilderTest, ArrayAccessor_Dynamic) { ast::Variable var("ary", ast::StorageClass::kFunction, &vec3); - auto ary = std::make_unique("ary"); + auto ary = create("ary"); ast::ArrayAccessorExpression expr( - std::move(ary), std::make_unique( - ast::BinaryOp::kAdd, - std::make_unique( - std::make_unique(&i32, 1)), - std::make_unique( - std::make_unique(&i32, 2)))); + std::move(ary), + create(ast::BinaryOp::kAdd, + create( + create(&i32, 1)), + create( + create(&i32, 2)))); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -190,12 +190,12 @@ TEST_F(BuilderTest, ArrayAccessor_MultiLevel) { ast::Variable var("ary", ast::StorageClass::kFunction, &ary4); ast::ArrayAccessorExpression expr( - std::make_unique( - std::make_unique("ary"), - std::make_unique( - std::make_unique(&i32, 3))), - std::make_unique( - std::make_unique(&i32, 2))); + create( + create("ary"), + create( + create(&i32, 3))), + create( + create(&i32, 2))); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -237,11 +237,11 @@ TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) { ast::Variable var("ary", ast::StorageClass::kFunction, &ary4); ast::MemberAccessorExpression expr( - std::make_unique( - std::make_unique("ary"), - std::make_unique( - std::make_unique(&i32, 2))), - std::make_unique("xy")); + create( + create("ary"), + create( + create(&i32, 2))), + create("xy")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -284,19 +284,16 @@ TEST_F(BuilderTest, MemberAccessor) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("a", &f32, std::move(decos))); - members.push_back( - std::make_unique("b", &f32, std::move(decos))); + members.push_back(create("a", &f32, std::move(decos))); + members.push_back(create("b", &f32, std::move(decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("my_struct", std::move(s)); ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); - ast::MemberAccessorExpression expr( - std::make_unique("ident"), - std::make_unique("b")); + ast::MemberAccessorExpression expr(create("ident"), + create("b")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -337,27 +334,27 @@ TEST_F(BuilderTest, MemberAccessor_Nested) { ast::StructMemberDecorationList decos; ast::StructMemberList inner_members; inner_members.push_back( - std::make_unique("a", &f32, std::move(decos))); + create("a", &f32, std::move(decos))); inner_members.push_back( - std::make_unique("b", &f32, std::move(decos))); + create("b", &f32, std::move(decos))); ast::type::StructType inner_struct( - "Inner", std::make_unique(std::move(inner_members))); + "Inner", create(std::move(inner_members))); ast::StructMemberList outer_members; - outer_members.push_back(std::make_unique( - "inner", &inner_struct, std::move(decos))); + outer_members.push_back( + create("inner", &inner_struct, std::move(decos))); - ast::type::StructType s_type( - "my_struct", std::make_unique(std::move(outer_members))); + ast::type::StructType s_type("my_struct", + create(std::move(outer_members))); ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); ast::MemberAccessorExpression expr( - std::make_unique( - std::make_unique("ident"), - std::make_unique("inner")), - std::make_unique("a")); + create( + create("ident"), + create("inner")), + create("a")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -400,29 +397,29 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) { ast::StructMemberDecorationList decos; ast::StructMemberList inner_members; inner_members.push_back( - std::make_unique("a", &f32, std::move(decos))); + create("a", &f32, std::move(decos))); inner_members.push_back( - std::make_unique("b", &f32, std::move(decos))); + create("b", &f32, std::move(decos))); ast::type::StructType inner_struct( - "Inner", std::make_unique(std::move(inner_members))); + "Inner", create(std::move(inner_members))); ast::type::AliasType alias("Inner", &inner_struct); ast::StructMemberList outer_members; outer_members.push_back( - std::make_unique("inner", &alias, std::move(decos))); + create("inner", &alias, std::move(decos))); - ast::type::StructType s_type( - "Outer", std::make_unique(std::move(outer_members))); + ast::type::StructType s_type("Outer", + create(std::move(outer_members))); ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); ast::MemberAccessorExpression expr( - std::make_unique( - std::make_unique("ident"), - std::make_unique("inner")), - std::make_unique("a")); + create( + create("ident"), + create("inner")), + create("a")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -465,30 +462,30 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) { ast::StructMemberDecorationList decos; ast::StructMemberList inner_members; inner_members.push_back( - std::make_unique("a", &f32, std::move(decos))); + create("a", &f32, std::move(decos))); inner_members.push_back( - std::make_unique("b", &f32, std::move(decos))); + create("b", &f32, std::move(decos))); ast::type::StructType inner_struct( - "Inner", std::make_unique(std::move(inner_members))); + "Inner", create(std::move(inner_members))); ast::StructMemberList outer_members; - outer_members.push_back(std::make_unique( - "inner", &inner_struct, std::move(decos))); + outer_members.push_back( + create("inner", &inner_struct, std::move(decos))); - ast::type::StructType s_type( - "my_struct", std::make_unique(std::move(outer_members))); + ast::type::StructType s_type("my_struct", + create(std::move(outer_members))); ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); - auto lhs = std::make_unique( - std::make_unique( - std::make_unique("ident"), - std::make_unique("inner")), - std::make_unique("a")); + auto lhs = create( + create( + create("ident"), + create("inner")), + create("a")); - auto rhs = std::make_unique( - std::make_unique(&f32, 2.f)); + auto rhs = create( + create(&f32, 2.f)); ast::AssignmentStatement expr(std::move(lhs), std::move(rhs)); @@ -535,30 +532,30 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) { ast::StructMemberDecorationList decos; ast::StructMemberList inner_members; inner_members.push_back( - std::make_unique("a", &f32, std::move(decos))); + create("a", &f32, std::move(decos))); inner_members.push_back( - std::make_unique("b", &f32, std::move(decos))); + create("b", &f32, std::move(decos))); ast::type::StructType inner_struct( - "Inner", std::make_unique(std::move(inner_members))); + "Inner", create(std::move(inner_members))); ast::StructMemberList outer_members; - outer_members.push_back(std::make_unique( - "inner", &inner_struct, std::move(decos))); + outer_members.push_back( + create("inner", &inner_struct, std::move(decos))); - ast::type::StructType s_type( - "my_struct", std::make_unique(std::move(outer_members))); + ast::type::StructType s_type("my_struct", + create(std::move(outer_members))); ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); ast::Variable store("store", ast::StorageClass::kFunction, &f32); - auto lhs = std::make_unique("store"); + auto lhs = create("store"); - auto rhs = std::make_unique( - std::make_unique( - std::make_unique("ident"), - std::make_unique("inner")), - std::make_unique("a")); + auto rhs = create( + create( + create("ident"), + create("inner")), + create("a")); ast::AssignmentStatement expr(std::move(lhs), std::move(rhs)); @@ -601,9 +598,8 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_Single) { ast::Variable var("ident", ast::StorageClass::kFunction, &vec3); - ast::MemberAccessorExpression expr( - std::make_unique("ident"), - std::make_unique("y")); + ast::MemberAccessorExpression expr(create("ident"), + create("y")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -637,9 +633,8 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_MultipleNames) { ast::Variable var("ident", ast::StorageClass::kFunction, &vec3); - ast::MemberAccessorExpression expr( - std::make_unique("ident"), - std::make_unique("yx")); + ast::MemberAccessorExpression expr(create("ident"), + create("yx")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -673,10 +668,10 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_of_Swizzle) { ast::Variable var("ident", ast::StorageClass::kFunction, &vec3); ast::MemberAccessorExpression expr( - std::make_unique( - std::make_unique("ident"), - std::make_unique("yxz")), - std::make_unique("xz")); + create( + create("ident"), + create("yxz")), + create("xz")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -711,10 +706,10 @@ TEST_F(BuilderTest, MemberAccessor_Member_of_Swizzle) { ast::Variable var("ident", ast::StorageClass::kFunction, &vec3); ast::MemberAccessorExpression expr( - std::make_unique( - std::make_unique("ident"), - std::make_unique("yxz")), - std::make_unique("x")); + create( + create("ident"), + create("yxz")), + create("x")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -749,11 +744,11 @@ TEST_F(BuilderTest, MemberAccessor_Array_of_Swizzle) { ast::Variable var("ident", ast::StorageClass::kFunction, &vec3); ast::ArrayAccessorExpression expr( - std::make_unique( - std::make_unique("ident"), - std::make_unique("yxz")), - std::make_unique( - std::make_unique(&i32, 1))); + create( + create("ident"), + create("yxz")), + create( + create(&i32, 1))); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -799,21 +794,20 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("baz", &vec3, std::move(decos))); - auto s = std::make_unique(std::move(members)); + members.push_back(create("baz", &vec3, std::move(decos))); + auto s = create(std::move(members)); ast::type::StructType c_type("C", std::move(s)); members.push_back( - std::make_unique("bar", &c_type, std::move(decos))); - s = std::make_unique(std::move(members)); + create("bar", &c_type, std::move(decos))); + s = create(std::move(members)); ast::type::StructType b_type("B", std::move(s)); ast::type::ArrayType b_ary_type(&b_type, 3); - members.push_back(std::make_unique("foo", &b_ary_type, - std::move(decos))); - s = std::make_unique(std::move(members)); + members.push_back( + create("foo", &b_ary_type, std::move(decos))); + s = create(std::move(members)); ast::type::StructType a_type("A", std::move(s)); ast::type::ArrayType a_ary_type(&a_type, 2); @@ -821,20 +815,20 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { ast::Variable var("index", ast::StorageClass::kFunction, &a_ary_type); ast::MemberAccessorExpression expr( - std::make_unique( - std::make_unique( - std::make_unique( - std::make_unique( - std::make_unique( - std::make_unique("index"), - std::make_unique( - std::make_unique(&i32, 0))), - std::make_unique("foo")), - std::make_unique( - std::make_unique(&i32, 2))), - std::make_unique("bar")), - std::make_unique("baz")), - std::make_unique("yx")); + create( + create( + create( + create( + create( + create("index"), + create( + create(&i32, 0))), + create("foo")), + create( + create(&i32, 2))), + create("bar")), + create("baz")), + create("yx")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -888,36 +882,35 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) { ast::ExpressionList ary_params; ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 0.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 0.5))); - ary_params.push_back(std::make_unique( - &vec, std::move(vec_params))); + vec_params.push_back(create( + create(&f32, 0.0))); + vec_params.push_back(create( + create(&f32, 0.5))); + ary_params.push_back( + create(&vec, std::move(vec_params))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, -0.5))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, -0.5))); - ary_params.push_back(std::make_unique( - &vec, std::move(vec_params))); + vec_params.push_back(create( + create(&f32, -0.5))); + vec_params.push_back(create( + create(&f32, -0.5))); + ary_params.push_back( + create(&vec, std::move(vec_params))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 0.5))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, -0.5))); - ary_params.push_back(std::make_unique( - &vec, std::move(vec_params))); + vec_params.push_back(create( + create(&f32, 0.5))); + vec_params.push_back(create( + create(&f32, -0.5))); + ary_params.push_back( + create(&vec, std::move(vec_params))); ast::Variable var("pos", ast::StorageClass::kPrivate, &arr); var.set_is_const(true); - var.set_constructor(std::make_unique( - &arr, std::move(ary_params))); + var.set_constructor( + create(&arr, std::move(ary_params))); - ast::ArrayAccessorExpression expr( - std::make_unique("pos"), - std::make_unique( - std::make_unique(&u32, 1))); + ast::ArrayAccessorExpression expr(create("pos"), + create( + create(&u32, 1))); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(var.constructor())) << td.error(); diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc index cf0b0c43a3..58229b0ccc 100644 --- a/src/writer/spirv/builder_assign_test.cc +++ b/src/writer/spirv/builder_assign_test.cc @@ -47,9 +47,9 @@ TEST_F(BuilderTest, Assign_Var) { ast::Variable v("var", ast::StorageClass::kOutput, &f32); - auto ident = std::make_unique("var"); - auto val = std::make_unique( - std::make_unique(&f32, 1.0f)); + auto ident = create("var"); + auto val = create( + create(&f32, 1.0f)); ast::AssignmentStatement assign(std::move(ident), std::move(val)); @@ -81,10 +81,9 @@ TEST_F(BuilderTest, Assign_Var_ZeroConstructor) { ast::Variable v("var", ast::StorageClass::kOutput, &vec); - auto ident = std::make_unique("var"); + auto ident = create("var"); ast::ExpressionList vals; - auto val = - std::make_unique(&vec, std::move(vals)); + auto val = create(&vec, std::move(vals)); ast::AssignmentStatement assign(std::move(ident), std::move(val)); @@ -116,24 +115,22 @@ TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) { ast::type::VectorType vec2(&f32, 2); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 2.0f))); - auto first = - std::make_unique(&vec2, std::move(vals)); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 2.0f))); + auto first = create(&vec2, std::move(vals)); vals.push_back(std::move(first)); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 3.0f))); - auto init = - std::make_unique(&vec3, std::move(vals)); + auto init = create(&vec3, std::move(vals)); ast::Variable v("var", ast::StorageClass::kOutput, &vec3); - ast::AssignmentStatement assign( - std::make_unique("var"), std::move(init)); + ast::AssignmentStatement assign(create("var"), + std::move(init)); td.RegisterVariableForTesting(&v); ASSERT_TRUE(td.DetermineResultType(&assign)) << td.error(); @@ -169,20 +166,19 @@ TEST_F(BuilderTest, Assign_Var_Complex_Constructor) { ast::type::VectorType vec3(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 2.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 2.0f))); + vals.push_back(create( + create(&f32, 3.0f))); - auto init = - std::make_unique(&vec3, std::move(vals)); + auto init = create(&vec3, std::move(vals)); ast::Variable v("var", ast::StorageClass::kOutput, &vec3); - ast::AssignmentStatement assign( - std::make_unique("var"), std::move(init)); + ast::AssignmentStatement assign(create("var"), + std::move(init)); td.RegisterVariableForTesting(&v); ASSERT_TRUE(td.DetermineResultType(&assign)) << td.error(); @@ -220,22 +216,20 @@ TEST_F(BuilderTest, Assign_StructMember) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("a", &f32, std::move(decos))); - members.push_back( - std::make_unique("b", &f32, std::move(decos))); + members.push_back(create("a", &f32, std::move(decos))); + members.push_back(create("b", &f32, std::move(decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("my_struct", std::move(s)); ast::Variable v("ident", ast::StorageClass::kFunction, &s_type); - auto ident = std::make_unique( - std::make_unique("ident"), - std::make_unique("b")); + auto ident = create( + create("ident"), + create("b")); - auto val = std::make_unique( - std::make_unique(&f32, 4.0f)); + auto val = create( + create(&f32, 4.0f)); ast::AssignmentStatement assign(std::move(ident), std::move(val)); @@ -272,18 +266,17 @@ TEST_F(BuilderTest, Assign_Vector) { ast::Variable v("var", ast::StorageClass::kOutput, &vec3); - auto ident = std::make_unique("var"); + auto ident = create("var"); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 3.0f))); - auto val = - std::make_unique(&vec3, std::move(vals)); + auto val = create(&vec3, std::move(vals)); ast::AssignmentStatement assign(std::move(ident), std::move(val)); @@ -320,11 +313,11 @@ TEST_F(BuilderTest, Assign_Vector_MemberByName) { ast::Variable v("var", ast::StorageClass::kOutput, &vec3); - auto ident = std::make_unique( - std::make_unique("var"), - std::make_unique("y")); - auto val = std::make_unique( - std::make_unique(&f32, 1.0f)); + auto ident = create( + create("var"), + create("y")); + auto val = create( + create(&f32, 1.0f)); ast::AssignmentStatement assign(std::move(ident), std::move(val)); @@ -365,12 +358,12 @@ TEST_F(BuilderTest, Assign_Vector_MemberByIndex) { ast::Variable v("var", ast::StorageClass::kOutput, &vec3); - auto ident = std::make_unique( - std::make_unique("var"), - std::make_unique( - std::make_unique(&i32, 1))); - auto val = std::make_unique( - std::make_unique(&f32, 1.0f)); + auto ident = create( + create("var"), + create( + create(&i32, 1))); + auto val = create( + create(&f32, 1.0f)); ast::AssignmentStatement assign(std::move(ident), std::move(val)); diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc index d7e3bbf59d..1b4d2cd1ef 100644 --- a/src/writer/spirv/builder_binary_expression_test.cc +++ b/src/writer/spirv/builder_binary_expression_test.cc @@ -57,10 +57,10 @@ TEST_P(BinaryArithSignedIntegerTest, Scalar) { ast::type::I32Type i32; - auto lhs = std::make_unique( - std::make_unique(&i32, 3)); - auto rhs = std::make_unique( - std::make_unique(&i32, 4)); + auto lhs = create( + create(&i32, 3)); + auto rhs = create( + create(&i32, 4)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -83,23 +83,21 @@ TEST_P(BinaryArithSignedIntegerTest, Vector) { ast::type::VectorType vec3(&i32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - auto lhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); + auto lhs = create(&vec3, std::move(vals)); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - auto rhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); + auto rhs = create(&vec3, std::move(vals)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -123,8 +121,8 @@ TEST_P(BinaryArithSignedIntegerTest, Scalar_Loads) { ast::Variable var("param", ast::StorageClass::kFunction, &i32); - auto lhs = std::make_unique("param"); - auto rhs = std::make_unique("param"); + auto lhs = create("param"); + auto rhs = create("param"); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -171,10 +169,10 @@ TEST_P(BinaryArithUnsignedIntegerTest, Scalar) { ast::type::U32Type u32; - auto lhs = std::make_unique( - std::make_unique(&u32, 3)); - auto rhs = std::make_unique( - std::make_unique(&u32, 4)); + auto lhs = create( + create(&u32, 3)); + auto rhs = create( + create(&u32, 4)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -197,23 +195,21 @@ TEST_P(BinaryArithUnsignedIntegerTest, Vector) { ast::type::VectorType vec3(&u32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - auto lhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&u32, 1))); + vals.push_back(create( + create(&u32, 1))); + vals.push_back(create( + create(&u32, 1))); + auto lhs = create(&vec3, std::move(vals)); - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - auto rhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&u32, 1))); + vals.push_back(create( + create(&u32, 1))); + vals.push_back(create( + create(&u32, 1))); + auto rhs = create(&vec3, std::move(vals)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -251,10 +247,10 @@ TEST_P(BinaryArithFloatTest, Scalar) { ast::type::F32Type f32; - auto lhs = std::make_unique( - std::make_unique(&f32, 3.2f)); - auto rhs = std::make_unique( - std::make_unique(&f32, 4.5f)); + auto lhs = create( + create(&f32, 3.2f)); + auto rhs = create( + create(&f32, 4.5f)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -277,23 +273,21 @@ TEST_P(BinaryArithFloatTest, Vector) { ast::type::VectorType vec3(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - auto lhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + auto lhs = create(&vec3, std::move(vals)); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - auto rhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + auto rhs = create(&vec3, std::move(vals)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -325,10 +319,10 @@ TEST_P(BinaryCompareUnsignedIntegerTest, Scalar) { ast::type::U32Type u32; - auto lhs = std::make_unique( - std::make_unique(&u32, 3)); - auto rhs = std::make_unique( - std::make_unique(&u32, 4)); + auto lhs = create( + create(&u32, 3)); + auto rhs = create( + create(&u32, 4)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -353,23 +347,21 @@ TEST_P(BinaryCompareUnsignedIntegerTest, Vector) { ast::type::VectorType vec3(&u32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - auto lhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&u32, 1))); + vals.push_back(create( + create(&u32, 1))); + vals.push_back(create( + create(&u32, 1))); + auto lhs = create(&vec3, std::move(vals)); - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); - auto rhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&u32, 1))); + vals.push_back(create( + create(&u32, 1))); + vals.push_back(create( + create(&u32, 1))); + auto rhs = create(&vec3, std::move(vals)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -405,10 +397,10 @@ TEST_P(BinaryCompareSignedIntegerTest, Scalar) { ast::type::I32Type i32; - auto lhs = std::make_unique( - std::make_unique(&i32, 3)); - auto rhs = std::make_unique( - std::make_unique(&i32, 4)); + auto lhs = create( + create(&i32, 3)); + auto rhs = create( + create(&i32, 4)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -433,23 +425,21 @@ TEST_P(BinaryCompareSignedIntegerTest, Vector) { ast::type::VectorType vec3(&i32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - auto lhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); + auto lhs = create(&vec3, std::move(vals)); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - auto rhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); + auto rhs = create(&vec3, std::move(vals)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -485,10 +475,10 @@ TEST_P(BinaryCompareFloatTest, Scalar) { ast::type::F32Type f32; - auto lhs = std::make_unique( - std::make_unique(&f32, 3.2f)); - auto rhs = std::make_unique( - std::make_unique(&f32, 4.5f)); + auto lhs = create( + create(&f32, 3.2f)); + auto rhs = create( + create(&f32, 4.5f)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -513,23 +503,21 @@ TEST_P(BinaryCompareFloatTest, Vector) { ast::type::VectorType vec3(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - auto lhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + auto lhs = create(&vec3, std::move(vals)); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - auto rhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + auto rhs = create(&vec3, std::move(vals)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -564,17 +552,16 @@ TEST_F(BuilderTest, Binary_Multiply_VectorScalar) { ast::type::VectorType vec3(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - auto lhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + auto lhs = create(&vec3, std::move(vals)); - auto rhs = std::make_unique( - std::make_unique(&f32, 1.f)); + auto rhs = create( + create(&f32, 1.f)); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, std::move(lhs), std::move(rhs)); @@ -597,18 +584,17 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarVector) { ast::type::F32Type f32; ast::type::VectorType vec3(&f32, 3); - auto lhs = std::make_unique( - std::make_unique(&f32, 1.f)); + auto lhs = create( + create(&f32, 1.f)); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - auto rhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + auto rhs = create(&vec3, std::move(vals)); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, std::move(lhs), std::move(rhs)); @@ -631,11 +617,10 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) { ast::type::F32Type f32; ast::type::MatrixType mat3(&f32, 3, 3); - auto var = std::make_unique( - "mat", ast::StorageClass::kFunction, &mat3); - auto lhs = std::make_unique("mat"); - auto rhs = std::make_unique( - std::make_unique(&f32, 1.f)); + auto var = create("mat", ast::StorageClass::kFunction, &mat3); + auto lhs = create("mat"); + auto rhs = create( + create(&f32, 1.f)); td.RegisterVariableForTesting(var.get()); @@ -665,11 +650,10 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) { ast::type::F32Type f32; ast::type::MatrixType mat3(&f32, 3, 3); - auto var = std::make_unique( - "mat", ast::StorageClass::kFunction, &mat3); - auto lhs = std::make_unique( - std::make_unique(&f32, 1.f)); - auto rhs = std::make_unique("mat"); + auto var = create("mat", ast::StorageClass::kFunction, &mat3); + auto lhs = create( + create(&f32, 1.f)); + auto rhs = create("mat"); td.RegisterVariableForTesting(var.get()); @@ -700,19 +684,17 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixVector) { ast::type::VectorType vec3(&f32, 3); ast::type::MatrixType mat3(&f32, 3, 3); - auto var = std::make_unique( - "mat", ast::StorageClass::kFunction, &mat3); - auto lhs = std::make_unique("mat"); + auto var = create("mat", ast::StorageClass::kFunction, &mat3); + auto lhs = create("mat"); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - auto rhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + auto rhs = create(&vec3, std::move(vals)); td.RegisterVariableForTesting(var.get()); @@ -744,20 +726,18 @@ TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) { ast::type::VectorType vec3(&f32, 3); ast::type::MatrixType mat3(&f32, 3, 3); - auto var = std::make_unique( - "mat", ast::StorageClass::kFunction, &mat3); + auto var = create("mat", ast::StorageClass::kFunction, &mat3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - auto lhs = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + vals.push_back(create( + create(&f32, 1.f))); + auto lhs = create(&vec3, std::move(vals)); - auto rhs = std::make_unique("mat"); + auto rhs = create("mat"); td.RegisterVariableForTesting(var.get()); @@ -789,10 +769,9 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixMatrix) { ast::type::VectorType vec3(&f32, 3); ast::type::MatrixType mat3(&f32, 3, 3); - auto var = std::make_unique( - "mat", ast::StorageClass::kFunction, &mat3); - auto lhs = std::make_unique("mat"); - auto rhs = std::make_unique("mat"); + auto var = create("mat", ast::StorageClass::kFunction, &mat3); + auto lhs = create("mat"); + auto rhs = create("mat"); td.RegisterVariableForTesting(var.get()); @@ -821,19 +800,19 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixMatrix) { TEST_F(BuilderTest, Binary_LogicalAnd) { ast::type::I32Type i32; - auto lhs = std::make_unique( - ast::BinaryOp::kEqual, - std::make_unique( - std::make_unique(&i32, 1)), - std::make_unique( - std::make_unique(&i32, 2))); + auto lhs = + create(ast::BinaryOp::kEqual, + create( + create(&i32, 1)), + create( + create(&i32, 2))); - auto rhs = std::make_unique( - ast::BinaryOp::kEqual, - std::make_unique( - std::make_unique(&i32, 3)), - std::make_unique( - std::make_unique(&i32, 4))); + auto rhs = + create(ast::BinaryOp::kEqual, + create( + create(&i32, 3)), + create( + create(&i32, 4))); ast::BinaryExpression expr(ast::BinaryOp::kLogicalAnd, std::move(lhs), std::move(rhs)); @@ -867,17 +846,17 @@ OpBranch %7 TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) { ast::type::BoolType bool_type; - auto a_var = std::make_unique( - "a", ast::StorageClass::kFunction, &bool_type); - a_var->set_constructor(std::make_unique( - std::make_unique(&bool_type, true))); - auto b_var = std::make_unique( - "b", ast::StorageClass::kFunction, &bool_type); - b_var->set_constructor(std::make_unique( - std::make_unique(&bool_type, false))); + auto a_var = + create("a", ast::StorageClass::kFunction, &bool_type); + a_var->set_constructor(create( + create(&bool_type, true))); + auto b_var = + create("b", ast::StorageClass::kFunction, &bool_type); + b_var->set_constructor(create( + create(&bool_type, false))); - auto lhs = std::make_unique("a"); - auto rhs = std::make_unique("b"); + auto lhs = create("a"); + auto rhs = create("b"); td.RegisterVariableForTesting(a_var.get()); td.RegisterVariableForTesting(b_var.get()); @@ -917,19 +896,19 @@ OpBranch %9 TEST_F(BuilderTest, Binary_LogicalOr) { ast::type::I32Type i32; - auto lhs = std::make_unique( - ast::BinaryOp::kEqual, - std::make_unique( - std::make_unique(&i32, 1)), - std::make_unique( - std::make_unique(&i32, 2))); + auto lhs = + create(ast::BinaryOp::kEqual, + create( + create(&i32, 1)), + create( + create(&i32, 2))); - auto rhs = std::make_unique( - ast::BinaryOp::kEqual, - std::make_unique( - std::make_unique(&i32, 3)), - std::make_unique( - std::make_unique(&i32, 4))); + auto rhs = + create(ast::BinaryOp::kEqual, + create( + create(&i32, 3)), + create( + create(&i32, 4))); ast::BinaryExpression expr(ast::BinaryOp::kLogicalOr, std::move(lhs), std::move(rhs)); @@ -963,17 +942,17 @@ OpBranch %7 TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) { ast::type::BoolType bool_type; - auto a_var = std::make_unique( - "a", ast::StorageClass::kFunction, &bool_type); - a_var->set_constructor(std::make_unique( - std::make_unique(&bool_type, true))); - auto b_var = std::make_unique( - "b", ast::StorageClass::kFunction, &bool_type); - b_var->set_constructor(std::make_unique( - std::make_unique(&bool_type, false))); + auto a_var = + create("a", ast::StorageClass::kFunction, &bool_type); + a_var->set_constructor(create( + create(&bool_type, true))); + auto b_var = + create("b", ast::StorageClass::kFunction, &bool_type); + b_var->set_constructor(create( + create(&bool_type, false))); - auto lhs = std::make_unique("a"); - auto rhs = std::make_unique("b"); + auto lhs = create("a"); + auto rhs = create("b"); td.RegisterVariableForTesting(a_var.get()); td.RegisterVariableForTesting(b_var.get()); diff --git a/src/writer/spirv/builder_bitcast_expression_test.cc b/src/writer/spirv/builder_bitcast_expression_test.cc index bf4003732d..92996ca0f4 100644 --- a/src/writer/spirv/builder_bitcast_expression_test.cc +++ b/src/writer/spirv/builder_bitcast_expression_test.cc @@ -36,9 +36,9 @@ TEST_F(BuilderTest, Bitcast) { ast::type::U32Type u32; ast::type::F32Type f32; - ast::BitcastExpression bitcast( - &u32, std::make_unique( - std::make_unique(&f32, 2.4))); + ast::BitcastExpression bitcast(&u32, + create( + create(&f32, 2.4))); ASSERT_TRUE(td.DetermineResultType(&bitcast)) << td.error(); @@ -57,9 +57,9 @@ TEST_F(BuilderTest, Bitcast) { TEST_F(BuilderTest, Bitcast_DuplicateType) { ast::type::F32Type f32; - ast::BitcastExpression bitcast( - &f32, std::make_unique( - std::make_unique(&f32, 2.4))); + ast::BitcastExpression bitcast(&f32, + create( + create(&f32, 2.4))); ASSERT_TRUE(td.DetermineResultType(&bitcast)) << td.error(); diff --git a/src/writer/spirv/builder_block_test.cc b/src/writer/spirv/builder_block_test.cc index 586357dfc1..505642b4bd 100644 --- a/src/writer/spirv/builder_block_test.cc +++ b/src/writer/spirv/builder_block_test.cc @@ -42,28 +42,26 @@ TEST_F(BuilderTest, Block) { // serves to prove the block code is pushing new scopes as needed. ast::BlockStatement outer; - outer.append(std::make_unique( - std::make_unique("var", ast::StorageClass::kFunction, - &f32))); - outer.append(std::make_unique( - std::make_unique("var"), - std::make_unique( - std::make_unique(&f32, 1.0f)))); + outer.append(create( + create("var", ast::StorageClass::kFunction, &f32))); + outer.append(create( + create("var"), + create( + create(&f32, 1.0f)))); - auto inner = std::make_unique(); - inner->append(std::make_unique( - std::make_unique("var", ast::StorageClass::kFunction, - &f32))); - inner->append(std::make_unique( - std::make_unique("var"), - std::make_unique( - std::make_unique(&f32, 2.0f)))); + auto inner = create(); + inner->append(create( + create("var", ast::StorageClass::kFunction, &f32))); + inner->append(create( + create("var"), + create( + create(&f32, 2.0f)))); outer.append(std::move(inner)); - outer.append(std::make_unique( - std::make_unique("var"), - std::make_unique( - std::make_unique(&f32, 3.0f)))); + outer.append(create( + create("var"), + create( + create(&f32, 3.0f)))); ASSERT_TRUE(td.DetermineResultType(&outer)) << td.error(); diff --git a/src/writer/spirv/builder_call_test.cc b/src/writer/spirv/builder_call_test.cc index 34b02074bd..5bcadc5778 100644 --- a/src/writer/spirv/builder_call_test.cc +++ b/src/writer/spirv/builder_call_test.cc @@ -45,30 +45,28 @@ TEST_F(BuilderTest, Expression_Call) { ast::VariableList func_params; func_params.push_back( - std::make_unique("a", ast::StorageClass::kFunction, &f32)); + create("a", ast::StorageClass::kFunction, &f32)); func_params.push_back( - std::make_unique("b", ast::StorageClass::kFunction, &f32)); + create("b", ast::StorageClass::kFunction, &f32)); ast::Function a_func("a_func", std::move(func_params), &f32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique( - ast::BinaryOp::kAdd, std::make_unique("a"), - std::make_unique("b")))); + auto body = create(); + body->append(create(create( + ast::BinaryOp::kAdd, create("a"), + create("b")))); a_func.set_body(std::move(body)); ast::Function func("main", {}, &void_type); ast::ExpressionList call_params; - call_params.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - call_params.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); + call_params.push_back(create( + create(&f32, 1.f))); + call_params.push_back(create( + create(&f32, 1.f))); - ast::CallExpression expr( - std::make_unique("a_func"), - std::move(call_params)); + ast::CallExpression expr(create("a_func"), + std::move(call_params)); ASSERT_TRUE(td.DetermineFunction(&func)) << td.error(); ASSERT_TRUE(td.DetermineFunction(&a_func)) << td.error(); @@ -109,30 +107,28 @@ TEST_F(BuilderTest, Statement_Call) { ast::VariableList func_params; func_params.push_back( - std::make_unique("a", ast::StorageClass::kFunction, &f32)); + create("a", ast::StorageClass::kFunction, &f32)); func_params.push_back( - std::make_unique("b", ast::StorageClass::kFunction, &f32)); + create("b", ast::StorageClass::kFunction, &f32)); ast::Function a_func("a_func", std::move(func_params), &void_type); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique( - ast::BinaryOp::kAdd, std::make_unique("a"), - std::make_unique("b")))); + auto body = create(); + body->append(create(create( + ast::BinaryOp::kAdd, create("a"), + create("b")))); a_func.set_body(std::move(body)); ast::Function func("main", {}, &void_type); ast::ExpressionList call_params; - call_params.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); - call_params.push_back(std::make_unique( - std::make_unique(&f32, 1.f))); + call_params.push_back(create( + create(&f32, 1.f))); + call_params.push_back(create( + create(&f32, 1.f))); - ast::CallStatement expr(std::make_unique( - std::make_unique("a_func"), - std::move(call_params))); + ast::CallStatement expr(create( + create("a_func"), std::move(call_params))); ASSERT_TRUE(td.DetermineFunction(&func)) << td.error(); ASSERT_TRUE(td.DetermineFunction(&a_func)) << td.error(); diff --git a/src/writer/spirv/builder_constructor_expression_test.cc b/src/writer/spirv/builder_constructor_expression_test.cc index 16554280a7..c94080e17c 100644 --- a/src/writer/spirv/builder_constructor_expression_test.cc +++ b/src/writer/spirv/builder_constructor_expression_test.cc @@ -52,7 +52,7 @@ using BuilderTest = TestHelper; TEST_F(BuilderTest, Constructor_Const) { ast::type::F32Type f32; - auto fl = std::make_unique(&f32, 42.2f); + auto fl = create(&f32, 42.2f); ast::ScalarConstructorExpression c(std::move(fl)); EXPECT_EQ(b.GenerateConstructorExpression(nullptr, &c, true), 2u); @@ -68,12 +68,12 @@ TEST_F(BuilderTest, Constructor_Type) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 3.0f))); ast::TypeConstructorExpression t(&vec, std::move(vals)); @@ -96,16 +96,16 @@ TEST_F(BuilderTest, Constructor_Type_WithCasts) { ast::type::VectorType vec(&f32, 2); ast::ExpressionList type_vals; - type_vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + type_vals.push_back(create( + create(&i32, 1))); ast::ExpressionList vals; - vals.push_back(std::make_unique( + vals.push_back(create( &f32, std::move(type_vals))); - type_vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vals.push_back(std::make_unique( + type_vals.push_back(create( + create(&i32, 1))); + vals.push_back(create( &f32, std::move(type_vals))); ast::TypeConstructorExpression t(&vec, std::move(vals)); @@ -139,8 +139,8 @@ TEST_F(BuilderTest, Constructor_Type_WithAlias) { ast::type::AliasType alias("Int", &i32); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.3))); + params.push_back(create( + create(&f32, 2.3))); ast::TypeConstructorExpression cast(&alias, std::move(params)); @@ -162,13 +162,13 @@ TEST_F(BuilderTest, Constructor_Type_IdentifierExpression_Param) { ast::type::F32Type f32; ast::type::VectorType vec(&f32, 2); - auto var = std::make_unique( + auto var = create( "ident", ast::StorageClass::kFunction, &f32); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique("ident")); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create("ident")); ast::TypeConstructorExpression t(&vec, std::move(vals)); @@ -203,10 +203,10 @@ TEST_F(BuilderTest, Constructor_Vector_Bitcast_Params) { ast::type::VectorType vec(&u32, 2); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); ast::TypeConstructorExpression t(&vec, std::move(vals)); @@ -233,16 +233,16 @@ TEST_F(BuilderTest, Constructor_Vector_Bitcast_Params) { TEST_F(BuilderTest, Constructor_Type_NonConst_Value_Fails) { ast::type::F32Type f32; ast::type::VectorType vec(&f32, 2); - auto rel = std::make_unique( + auto rel = create( ast::BinaryOp::kAdd, - std::make_unique( - std::make_unique(&f32, 3.0f)), - std::make_unique( - std::make_unique(&f32, 3.0f))); + create( + create(&f32, 3.0f)), + create( + create(&f32, 3.0f))); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 1.0f))); vals.push_back(std::move(rel)); ast::TypeConstructorExpression t(&vec, std::move(vals)); @@ -258,8 +258,8 @@ TEST_F(BuilderTest, Constructor_Type_Bool_With_Bool) { ast::type::BoolType bool_type; ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&bool_type, true))); + vals.push_back(create( + create(&bool_type, true))); ast::TypeConstructorExpression t(&bool_type, std::move(vals)); @@ -282,8 +282,8 @@ TEST_F(BuilderTest, Constructor_Type_I32_With_I32) { ast::type::I32Type i32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&i32, 2))); + params.push_back(create( + create(&i32, 2))); ast::TypeConstructorExpression cast(&i32, std::move(params)); @@ -304,8 +304,8 @@ TEST_F(BuilderTest, Constructor_Type_U32_With_U32) { ast::type::U32Type u32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&u32, 2))); + params.push_back(create( + create(&u32, 2))); ast::TypeConstructorExpression cast(&u32, std::move(params)); @@ -326,8 +326,8 @@ TEST_F(BuilderTest, Constructor_Type_F32_With_F32) { ast::type::F32Type f32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&f32, std::move(params)); @@ -349,10 +349,10 @@ TEST_F(BuilderTest, Constructor_Type_Vec2_With_F32_F32) { ast::type::VectorType vec(&f32, 2); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&vec, std::move(params)); @@ -373,12 +373,12 @@ TEST_F(BuilderTest, Constructor_Type_Vec3_With_F32_F32_F32) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&vec, std::move(params)); @@ -400,15 +400,15 @@ TEST_F(BuilderTest, Constructor_Type_Vec3_With_F32_Vec2) { ast::type::VectorType vec3(&f32, 3); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( &vec2, std::move(vec_params))); ast::TypeConstructorExpression cast(&vec3, std::move(params)); @@ -437,16 +437,16 @@ TEST_F(BuilderTest, Constructor_Type_Vec3_With_Vec2_F32) { ast::type::VectorType vec3(&f32, 3); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec2, std::move(vec_params))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&vec3, std::move(params)); @@ -473,14 +473,14 @@ TEST_F(BuilderTest, Constructor_Type_Vec4_With_F32_F32_F32_F32) { ast::type::VectorType vec(&f32, 4); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&vec, std::move(params)); @@ -502,17 +502,17 @@ TEST_F(BuilderTest, Constructor_Type_Vec4_With_F32_F32_Vec2) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( &vec2, std::move(vec_params))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -541,18 +541,18 @@ TEST_F(BuilderTest, Constructor_Type_Vec4_With_F32_Vec2_F32) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( &vec2, std::move(vec_params))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -580,18 +580,18 @@ TEST_F(BuilderTest, Constructor_Type_Vec4_With_Vec2_F32_F32) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec2, std::move(vec_params))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -619,21 +619,21 @@ TEST_F(BuilderTest, Constructor_Type_Vec4_With_Vec2_Vec2) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec2, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec2, std::move(vec2_params))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -664,17 +664,17 @@ TEST_F(BuilderTest, Constructor_Type_Vec4_With_F32_Vec3) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( &vec3, std::move(vec_params))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -704,18 +704,18 @@ TEST_F(BuilderTest, Constructor_Type_Vec4_With_Vec3_F32) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec3, std::move(vec_params))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -744,15 +744,15 @@ TEST_F(BuilderTest, Constructor_Type_ModuleScope_Vec3_With_F32_Vec2) { ast::type::VectorType vec3(&f32, 3); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( &vec2, std::move(vec_params))); ast::TypeConstructorExpression cast(&vec3, std::move(params)); @@ -782,16 +782,16 @@ TEST_F(BuilderTest, Constructor_Type_ModuleScope_Vec3_With_Vec2_F32) { ast::type::VectorType vec3(&f32, 3); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec2, std::move(vec_params))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&vec3, std::move(params)); @@ -820,17 +820,17 @@ TEST_F(BuilderTest, Constructor_Type_ModuleScope_Vec4_With_F32_F32_Vec2) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( &vec2, std::move(vec_params))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -860,18 +860,18 @@ TEST_F(BuilderTest, Constructor_Type_ModuleScope_Vec4_With_F32_Vec2_F32) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( &vec2, std::move(vec_params))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -900,18 +900,18 @@ TEST_F(BuilderTest, Constructor_Type_ModuleScope_Vec4_With_Vec2_F32_F32) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec2, std::move(vec_params))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -940,21 +940,21 @@ TEST_F(BuilderTest, Constructor_Type_ModuleScope_Vec4_With_Vec2_Vec2) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec2, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec2, std::move(vec2_params))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -986,17 +986,17 @@ TEST_F(BuilderTest, Constructor_Type_ModuleScope_Vec4_With_F32_Vec3) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( &vec3, std::move(vec_params))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -1028,18 +1028,18 @@ TEST_F(BuilderTest, Constructor_Type_ModuleScope_Vec4_With_Vec3_F32) { ast::type::VectorType vec4(&f32, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec3, std::move(vec_params))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&vec4, std::move(params)); @@ -1070,21 +1070,21 @@ TEST_F(BuilderTest, Constructor_Type_Mat2x2_With_Vec2_Vec2) { ast::type::MatrixType mat(&f32, 2, 2); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec2_params))); ast::TypeConstructorExpression cast(&mat, std::move(params)); @@ -1109,29 +1109,29 @@ TEST_F(BuilderTest, Constructor_Type_Mat3x2_With_Vec2_Vec2_Vec2) { ast::type::MatrixType mat(&f32, 2, 3); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec3_params; - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec2_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec3_params))); ast::TypeConstructorExpression cast(&mat, std::move(params)); @@ -1156,37 +1156,37 @@ TEST_F(BuilderTest, Constructor_Type_Mat4x2_With_Vec2_Vec2_Vec2_Vec2) { ast::type::MatrixType mat(&f32, 2, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec3_params; - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec4_params; - vec4_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec4_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec4_params.push_back(create( + create(&f32, 2.0))); + vec4_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec2_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec3_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec4_params))); ast::TypeConstructorExpression cast(&mat, std::move(params)); @@ -1211,25 +1211,25 @@ TEST_F(BuilderTest, Constructor_Type_Mat2x3_With_Vec3_Vec3) { ast::type::MatrixType mat(&f32, 3, 2); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec2_params))); ast::TypeConstructorExpression cast(&mat, std::move(params)); @@ -1254,35 +1254,35 @@ TEST_F(BuilderTest, Constructor_Type_Mat3x3_With_Vec3_Vec3_Vec3) { ast::type::MatrixType mat(&f32, 3, 3); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec3_params; - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec2_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec3_params))); ast::TypeConstructorExpression cast(&mat, std::move(params)); @@ -1307,45 +1307,45 @@ TEST_F(BuilderTest, Constructor_Type_Mat4x3_With_Vec3_Vec3_Vec3_Vec3) { ast::type::MatrixType mat(&f32, 3, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec3_params; - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec4_params; - vec4_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec4_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec4_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec4_params.push_back(create( + create(&f32, 2.0))); + vec4_params.push_back(create( + create(&f32, 2.0))); + vec4_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec2_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec3_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec4_params))); ast::TypeConstructorExpression cast(&mat, std::move(params)); @@ -1370,29 +1370,29 @@ TEST_F(BuilderTest, Constructor_Type_Mat2x4_With_Vec4_Vec4) { ast::type::MatrixType mat(&f32, 4, 2); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec2_params))); ast::TypeConstructorExpression cast(&mat, std::move(params)); @@ -1417,41 +1417,41 @@ TEST_F(BuilderTest, Constructor_Type_Mat3x4_With_Vec4_Vec4_Vec4) { ast::type::MatrixType mat(&f32, 4, 3); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec3_params; - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec2_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec3_params))); ast::TypeConstructorExpression cast(&mat, std::move(params)); @@ -1476,53 +1476,53 @@ TEST_F(BuilderTest, Constructor_Type_Mat4x4_With_Vec4_Vec4_Vec4_Vec4) { ast::type::MatrixType mat(&f32, 4, 4); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec3_params; - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec3_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); + vec3_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec4_params; - vec4_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec4_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec4_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec4_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec4_params.push_back(create( + create(&f32, 2.0))); + vec4_params.push_back(create( + create(&f32, 2.0))); + vec4_params.push_back(create( + create(&f32, 2.0))); + vec4_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec2_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec3_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec4_params))); ast::TypeConstructorExpression cast(&mat, std::move(params)); @@ -1546,16 +1546,16 @@ TEST_F(BuilderTest, Constructor_Type_Array_5_F32) { ast::type::ArrayType ary(&f32, 5); ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); + params.push_back(create( + create(&f32, 2.0))); ast::TypeConstructorExpression cast(&ary, std::move(params)); @@ -1579,25 +1579,25 @@ TEST_F(BuilderTest, Constructor_Type_Array_2_Vec3) { ast::type::ArrayType ary(&vec, 2); ast::ExpressionList vec_params; - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList vec2_params; - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec2_params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); + vec2_params.push_back(create( + create(&f32, 2.0))); ast::ExpressionList params; - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec_params))); - params.push_back(std::make_unique( + params.push_back(create( &vec, std::move(vec2_params))); ast::TypeConstructorExpression cast(&ary, std::move(params)); @@ -1625,25 +1625,25 @@ TEST_F(BuilderTest, Constructor_Type_Struct) { ast::StructMemberDecorationList decos; ast::StructMemberList members; members.push_back( - std::make_unique("a", &f32, std::move(decos))); + create("a", &f32, std::move(decos))); members.push_back( - std::make_unique("b", &vec, std::move(decos))); + create("b", &vec, std::move(decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("my_struct", std::move(s)); ast::ExpressionList vec_vals; - vec_vals.push_back(std::make_unique( - std::make_unique(&f32, 2))); - vec_vals.push_back(std::make_unique( - std::make_unique(&f32, 2))); - vec_vals.push_back(std::make_unique( - std::make_unique(&f32, 2))); + vec_vals.push_back(create( + create(&f32, 2))); + vec_vals.push_back(create( + create(&f32, 2))); + vec_vals.push_back(create( + create(&f32, 2))); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 2))); - vals.push_back(std::make_unique( + vals.push_back(create( + create(&f32, 2))); + vals.push_back(create( &vec, std::move(vec_vals))); ast::TypeConstructorExpression t(&s_type, std::move(vals)); @@ -1805,9 +1805,9 @@ TEST_F(BuilderTest, Constructor_Type_ZeroInit_Struct) { ast::StructMemberDecorationList decos; ast::StructMemberList members; members.push_back( - std::make_unique("a", &f32, std::move(decos))); + create("a", &f32, std::move(decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("my_struct", std::move(s)); ast::ExpressionList vals; @@ -1831,8 +1831,8 @@ TEST_F(BuilderTest, Constructor_Type_Convert_U32_To_I32) { ast::type::I32Type i32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&u32, 2))); + params.push_back(create( + create(&u32, 2))); ast::TypeConstructorExpression cast(&i32, std::move(params)); @@ -1855,8 +1855,8 @@ TEST_F(BuilderTest, Constructor_Type_Convert_I32_To_U32) { ast::type::I32Type i32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&i32, 2))); + params.push_back(create( + create(&i32, 2))); ast::TypeConstructorExpression cast(&u32, std::move(params)); @@ -1879,8 +1879,8 @@ TEST_F(BuilderTest, Constructor_Type_Convert_F32_To_I32) { ast::type::F32Type f32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.4))); + params.push_back(create( + create(&f32, 2.4))); ast::TypeConstructorExpression cast(&i32, std::move(params)); @@ -1903,8 +1903,8 @@ TEST_F(BuilderTest, Constructor_Type_Convert_F32_To_U32) { ast::type::F32Type f32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 2.4))); + params.push_back(create( + create(&f32, 2.4))); ast::TypeConstructorExpression cast(&u32, std::move(params)); @@ -1927,8 +1927,8 @@ TEST_F(BuilderTest, Constructor_Type_Convert_I32_To_F32) { ast::type::F32Type f32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&i32, 2))); + params.push_back(create( + create(&i32, 2))); ast::TypeConstructorExpression cast(&f32, std::move(params)); @@ -1951,8 +1951,8 @@ TEST_F(BuilderTest, Constructor_Type_Convert_U32_To_F32) { ast::type::F32Type f32; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&u32, 2))); + params.push_back(create( + create(&u32, 2))); ast::TypeConstructorExpression cast(&f32, std::move(params)); @@ -1977,10 +1977,10 @@ TEST_F(BuilderTest, Constructor_Type_Convert_Vectors_U32_to_I32) { ast::type::VectorType ivec3(&i32, 3); auto var = - std::make_unique("i", ast::StorageClass::kPrivate, &uvec3); + create("i", ast::StorageClass::kPrivate, &uvec3); ast::ExpressionList params; - params.push_back(std::make_unique("i")); + params.push_back(create("i")); ast::TypeConstructorExpression cast(&ivec3, std::move(params)); @@ -2012,10 +2012,10 @@ TEST_F(BuilderTest, Constructor_Type_Convert_Vectors_F32_to_I32) { ast::type::VectorType fvec3(&f32, 3); auto var = - std::make_unique("i", ast::StorageClass::kPrivate, &fvec3); + create("i", ast::StorageClass::kPrivate, &fvec3); ast::ExpressionList params; - params.push_back(std::make_unique("i")); + params.push_back(create("i")); ast::TypeConstructorExpression cast(&ivec3, std::move(params)); @@ -2047,10 +2047,10 @@ TEST_F(BuilderTest, Constructor_Type_Convert_Vectors_I32_to_U32) { ast::type::VectorType ivec3(&i32, 3); auto var = - std::make_unique("i", ast::StorageClass::kPrivate, &ivec3); + create("i", ast::StorageClass::kPrivate, &ivec3); ast::ExpressionList params; - params.push_back(std::make_unique("i")); + params.push_back(create("i")); ast::TypeConstructorExpression cast(&uvec3, std::move(params)); @@ -2082,10 +2082,10 @@ TEST_F(BuilderTest, Constructor_Type_Convert_Vectors_F32_to_U32) { ast::type::VectorType fvec3(&f32, 3); auto var = - std::make_unique("i", ast::StorageClass::kPrivate, &fvec3); + create("i", ast::StorageClass::kPrivate, &fvec3); ast::ExpressionList params; - params.push_back(std::make_unique("i")); + params.push_back(create("i")); ast::TypeConstructorExpression cast(&uvec3, std::move(params)); @@ -2117,10 +2117,10 @@ TEST_F(BuilderTest, Constructor_Type_Convert_Vectors_I32_to_F32) { ast::type::VectorType fvec3(&f32, 3); auto var = - std::make_unique("i", ast::StorageClass::kPrivate, &ivec3); + create("i", ast::StorageClass::kPrivate, &ivec3); ast::ExpressionList params; - params.push_back(std::make_unique("i")); + params.push_back(create("i")); ast::TypeConstructorExpression cast(&fvec3, std::move(params)); @@ -2152,10 +2152,10 @@ TEST_F(BuilderTest, Constructor_Type_Convert_Vectors_U32_to_F32) { ast::type::VectorType fvec3(&f32, 3); auto var = - std::make_unique("i", ast::StorageClass::kPrivate, &uvec3); + create("i", ast::StorageClass::kPrivate, &uvec3); ast::ExpressionList params; - params.push_back(std::make_unique("i")); + params.push_back(create("i")); ast::TypeConstructorExpression cast(&fvec3, std::move(params)); @@ -2186,12 +2186,12 @@ TEST_F(BuilderTest, IsConstructorConst_GlobalVectorWithAllConstConstructors) { ast::type::VectorType vec(&f32, 3); 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::TypeConstructorExpression t(&vec, std::move(params)); ASSERT_TRUE(td.DetermineResultType(&t)) << td.error(); @@ -2206,9 +2206,9 @@ TEST_F(BuilderTest, IsConstructorConst_GlobalVector_WithIdent) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList params; - params.push_back(std::make_unique("a")); - params.push_back(std::make_unique("b")); - params.push_back(std::make_unique("c")); + params.push_back(create("a")); + params.push_back(create("b")); + params.push_back(create("c")); ast::TypeConstructorExpression t(&vec, std::move(params)); ast::Variable var_a("a", ast::StorageClass::kPrivate, &f32); @@ -2233,23 +2233,23 @@ TEST_F(BuilderTest, IsConstructorConst_GlobalArrayWithAllConstConstructors) { ast::type::ArrayType ary(&vec, 2); 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))); auto first = - std::make_unique(&vec, std::move(params)); + create(&vec, std::move(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))); auto second = - std::make_unique(&vec, std::move(params)); + create(&vec, std::move(params)); ast::ExpressionList ary_params; ary_params.push_back(std::move(first)); @@ -2271,14 +2271,14 @@ TEST_F(BuilderTest, ast::ExpressionList vec_params; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&f32, 1.0))); - vec_params.push_back(std::make_unique( + params.push_back(create( + create(&f32, 1.0))); + vec_params.push_back(create( &f32, std::move(params))); - params.push_back(std::make_unique( - std::make_unique(&f32, 2.0))); - vec_params.push_back(std::make_unique( + params.push_back(create( + create(&f32, 2.0))); + vec_params.push_back(create( &f32, std::move(params))); ast::TypeConstructorExpression t(&vec, std::move(vec_params)); @@ -2298,14 +2298,14 @@ TEST_F(BuilderTest, IsConstructorConst_GlobalWithTypeCastConstructor) { ast::ExpressionList vec_params; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vec_params.push_back(std::make_unique( + params.push_back(create( + create(&i32, 1))); + vec_params.push_back(create( &f32, std::move(params))); - params.push_back(std::make_unique( - std::make_unique(&i32, 2))); - vec_params.push_back(std::make_unique( + params.push_back(create( + create(&i32, 2))); + vec_params.push_back(create( &f32, std::move(params))); ast::TypeConstructorExpression t(&vec, std::move(vec_params)); @@ -2322,12 +2322,12 @@ TEST_F(BuilderTest, IsConstructorConst_VectorWithAllConstConstructors) { ast::type::VectorType vec(&f32, 3); 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::TypeConstructorExpression t(&vec, std::move(params)); ASSERT_TRUE(td.DetermineResultType(&t)) << td.error(); @@ -2342,9 +2342,9 @@ TEST_F(BuilderTest, IsConstructorConst_Vector_WithIdent) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList params; - params.push_back(std::make_unique("a")); - params.push_back(std::make_unique("b")); - params.push_back(std::make_unique("c")); + params.push_back(create("a")); + params.push_back(create("b")); + params.push_back(create("c")); ast::TypeConstructorExpression t(&vec, std::move(params)); ast::Variable var_a("a", ast::StorageClass::kPrivate, &f32); @@ -2368,23 +2368,23 @@ TEST_F(BuilderTest, IsConstructorConst_ArrayWithAllConstConstructors) { ast::type::ArrayType ary(&vec, 2); 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))); auto first = - std::make_unique(&vec, std::move(params)); + create(&vec, std::move(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))); auto second = - std::make_unique(&vec, std::move(params)); + create(&vec, std::move(params)); ast::ExpressionList ary_params; ary_params.push_back(std::move(first)); @@ -2406,14 +2406,14 @@ TEST_F(BuilderTest, IsConstructorConst_VectorWith_TypeCastConstConstructors) { ast::ExpressionList vec_params; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vec_params.push_back(std::make_unique( + params.push_back(create( + create(&i32, 1))); + vec_params.push_back(create( &f32, std::move(params))); - params.push_back(std::make_unique( - std::make_unique(&i32, 2))); - vec_params.push_back(std::make_unique( + params.push_back(create( + create(&i32, 2))); + vec_params.push_back(create( &f32, std::move(params))); ast::TypeConstructorExpression t(&vec, std::move(vec_params)); @@ -2433,14 +2433,14 @@ TEST_F(BuilderTest, IsConstructorConst_WithTypeCastConstructor) { ast::ExpressionList vec_params; ast::ExpressionList params; - params.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vec_params.push_back(std::make_unique( + params.push_back(create( + create(&i32, 1))); + vec_params.push_back(create( &f32, std::move(params))); - params.push_back(std::make_unique( - std::make_unique(&i32, 2))); - vec_params.push_back(std::make_unique( + params.push_back(create( + create(&i32, 2))); + vec_params.push_back(create( &f32, std::move(params))); ast::TypeConstructorExpression t(&vec, std::move(vec_params)); @@ -2457,10 +2457,10 @@ TEST_F(BuilderTest, IsConstructorConst_BitCastScalars) { ast::type::VectorType vec(&u32, 2); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); - vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); + vals.push_back(create( + create(&i32, 1))); ast::TypeConstructorExpression t(&vec, std::move(vals)); @@ -2477,25 +2477,25 @@ TEST_F(BuilderTest, IsConstructorConst_Struct) { ast::StructMemberDecorationList decos; ast::StructMemberList members; members.push_back( - std::make_unique("a", &f32, std::move(decos))); + create("a", &f32, std::move(decos))); members.push_back( - std::make_unique("b", &vec, std::move(decos))); + create("b", &vec, std::move(decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("my_struct", std::move(s)); ast::ExpressionList vec_vals; - vec_vals.push_back(std::make_unique( - std::make_unique(&f32, 2))); - vec_vals.push_back(std::make_unique( - std::make_unique(&f32, 2))); - vec_vals.push_back(std::make_unique( - std::make_unique(&f32, 2))); + vec_vals.push_back(create( + create(&f32, 2))); + vec_vals.push_back(create( + create(&f32, 2))); + vec_vals.push_back(create( + create(&f32, 2))); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 2))); - vals.push_back(std::make_unique( + vals.push_back(create( + create(&f32, 2))); + vals.push_back(create( &vec, std::move(vec_vals))); ast::TypeConstructorExpression t(&s_type, std::move(vals)); @@ -2513,24 +2513,24 @@ TEST_F(BuilderTest, IsConstructorConst_Struct_WithIdentSubExpression) { ast::StructMemberDecorationList decos; ast::StructMemberList members; members.push_back( - std::make_unique("a", &f32, std::move(decos))); + create("a", &f32, std::move(decos))); members.push_back( - std::make_unique("b", &vec, std::move(decos))); + create("b", &vec, std::move(decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("my_struct", std::move(s)); ast::ExpressionList vec_vals; - vec_vals.push_back(std::make_unique( - std::make_unique(&f32, 2))); - vec_vals.push_back(std::make_unique("a")); - vec_vals.push_back(std::make_unique( - std::make_unique(&f32, 2))); + vec_vals.push_back(create( + create(&f32, 2))); + vec_vals.push_back(create("a")); + vec_vals.push_back(create( + create(&f32, 2))); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 2))); - vals.push_back(std::make_unique( + vals.push_back(create( + create(&f32, 2))); + vals.push_back(create( &vec, std::move(vec_vals))); ast::TypeConstructorExpression t(&s_type, std::move(vals)); diff --git a/src/writer/spirv/builder_function_decoration_test.cc b/src/writer/spirv/builder_function_decoration_test.cc index b549526ae0..4a22a79a78 100644 --- a/src/writer/spirv/builder_function_decoration_test.cc +++ b/src/writer/spirv/builder_function_decoration_test.cc @@ -43,8 +43,8 @@ TEST_F(BuilderTest, FunctionDecoration_Stage) { ast::type::VoidType void_type; ast::Function func("main", {}, &void_type); - func.add_decoration(std::make_unique( - ast::PipelineStage::kVertex, Source{})); + func.add_decoration( + create(ast::PipelineStage::kVertex, Source{})); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); EXPECT_EQ(DumpInstructions(b.entry_points()), @@ -67,8 +67,7 @@ TEST_P(FunctionDecoration_StageTest, Emit) { ast::type::VoidType void_type; ast::Function func("main", {}, &void_type); - func.add_decoration( - std::make_unique(params.stage, Source{})); + func.add_decoration(create(params.stage, Source{})); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -94,14 +93,13 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUnusedInterfaceIds) { ast::type::VoidType void_type; ast::Function func("main", {}, &void_type); - func.add_decoration(std::make_unique( - ast::PipelineStage::kVertex, Source{})); - auto v_in = - std::make_unique("my_in", ast::StorageClass::kInput, &f32); - auto v_out = std::make_unique( - "my_out", ast::StorageClass::kOutput, &f32); - auto v_wg = std::make_unique( - "my_wg", ast::StorageClass::kWorkgroup, &f32); + func.add_decoration( + create(ast::PipelineStage::kVertex, Source{})); + auto v_in = create("my_in", ast::StorageClass::kInput, &f32); + auto v_out = + create("my_out", ast::StorageClass::kOutput, &f32); + auto v_wg = + create("my_wg", ast::StorageClass::kWorkgroup, &f32); EXPECT_TRUE(b.GenerateGlobalVariable(v_in.get())) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(v_out.get())) << b.error(); @@ -138,28 +136,27 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) { ast::type::VoidType void_type; ast::Function func("main", {}, &void_type); - func.add_decoration(std::make_unique( - ast::PipelineStage::kVertex, Source{})); + func.add_decoration( + create(ast::PipelineStage::kVertex, Source{})); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("my_out"), - std::make_unique("my_in"))); - body->append(std::make_unique( - std::make_unique("my_wg"), - std::make_unique("my_wg"))); + auto body = create(); + body->append(create( + create("my_out"), + create("my_in"))); + body->append(create( + create("my_wg"), + create("my_wg"))); // Add duplicate usages so we show they don't get output multiple times. - body->append(std::make_unique( - std::make_unique("my_out"), - std::make_unique("my_in"))); + body->append(create( + create("my_out"), + create("my_in"))); func.set_body(std::move(body)); - auto v_in = - std::make_unique("my_in", ast::StorageClass::kInput, &f32); - auto v_out = std::make_unique( - "my_out", ast::StorageClass::kOutput, &f32); - auto v_wg = std::make_unique( - "my_wg", ast::StorageClass::kWorkgroup, &f32); + auto v_in = create("my_in", ast::StorageClass::kInput, &f32); + auto v_out = + create("my_out", ast::StorageClass::kOutput, &f32); + auto v_wg = + create("my_wg", ast::StorageClass::kWorkgroup, &f32); td.RegisterVariableForTesting(v_in.get()); td.RegisterVariableForTesting(v_out.get()); @@ -201,8 +198,8 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_Fragment_OriginUpperLeft) { ast::type::VoidType void_type; ast::Function func("main", {}, &void_type); - func.add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + func.add_decoration( + create(ast::PipelineStage::kFragment, Source{})); ASSERT_TRUE(b.GenerateExecutionModes(&func, 3)) << b.error(); EXPECT_EQ(DumpInstructions(b.execution_modes()), @@ -214,8 +211,8 @@ TEST_F(BuilderTest, FunctionDecoration_WorkgroupSize_Default) { ast::type::VoidType void_type; ast::Function func("main", {}, &void_type); - func.add_decoration(std::make_unique( - ast::PipelineStage::kCompute, Source{})); + func.add_decoration( + create(ast::PipelineStage::kCompute, Source{})); ASSERT_TRUE(b.GenerateExecutionModes(&func, 3)) << b.error(); EXPECT_EQ(DumpInstructions(b.execution_modes()), @@ -227,10 +224,9 @@ TEST_F(BuilderTest, FunctionDecoration_WorkgroupSize) { ast::type::VoidType void_type; ast::Function func("main", {}, &void_type); + func.add_decoration(create(2u, 4u, 6u, Source{})); func.add_decoration( - std::make_unique(2u, 4u, 6u, Source{})); - func.add_decoration(std::make_unique( - ast::PipelineStage::kCompute, Source{})); + create(ast::PipelineStage::kCompute, Source{})); ASSERT_TRUE(b.GenerateExecutionModes(&func, 3)) << b.error(); EXPECT_EQ(DumpInstructions(b.execution_modes()), @@ -242,12 +238,12 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_MultipleFragment) { ast::type::VoidType void_type; ast::Function func1("main1", {}, &void_type); - func1.add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + func1.add_decoration( + create(ast::PipelineStage::kFragment, Source{})); ast::Function func2("main2", {}, &void_type); - func2.add_decoration(std::make_unique( - ast::PipelineStage::kFragment, Source{})); + func2.add_decoration( + create(ast::PipelineStage::kFragment, Source{})); ASSERT_TRUE(b.GenerateFunction(&func1)) << b.error(); ASSERT_TRUE(b.GenerateFunction(&func2)) << b.error(); diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc index 98380d5604..e7549f7167 100644 --- a/src/writer/spirv/builder_function_test.cc +++ b/src/writer/spirv/builder_function_test.cc @@ -69,20 +69,18 @@ TEST_F(BuilderTest, Function_WithParams) { ast::type::I32Type i32; ast::VariableList params; - auto var_a = - std::make_unique("a", ast::StorageClass::kFunction, &f32); + auto var_a = create("a", ast::StorageClass::kFunction, &f32); var_a->set_is_const(true); params.push_back(std::move(var_a)); - auto var_b = - std::make_unique("b", ast::StorageClass::kFunction, &i32); + auto var_b = create("b", ast::StorageClass::kFunction, &i32); var_b->set_is_const(true); params.push_back(std::move(var_b)); ast::Function func("a_func", std::move(params), &f32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("a"))); + auto body = create(); + body->append( + create(create("a"))); func.set_body(std::move(body)); td.RegisterVariableForTesting(func.params()[0].get()); @@ -108,8 +106,8 @@ OpFunctionEnd TEST_F(BuilderTest, Function_WithBody) { ast::type::VoidType void_type; - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); ast::Function func("a_func", {}, &void_type); func.set_body(std::move(body)); @@ -169,27 +167,23 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { 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); @@ -199,20 +193,18 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { { 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)); @@ -220,20 +212,18 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { { 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/spirv/builder_function_variable_test.cc b/src/writer/spirv/builder_function_variable_test.cc index b03429d1a9..7702627859 100644 --- a/src/writer/spirv/builder_function_variable_test.cc +++ b/src/writer/spirv/builder_function_variable_test.cc @@ -70,15 +70,14 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 3.0f))); - auto init = - std::make_unique(&vec, std::move(vals)); + auto init = create(&vec, std::move(vals)); EXPECT_TRUE(td.DetermineResultType(init.get())) << td.error(); @@ -112,20 +111,19 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) { ast::type::F32Type f32; ast::type::VectorType vec(&f32, 2); - auto rel = std::make_unique( - ast::BinaryOp::kAdd, - std::make_unique( - std::make_unique(&f32, 3.0f)), - std::make_unique( - std::make_unique(&f32, 3.0f))); + auto rel = + create(ast::BinaryOp::kAdd, + create( + create(&f32, 3.0f)), + create( + create(&f32, 3.0f))); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 1.0f))); vals.push_back(std::move(rel)); - auto init = - std::make_unique(&vec, std::move(vals)); + auto init = create(&vec, std::move(vals)); EXPECT_TRUE(td.DetermineResultType(init.get())) << td.error(); @@ -170,15 +168,14 @@ TEST_F(BuilderTest, FunctionVar_Const) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 3.0f))); - auto init = - std::make_unique(&vec, std::move(vals)); + auto init = create(&vec, std::move(vals)); EXPECT_TRUE(td.DetermineResultType(init.get())) << td.error(); diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc index 288deedbde..ff044d550b 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -97,15 +97,14 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 3.0f))); - auto init = - std::make_unique(&vec, std::move(vals)); + auto init = create(&vec, std::move(vals)); EXPECT_TRUE(td.DetermineResultType(init.get())) << td.error(); @@ -133,15 +132,14 @@ TEST_F(BuilderTest, GlobalVar_Const) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 3.0f))); - auto init = - std::make_unique(&vec, std::move(vals)); + auto init = create(&vec, std::move(vals)); EXPECT_TRUE(td.DetermineResultType(init.get())) << td.error(); @@ -168,14 +166,13 @@ TEST_F(BuilderTest, GlobalVar_Complex_Constructor) { ast::type::VectorType vec3(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 2.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); - auto init = - std::make_unique(&vec3, std::move(vals)); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 2.0f))); + vals.push_back(create( + create(&f32, 3.0f))); + auto init = create(&vec3, std::move(vals)); EXPECT_TRUE(td.DetermineResultType(init.get())) << td.error(); @@ -202,19 +199,17 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) { ast::type::VectorType vec2(&f32, 2); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 2.0f))); - auto first = - std::make_unique(&vec2, std::move(vals)); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 2.0f))); + auto first = create(&vec2, std::move(vals)); vals.push_back(std::move(first)); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 3.0f))); - auto init = - std::make_unique(&vec3, std::move(vals)); + auto init = create(&vec3, std::move(vals)); EXPECT_TRUE(td.DetermineResultType(init.get())) << td.error(); @@ -244,10 +239,9 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) { TEST_F(BuilderTest, GlobalVar_WithLocation) { ast::type::F32Type f32; - auto v = - std::make_unique("var", ast::StorageClass::kOutput, &f32); + auto v = create("var", ast::StorageClass::kOutput, &f32); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(5, Source{})); + decos.push_back(create(5, Source{})); ast::DecoratedVariable dv(std::move(v)); dv.set_decorations(std::move(decos)); @@ -266,11 +260,10 @@ TEST_F(BuilderTest, GlobalVar_WithLocation) { TEST_F(BuilderTest, GlobalVar_WithBindingAndSet) { ast::type::F32Type f32; - auto v = - std::make_unique("var", ast::StorageClass::kOutput, &f32); + auto v = create("var", ast::StorageClass::kOutput, &f32); ast::VariableDecorationList decos; - decos.push_back(std::make_unique(2, Source{})); - decos.push_back(std::make_unique(3, Source{})); + decos.push_back(create(2, Source{})); + decos.push_back(create(3, Source{})); ast::DecoratedVariable dv(std::move(v)); dv.set_decorations(std::move(decos)); @@ -290,11 +283,10 @@ OpDecorate %1 DescriptorSet 3 TEST_F(BuilderTest, GlobalVar_WithBuiltin) { ast::type::F32Type f32; - auto v = - std::make_unique("var", ast::StorageClass::kOutput, &f32); + auto v = create("var", ast::StorageClass::kOutput, &f32); ast::VariableDecorationList decos; - decos.push_back(std::make_unique( - ast::Builtin::kPosition, Source{})); + decos.push_back( + create(ast::Builtin::kPosition, Source{})); ast::DecoratedVariable dv(std::move(v)); dv.set_decorations(std::move(decos)); @@ -315,13 +307,13 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) { ast::type::BoolType bool_type; ast::VariableDecorationList decos; - decos.push_back(std::make_unique(1200, Source{})); + decos.push_back(create(1200, Source{})); - ast::DecoratedVariable v(std::make_unique( - "var", ast::StorageClass::kNone, &bool_type)); + ast::DecoratedVariable v( + create("var", ast::StorageClass::kNone, &bool_type)); v.set_decorations(std::move(decos)); - v.set_constructor(std::make_unique( - std::make_unique(&bool_type, true))); + v.set_constructor(create( + create(&bool_type, true))); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_766172" @@ -339,10 +331,10 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) { ast::type::BoolType bool_type; ast::VariableDecorationList decos; - decos.push_back(std::make_unique(1200, Source{})); + decos.push_back(create(1200, Source{})); - ast::DecoratedVariable v(std::make_unique( - "var", ast::StorageClass::kNone, &bool_type)); + ast::DecoratedVariable v( + create("var", ast::StorageClass::kNone, &bool_type)); v.set_decorations(std::move(decos)); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); @@ -361,13 +353,13 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) { ast::type::F32Type f32; ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); ast::DecoratedVariable v( - std::make_unique("var", ast::StorageClass::kNone, &f32)); + create("var", ast::StorageClass::kNone, &f32)); v.set_decorations(std::move(decos)); - v.set_constructor(std::make_unique( - std::make_unique(&f32, 2.0))); + v.set_constructor(create( + create(&f32, 2.0))); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %3 "tint_766172" @@ -385,10 +377,10 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) { ast::type::F32Type f32; ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); ast::DecoratedVariable v( - std::make_unique("var", ast::StorageClass::kNone, &f32)); + create("var", ast::StorageClass::kNone, &f32)); v.set_decorations(std::move(decos)); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); @@ -407,10 +399,10 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) { ast::type::I32Type i32; ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); ast::DecoratedVariable v( - std::make_unique("var", ast::StorageClass::kNone, &i32)); + create("var", ast::StorageClass::kNone, &i32)); v.set_decorations(std::move(decos)); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); @@ -429,10 +421,10 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_U32_NoConstructor) { ast::type::U32Type u32; ast::VariableDecorationList decos; - decos.push_back(std::make_unique(0, Source{})); + decos.push_back(create(0, Source{})); ast::DecoratedVariable v( - std::make_unique("var", ast::StorageClass::kNone, &u32)); + create("var", ast::StorageClass::kNone, &u32)); v.set_decorations(std::move(decos)); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); @@ -491,13 +483,10 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("a", &i32, std::move(decos))); - members.push_back( - std::make_unique("b", &i32, std::move(decos))); + members.push_back(create("a", &i32, std::move(decos))); + members.push_back(create("b", &i32, std::move(decos))); - ast::type::StructType A("A", - std::make_unique(std::move(members))); + ast::type::StructType A("A", create(std::move(members))); ast::type::AccessControlType ac{ast::AccessControl::kReadOnly, &A}; ast::Variable var("b", ast::StorageClass::kStorageBuffer, &ac); @@ -530,11 +519,9 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("a", &i32, std::move(decos))); + members.push_back(create("a", &i32, std::move(decos))); - ast::type::StructType A("A", - std::make_unique(std::move(members))); + ast::type::StructType A("A", create(std::move(members))); ast::type::AliasType B("B", &A); ast::type::AccessControlType ac{ast::AccessControl::kReadOnly, &B}; @@ -566,11 +553,9 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("a", &i32, std::move(decos))); + members.push_back(create("a", &i32, std::move(decos))); - ast::type::StructType A("A", - std::make_unique(std::move(members))); + ast::type::StructType A("A", create(std::move(members))); ast::type::AccessControlType ac{ast::AccessControl::kReadOnly, &A}; ast::type::AliasType B("B", &ac); @@ -602,11 +587,9 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("a", &i32, std::move(decos))); + members.push_back(create("a", &i32, std::move(decos))); - ast::type::StructType A("A", - std::make_unique(std::move(members))); + ast::type::StructType A("A", create(std::move(members))); ast::type::AccessControlType read{ast::AccessControl::kReadOnly, &A}; ast::type::AccessControlType rw{ast::AccessControl::kReadWrite, &A}; diff --git a/src/writer/spirv/builder_ident_expression_test.cc b/src/writer/spirv/builder_ident_expression_test.cc index ee2939bc43..801418359e 100644 --- a/src/writer/spirv/builder_ident_expression_test.cc +++ b/src/writer/spirv/builder_ident_expression_test.cc @@ -43,15 +43,14 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 3.0f))); - auto init = - std::make_unique(&vec, std::move(vals)); + auto init = create(&vec, std::move(vals)); EXPECT_TRUE(td.DetermineResultType(init.get())) << td.error(); @@ -103,15 +102,14 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 3.0f))); - auto init = - std::make_unique(&vec, std::move(vals)); + auto init = create(&vec, std::move(vals)); EXPECT_TRUE(td.DetermineResultType(init.get())) << td.error(); @@ -167,8 +165,8 @@ TEST_F(BuilderTest, IdentifierExpression_Load) { td.RegisterVariableForTesting(&var); - auto lhs = std::make_unique("var"); - auto rhs = std::make_unique("var"); + auto lhs = create("var"); + auto rhs = create("var"); ast::BinaryExpression expr(ast::BinaryOp::kAdd, std::move(lhs), std::move(rhs)); @@ -195,14 +193,14 @@ TEST_F(BuilderTest, IdentifierExpression_NoLoadConst) { ast::type::I32Type i32; ast::Variable var("var", ast::StorageClass::kNone, &i32); - var.set_constructor(std::make_unique( - std::make_unique(&i32, 2))); + var.set_constructor(create( + create(&i32, 2))); var.set_is_const(true); td.RegisterVariableForTesting(&var); - auto lhs = std::make_unique("var"); - auto rhs = std::make_unique("var"); + auto lhs = create("var"); + auto rhs = create("var"); ast::BinaryExpression expr(ast::BinaryOp::kAdd, std::move(lhs), std::move(rhs)); diff --git a/src/writer/spirv/builder_if_test.cc b/src/writer/spirv/builder_if_test.cc index ae8548618c..e86a6ac4fd 100644 --- a/src/writer/spirv/builder_if_test.cc +++ b/src/writer/spirv/builder_if_test.cc @@ -46,11 +46,10 @@ TEST_F(BuilderTest, If_Empty) { // if (true) { // } - auto cond = std::make_unique( - std::make_unique(&bool_type, true)); + auto cond = create( + create(&bool_type, true)); - ast::IfStatement expr(std::move(cond), - std::make_unique()); + ast::IfStatement expr(std::move(cond), create()); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -76,17 +75,16 @@ TEST_F(BuilderTest, If_WithStatements) { // if (true) { // v = 2; // } - auto var = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); + auto var = create("v", ast::StorageClass::kPrivate, &i32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 2)))); + auto body = create(); + body->append( + create(create("v"), + create( + create(&i32, 2)))); - auto cond = std::make_unique( - std::make_unique(&bool_type, true)); + auto cond = create( + create(&bool_type, true)); ast::IfStatement expr(std::move(cond), std::move(body)); @@ -124,27 +122,25 @@ TEST_F(BuilderTest, If_WithElse) { // } else { // v = 3; // } - auto var = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); + auto var = create("v", ast::StorageClass::kPrivate, &i32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 2)))); + auto body = create(); + body->append( + create(create("v"), + create( + create(&i32, 2)))); - auto else_body = std::make_unique(); - else_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 3)))); + auto else_body = create(); + else_body->append( + create(create("v"), + create( + create(&i32, 3)))); ast::ElseStatementList else_stmts; - else_stmts.push_back( - std::make_unique(std::move(else_body))); + else_stmts.push_back(create(std::move(else_body))); - auto cond = std::make_unique( - std::make_unique(&bool_type, true)); + auto cond = create( + create(&bool_type, true)); ast::IfStatement expr(std::move(cond), std::move(body)); expr.set_else_statements(std::move(else_stmts)); @@ -188,30 +184,29 @@ TEST_F(BuilderTest, If_WithElseIf) { // } elseif (true) { // v = 3; // } - auto var = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); + auto var = create("v", ast::StorageClass::kPrivate, &i32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 2)))); + auto body = create(); + body->append( + create(create("v"), + create( + create(&i32, 2)))); - auto else_body = std::make_unique(); - else_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 3)))); + auto else_body = create(); + else_body->append( + create(create("v"), + create( + create(&i32, 3)))); - auto else_cond = std::make_unique( - std::make_unique(&bool_type, true)); + auto else_cond = create( + create(&bool_type, true)); ast::ElseStatementList else_stmts; - else_stmts.push_back(std::make_unique( - std::move(else_cond), std::move(else_body))); + else_stmts.push_back( + create(std::move(else_cond), std::move(else_body))); - auto cond = std::make_unique( - std::make_unique(&bool_type, true)); + auto cond = create( + create(&bool_type, true)); ast::IfStatement expr(std::move(cond), std::move(body)); expr.set_else_statements(std::move(else_stmts)); @@ -264,45 +259,43 @@ TEST_F(BuilderTest, If_WithMultiple) { // } else { // v = 5; // } - auto var = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); + auto var = create("v", ast::StorageClass::kPrivate, &i32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 2)))); - auto elseif_1_body = std::make_unique(); - elseif_1_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 3)))); - auto elseif_2_body = std::make_unique(); - elseif_2_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 4)))); - auto else_body = std::make_unique(); - else_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 5)))); + auto body = create(); + body->append( + create(create("v"), + create( + create(&i32, 2)))); + auto elseif_1_body = create(); + elseif_1_body->append( + create(create("v"), + create( + create(&i32, 3)))); + auto elseif_2_body = create(); + elseif_2_body->append( + create(create("v"), + create( + create(&i32, 4)))); + auto else_body = create(); + else_body->append( + create(create("v"), + create( + create(&i32, 5)))); - auto elseif_1_cond = std::make_unique( - std::make_unique(&bool_type, true)); - auto elseif_2_cond = std::make_unique( - std::make_unique(&bool_type, false)); + auto elseif_1_cond = create( + create(&bool_type, true)); + auto elseif_2_cond = create( + create(&bool_type, false)); ast::ElseStatementList else_stmts; - else_stmts.push_back(std::make_unique( - std::move(elseif_1_cond), std::move(elseif_1_body))); - else_stmts.push_back(std::make_unique( - std::move(elseif_2_cond), std::move(elseif_2_body))); - else_stmts.push_back( - std::make_unique(std::move(else_body))); + else_stmts.push_back(create(std::move(elseif_1_cond), + std::move(elseif_1_body))); + else_stmts.push_back(create(std::move(elseif_2_cond), + std::move(elseif_2_body))); + else_stmts.push_back(create(std::move(else_body))); - auto cond = std::make_unique( - std::make_unique(&bool_type, true)); + auto cond = create( + create(&bool_type, true)); ast::IfStatement expr(std::move(cond), std::move(body)); expr.set_else_statements(std::move(else_stmts)); @@ -363,20 +356,18 @@ TEST_F(BuilderTest, If_WithBreak) { // break; // } // } - auto cond = std::make_unique( - std::make_unique(&bool_type, true)); + auto cond = create( + create(&bool_type, true)); - auto if_body = std::make_unique(); - if_body->append(std::make_unique()); + auto if_body = create(); + if_body->append(create()); - auto if_stmt = - std::make_unique(std::move(cond), std::move(if_body)); + auto if_stmt = create(std::move(cond), std::move(if_body)); - auto loop_body = std::make_unique(); + auto loop_body = create(); loop_body->append(std::move(if_stmt)); - ast::LoopStatement expr(std::move(loop_body), - std::make_unique()); + ast::LoopStatement expr(std::move(loop_body), create()); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -412,25 +403,23 @@ TEST_F(BuilderTest, If_WithElseBreak) { // break; // } // } - auto cond = std::make_unique( - std::make_unique(&bool_type, true)); + auto cond = create( + create(&bool_type, true)); - auto else_body = std::make_unique(); - else_body->append(std::make_unique()); + auto else_body = create(); + else_body->append(create()); ast::ElseStatementList else_stmts; - else_stmts.push_back( - std::make_unique(std::move(else_body))); + else_stmts.push_back(create(std::move(else_body))); - auto if_stmt = std::make_unique( - std::move(cond), std::make_unique()); + auto if_stmt = + create(std::move(cond), create()); if_stmt->set_else_statements(std::move(else_stmts)); - auto loop_body = std::make_unique(); + auto loop_body = create(); loop_body->append(std::move(if_stmt)); - ast::LoopStatement expr(std::move(loop_body), - std::make_unique()); + ast::LoopStatement expr(std::move(loop_body), create()); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -467,20 +456,18 @@ TEST_F(BuilderTest, If_WithContinue) { // continue; // } // } - auto cond = std::make_unique( - std::make_unique(&bool_type, true)); + auto cond = create( + create(&bool_type, true)); - auto if_body = std::make_unique(); - if_body->append(std::make_unique()); + auto if_body = create(); + if_body->append(create()); - auto if_stmt = - std::make_unique(std::move(cond), std::move(if_body)); + auto if_stmt = create(std::move(cond), std::move(if_body)); - auto loop_body = std::make_unique(); + auto loop_body = create(); loop_body->append(std::move(if_stmt)); - ast::LoopStatement expr(std::move(loop_body), - std::make_unique()); + ast::LoopStatement expr(std::move(loop_body), create()); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -516,25 +503,23 @@ TEST_F(BuilderTest, If_WithElseContinue) { // continue; // } // } - auto cond = std::make_unique( - std::make_unique(&bool_type, true)); + auto cond = create( + create(&bool_type, true)); - auto else_body = std::make_unique(); - else_body->append(std::make_unique()); + auto else_body = create(); + else_body->append(create()); ast::ElseStatementList else_stmts; - else_stmts.push_back( - std::make_unique(std::move(else_body))); + else_stmts.push_back(create(std::move(else_body))); - auto if_stmt = std::make_unique( - std::move(cond), std::make_unique()); + auto if_stmt = + create(std::move(cond), create()); if_stmt->set_else_statements(std::move(else_stmts)); - auto loop_body = std::make_unique(); + auto loop_body = create(); loop_body->append(std::move(if_stmt)); - ast::LoopStatement expr(std::move(loop_body), - std::make_unique()); + ast::LoopStatement expr(std::move(loop_body), create()); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -569,11 +554,11 @@ TEST_F(BuilderTest, If_WithReturn) { // if (true) { // return; // } - auto cond = std::make_unique( - std::make_unique(&bool_type, true)); + auto cond = create( + create(&bool_type, true)); - auto if_body = std::make_unique(); - if_body->append(std::make_unique()); + auto if_body = create(); + if_body->append(create()); ast::IfStatement expr(std::move(cond), std::move(if_body)); @@ -599,13 +584,13 @@ TEST_F(BuilderTest, If_WithReturnValue) { // if (true) { // return false; // } - auto cond = std::make_unique( - std::make_unique(&bool_type, true)); - auto cond2 = std::make_unique( - std::make_unique(&bool_type, false)); + auto cond = create( + create(&bool_type, true)); + auto cond2 = create( + create(&bool_type, false)); - auto if_body = std::make_unique(); - if_body->append(std::make_unique(std::move(cond2))); + auto if_body = create(); + if_body->append(create(std::move(cond2))); ast::IfStatement expr(std::move(cond), std::move(if_body)); diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc index 04767d795c..033d83a421 100644 --- a/src/writer/spirv/builder_intrinsic_test.cc +++ b/src/writer/spirv/builder_intrinsic_test.cc @@ -64,6 +64,13 @@ class IntrinsicBuilderTest : public ast::Builder, public testing::Test { return var; } + /// @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)...); + } + Context ctx; ast::Module mod; TypeDeterminer td{&ctx, &mod}; @@ -1706,17 +1713,15 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("a", &ary, std::move(decos))); + members.push_back(create("a", &ary, std::move(decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("my_struct", std::move(s)); auto var = make_var("b", ast::StorageClass::kPrivate, &s_type); - auto expr = - call_expr("arrayLength", std::make_unique( - make_expr("b"), make_expr("a"))); + auto expr = call_expr("arrayLength", create( + make_expr("b"), make_expr("a"))); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -1748,18 +1753,15 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("z", f32(), std::move(decos))); - members.push_back( - std::make_unique("a", &ary, std::move(decos))); + members.push_back(create("z", f32(), std::move(decos))); + members.push_back(create("a", &ary, std::move(decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("my_struct", std::move(s)); auto var = make_var("b", ast::StorageClass::kPrivate, &s_type); - auto expr = - call_expr("arrayLength", std::make_unique( - make_expr("b"), make_expr("a"))); + auto expr = call_expr("arrayLength", create( + make_expr("b"), make_expr("a"))); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -1793,19 +1795,17 @@ TEST_F(IntrinsicBuilderTest, DISABLED_Call_ArrayLength_Ptr) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("z", f32(), std::move(decos))); - members.push_back( - std::make_unique("a", &ary, std::move(decos))); + members.push_back(create("z", f32(), std::move(decos))); + members.push_back(create("a", &ary, std::move(decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("my_struct", std::move(s)); auto var = make_var("b", ast::StorageClass::kPrivate, &s_type); auto ptr_var = make_var("ptr_var", ast::StorageClass::kPrivate, &ptr); - ptr_var->set_constructor(std::make_unique( - make_expr("b"), make_expr("a"))); + ptr_var->set_constructor( + create(make_expr("b"), make_expr("a"))); auto expr = call_expr("arrayLength", "ptr_var"); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); diff --git a/src/writer/spirv/builder_loop_test.cc b/src/writer/spirv/builder_loop_test.cc index d420e8898e..a7b265e723 100644 --- a/src/writer/spirv/builder_loop_test.cc +++ b/src/writer/spirv/builder_loop_test.cc @@ -65,17 +65,15 @@ TEST_F(BuilderTest, Loop_WithoutContinuing) { // loop { // v = 2; // } - auto var = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); + auto var = create("v", ast::StorageClass::kPrivate, &i32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 2)))); + auto body = create(); + body->append( + create(create("v"), + create( + create(&i32, 2)))); - ast::LoopStatement expr(std::move(body), - std::make_unique()); + ast::LoopStatement expr(std::move(body), create()); td.RegisterVariableForTesting(var.get()); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -113,20 +111,19 @@ TEST_F(BuilderTest, Loop_WithContinuing) { // } // } - auto var = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); + auto var = create("v", ast::StorageClass::kPrivate, &i32); - auto body = std::make_unique(); - body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 2)))); + auto body = create(); + body->append( + create(create("v"), + create( + create(&i32, 2)))); - auto continuing = std::make_unique(); - continuing->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 3)))); + auto continuing = create(); + continuing->append( + create(create("v"), + create( + create(&i32, 3)))); ast::LoopStatement expr(std::move(body), std::move(continuing)); td.RegisterVariableForTesting(var.get()); @@ -162,11 +159,10 @@ TEST_F(BuilderTest, Loop_WithContinue) { // loop { // continue; // } - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); - ast::LoopStatement expr(std::move(body), - std::make_unique()); + ast::LoopStatement expr(std::move(body), create()); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -190,11 +186,10 @@ TEST_F(BuilderTest, Loop_WithBreak) { // loop { // break; // } - auto body = std::make_unique(); - body->append(std::make_unique()); + auto body = create(); + body->append(create()); - ast::LoopStatement expr(std::move(body), - std::make_unique()); + ast::LoopStatement expr(std::move(body), create()); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); diff --git a/src/writer/spirv/builder_return_test.cc b/src/writer/spirv/builder_return_test.cc index 91fe8fbc94..856af32809 100644 --- a/src/writer/spirv/builder_return_test.cc +++ b/src/writer/spirv/builder_return_test.cc @@ -51,15 +51,14 @@ TEST_F(BuilderTest, Return_WithValue) { ast::type::VectorType vec(&f32, 3); ast::ExpressionList vals; - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 1.0f))); - vals.push_back(std::make_unique( - std::make_unique(&f32, 3.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 1.0f))); + vals.push_back(create( + create(&f32, 3.0f))); - auto val = - std::make_unique(&vec, std::move(vals)); + auto val = create(&vec, std::move(vals)); ast::ReturnStatement ret(std::move(val)); @@ -85,8 +84,7 @@ TEST_F(BuilderTest, Return_WithValue_GeneratesLoad) { ast::Variable var("param", ast::StorageClass::kFunction, &f32); - ast::ReturnStatement ret( - std::make_unique("param")); + ast::ReturnStatement ret(create("param")); td.RegisterVariableForTesting(&var); EXPECT_TRUE(td.DetermineResultType(&ret)) << td.error(); diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc index e7dfaaf611..ed4b35ecd3 100644 --- a/src/writer/spirv/builder_switch_test.cc +++ b/src/writer/spirv/builder_switch_test.cc @@ -45,8 +45,8 @@ TEST_F(BuilderTest, Switch_Empty) { // switch (1) { // } - auto cond = std::make_unique( - std::make_unique(&i32, 1)); + auto cond = create( + create(&i32, 1)); ast::SwitchStatement expr(std::move(cond), ast::CaseStatementList{}); @@ -77,36 +77,34 @@ TEST_F(BuilderTest, Switch_WithCase) { // v = 2; // } - auto v = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); - auto a = - std::make_unique("a", ast::StorageClass::kPrivate, &i32); + auto v = create("v", ast::StorageClass::kPrivate, &i32); + auto a = create("a", ast::StorageClass::kPrivate, &i32); - auto case_1_body = std::make_unique(); - case_1_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 1)))); + auto case_1_body = create(); + case_1_body->append( + create(create("v"), + create( + create(&i32, 1)))); - auto case_2_body = std::make_unique(); - case_2_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 2)))); + auto case_2_body = create(); + case_2_body->append( + create(create("v"), + create( + create(&i32, 2)))); ast::CaseSelectorList selector_1; - selector_1.push_back(std::make_unique(&i32, 1)); + selector_1.push_back(create(&i32, 1)); ast::CaseSelectorList selector_2; - selector_2.push_back(std::make_unique(&i32, 2)); + selector_2.push_back(create(&i32, 2)); ast::CaseStatementList cases; - cases.push_back(std::make_unique(std::move(selector_1), - std::move(case_1_body))); - cases.push_back(std::make_unique(std::move(selector_2), - std::move(case_2_body))); + cases.push_back(create(std::move(selector_1), + std::move(case_1_body))); + cases.push_back(create(std::move(selector_2), + std::move(case_2_body))); - ast::SwitchStatement expr(std::make_unique("a"), + ast::SwitchStatement expr(create("a"), std::move(cases)); td.RegisterVariableForTesting(v.get()); @@ -158,22 +156,19 @@ TEST_F(BuilderTest, Switch_WithDefault) { // v = 1; // } - auto v = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); - auto a = - std::make_unique("a", ast::StorageClass::kPrivate, &i32); + auto v = create("v", ast::StorageClass::kPrivate, &i32); + auto a = create("a", ast::StorageClass::kPrivate, &i32); - auto default_body = std::make_unique(); - default_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 1)))); + auto default_body = create(); + default_body->append( + create(create("v"), + create( + create(&i32, 1)))); ast::CaseStatementList cases; - cases.push_back( - std::make_unique(std::move(default_body))); + cases.push_back(create(std::move(default_body))); - ast::SwitchStatement expr(std::make_unique("a"), + ast::SwitchStatement expr(create("a"), std::move(cases)); td.RegisterVariableForTesting(v.get()); @@ -223,45 +218,42 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { // v = 3; // } - auto v = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); - auto a = - std::make_unique("a", ast::StorageClass::kPrivate, &i32); + auto v = create("v", ast::StorageClass::kPrivate, &i32); + auto a = create("a", ast::StorageClass::kPrivate, &i32); - auto case_1_body = std::make_unique(); - case_1_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 1)))); + auto case_1_body = create(); + case_1_body->append( + create(create("v"), + create( + create(&i32, 1)))); - auto case_2_body = std::make_unique(); - case_2_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 2)))); + auto case_2_body = create(); + case_2_body->append( + create(create("v"), + create( + create(&i32, 2)))); - auto default_body = std::make_unique(); - default_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 3)))); + auto default_body = create(); + default_body->append( + create(create("v"), + create( + create(&i32, 3)))); ast::CaseSelectorList selector_1; - selector_1.push_back(std::make_unique(&i32, 1)); + selector_1.push_back(create(&i32, 1)); ast::CaseSelectorList selector_2; - selector_2.push_back(std::make_unique(&i32, 2)); - selector_2.push_back(std::make_unique(&i32, 3)); + selector_2.push_back(create(&i32, 2)); + selector_2.push_back(create(&i32, 3)); ast::CaseStatementList cases; - cases.push_back(std::make_unique(std::move(selector_1), - std::move(case_1_body))); - cases.push_back(std::make_unique(std::move(selector_2), - std::move(case_2_body))); - cases.push_back( - std::make_unique(std::move(default_body))); + cases.push_back(create(std::move(selector_1), + std::move(case_1_body))); + cases.push_back(create(std::move(selector_2), + std::move(case_2_body))); + cases.push_back(create(std::move(default_body))); - ast::SwitchStatement expr(std::make_unique("a"), + ast::SwitchStatement expr(create("a"), std::move(cases)); td.RegisterVariableForTesting(v.get()); @@ -320,45 +312,42 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) { // v = 3; // } - auto v = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); - auto a = - std::make_unique("a", ast::StorageClass::kPrivate, &i32); + auto v = create("v", ast::StorageClass::kPrivate, &i32); + auto a = create("a", ast::StorageClass::kPrivate, &i32); - auto case_1_body = std::make_unique(); - case_1_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 1)))); - case_1_body->append(std::make_unique()); + auto case_1_body = create(); + case_1_body->append( + create(create("v"), + create( + create(&i32, 1)))); + case_1_body->append(create()); - auto case_2_body = std::make_unique(); - case_2_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 2)))); + auto case_2_body = create(); + case_2_body->append( + create(create("v"), + create( + create(&i32, 2)))); - auto default_body = std::make_unique(); - default_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 3)))); + auto default_body = create(); + default_body->append( + create(create("v"), + create( + create(&i32, 3)))); ast::CaseSelectorList selector_1; - selector_1.push_back(std::make_unique(&i32, 1)); + selector_1.push_back(create(&i32, 1)); ast::CaseSelectorList selector_2; - selector_2.push_back(std::make_unique(&i32, 2)); + selector_2.push_back(create(&i32, 2)); ast::CaseStatementList cases; - cases.push_back(std::make_unique(std::move(selector_1), - std::move(case_1_body))); - cases.push_back(std::make_unique(std::move(selector_2), - std::move(case_2_body))); - cases.push_back( - std::make_unique(std::move(default_body))); + cases.push_back(create(std::move(selector_1), + std::move(case_1_body))); + cases.push_back(create(std::move(selector_2), + std::move(case_2_body))); + cases.push_back(create(std::move(default_body))); - ast::SwitchStatement expr(std::make_unique("a"), + ast::SwitchStatement expr(create("a"), std::move(cases)); td.RegisterVariableForTesting(v.get()); @@ -413,26 +402,24 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) { // fallthrough; // } - auto v = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); - auto a = - std::make_unique("a", ast::StorageClass::kPrivate, &i32); + auto v = create("v", ast::StorageClass::kPrivate, &i32); + auto a = create("a", ast::StorageClass::kPrivate, &i32); - auto case_1_body = std::make_unique(); - case_1_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 1)))); - case_1_body->append(std::make_unique()); + auto case_1_body = create(); + case_1_body->append( + create(create("v"), + create( + create(&i32, 1)))); + case_1_body->append(create()); ast::CaseSelectorList selector_1; - selector_1.push_back(std::make_unique(&i32, 1)); + selector_1.push_back(create(&i32, 1)); ast::CaseStatementList cases; - cases.push_back(std::make_unique(std::move(selector_1), - std::move(case_1_body))); + cases.push_back(create(std::move(selector_1), + std::move(case_1_body))); - ast::SwitchStatement expr(std::make_unique("a"), + ast::SwitchStatement expr(create("a"), std::move(cases)); td.RegisterVariableForTesting(v.get()); @@ -461,33 +448,31 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { // v = 1; // } - auto v = - std::make_unique("v", ast::StorageClass::kPrivate, &i32); - auto a = - std::make_unique("a", ast::StorageClass::kPrivate, &i32); + auto v = create("v", ast::StorageClass::kPrivate, &i32); + auto a = create("a", ast::StorageClass::kPrivate, &i32); - auto if_body = std::make_unique(); - if_body->append(std::make_unique()); + auto if_body = create(); + if_body->append(create()); - auto case_1_body = std::make_unique(); - case_1_body->append(std::make_unique( - std::make_unique( - std::make_unique(&bool_type, true)), - std::move(if_body))); + auto case_1_body = create(); + case_1_body->append( + create(create( + create(&bool_type, true)), + std::move(if_body))); - case_1_body->append(std::make_unique( - std::make_unique("v"), - std::make_unique( - std::make_unique(&i32, 1)))); + case_1_body->append( + create(create("v"), + create( + create(&i32, 1)))); ast::CaseSelectorList selector_1; - selector_1.push_back(std::make_unique(&i32, 1)); + selector_1.push_back(create(&i32, 1)); ast::CaseStatementList cases; - cases.push_back(std::make_unique(std::move(selector_1), - std::move(case_1_body))); + cases.push_back(create(std::move(selector_1), + std::move(case_1_body))); - ast::SwitchStatement expr(std::make_unique("a"), + ast::SwitchStatement expr(create("a"), std::move(cases)); td.RegisterVariableForTesting(v.get()); diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc index e1e8362d8e..46aa30da64 100644 --- a/src/writer/spirv/builder_type_test.cc +++ b/src/writer/spirv/builder_type_test.cc @@ -124,7 +124,7 @@ TEST_F(BuilderTest_Type, GenerateArray_WithStride) { ast::type::I32Type i32; ast::ArrayDecorationList decos; - decos.push_back(std::make_unique(16u, Source{})); + decos.push_back(create(16u, Source{})); ast::type::ArrayType ary(&i32, 4); ary.set_decorations(std::move(decos)); @@ -279,7 +279,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) { } TEST_F(BuilderTest_Type, GenerateStruct_Empty) { - auto s = std::make_unique(); + auto s = create(); ast::type::StructType s_type("S", std::move(s)); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -298,10 +298,9 @@ TEST_F(BuilderTest_Type, GenerateStruct) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("a", &f32, std::move(decos))); + members.push_back(create("a", &f32, std::move(decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("my_struct", std::move(s)); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -321,15 +320,12 @@ TEST_F(BuilderTest_Type, GenerateStruct_Decorated) { ast::StructMemberDecorationList decos; ast::StructMemberList members; - members.push_back( - std::make_unique("a", &f32, std::move(decos))); + members.push_back(create("a", &f32, std::move(decos))); ast::StructDecorationList struct_decos; - struct_decos.push_back( - std::make_unique(Source{})); + struct_decos.push_back(create(Source{})); - auto s = std::make_unique(std::move(struct_decos), - std::move(members)); + auto s = create(std::move(struct_decos), std::move(members)); ast::type::StructType s_type("my_struct", std::move(s)); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -350,19 +346,15 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) { ast::type::F32Type f32; ast::StructMemberDecorationList a_decos; - a_decos.push_back( - std::make_unique(0, Source{})); + a_decos.push_back(create(0, Source{})); ast::StructMemberDecorationList b_decos; - b_decos.push_back( - std::make_unique(8, Source{})); + b_decos.push_back(create(8, Source{})); ast::StructMemberList members; - members.push_back( - std::make_unique("a", &f32, std::move(a_decos))); - members.push_back( - std::make_unique("b", &f32, std::move(b_decos))); + members.push_back(create("a", &f32, std::move(a_decos))); + members.push_back(create("b", &f32, std::move(b_decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("S", std::move(s)); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -392,14 +384,14 @@ TEST_F(BuilderTest_Type, GenerateStruct_NonLayout_Matrix) { ast::StructMemberDecorationList empty_b; ast::StructMemberDecorationList empty_c; ast::StructMemberList members; - members.push_back(std::make_unique("a", &glsl_mat2x2, - std::move(empty_a))); - members.push_back(std::make_unique("b", &glsl_mat2x3, - std::move(empty_b))); - members.push_back(std::make_unique("c", &glsl_mat4x4, - std::move(empty_c))); + members.push_back( + create("a", &glsl_mat2x2, std::move(empty_a))); + members.push_back( + create("b", &glsl_mat2x3, std::move(empty_b))); + members.push_back( + create("c", &glsl_mat4x4, std::move(empty_c))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("S", std::move(s)); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -431,24 +423,21 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutMatrix) { ast::type::MatrixType glsl_mat4x4(&f32, 4, 4); ast::StructMemberDecorationList a_decos; - a_decos.push_back( - std::make_unique(0, Source{})); + a_decos.push_back(create(0, Source{})); ast::StructMemberDecorationList b_decos; - b_decos.push_back( - std::make_unique(16, Source{})); + b_decos.push_back(create(16, Source{})); ast::StructMemberDecorationList c_decos; - c_decos.push_back( - std::make_unique(48, Source{})); + c_decos.push_back(create(48, Source{})); ast::StructMemberList members; - members.push_back(std::make_unique("a", &glsl_mat2x2, - std::move(a_decos))); - members.push_back(std::make_unique("b", &glsl_mat2x3, - std::move(b_decos))); - members.push_back(std::make_unique("c", &glsl_mat4x4, - std::move(c_decos))); + members.push_back( + create("a", &glsl_mat2x2, std::move(a_decos))); + members.push_back( + create("b", &glsl_mat2x3, std::move(b_decos))); + members.push_back( + create("c", &glsl_mat4x4, std::move(c_decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("S", std::move(s)); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -498,24 +487,21 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutArraysOfMatrix) { ast::type::ArrayType rtarr_mat4x4(&glsl_mat4x4); // Runtime array ast::StructMemberDecorationList a_decos; - a_decos.push_back( - std::make_unique(0, Source{})); + a_decos.push_back(create(0, Source{})); ast::StructMemberDecorationList b_decos; - b_decos.push_back( - std::make_unique(16, Source{})); + b_decos.push_back(create(16, Source{})); ast::StructMemberDecorationList c_decos; - c_decos.push_back( - std::make_unique(48, Source{})); + c_decos.push_back(create(48, Source{})); ast::StructMemberList members; - members.push_back(std::make_unique("a", &glsl_mat2x2, - std::move(a_decos))); - members.push_back(std::make_unique("b", &glsl_mat2x3, - std::move(b_decos))); - members.push_back(std::make_unique("c", &glsl_mat4x4, - std::move(c_decos))); + members.push_back( + create("a", &glsl_mat2x2, std::move(a_decos))); + members.push_back( + create("b", &glsl_mat2x3, std::move(b_decos))); + members.push_back( + create("c", &glsl_mat4x4, std::move(c_decos))); - auto s = std::make_unique(std::move(members)); + auto s = create(std::move(members)); ast::type::StructType s_type("S", std::move(s)); auto id = b.GenerateTypeIfNeeded(&s_type); diff --git a/src/writer/spirv/builder_unary_op_expression_test.cc b/src/writer/spirv/builder_unary_op_expression_test.cc index 29f597c79e..5795dee1af 100644 --- a/src/writer/spirv/builder_unary_op_expression_test.cc +++ b/src/writer/spirv/builder_unary_op_expression_test.cc @@ -41,10 +41,9 @@ using BuilderTest = TestHelper; TEST_F(BuilderTest, UnaryOp_Negation_Integer) { ast::type::I32Type i32; - ast::UnaryOpExpression expr( - ast::UnaryOp::kNegation, - std::make_unique( - std::make_unique(&i32, 1))); + ast::UnaryOpExpression expr(ast::UnaryOp::kNegation, + create( + create(&i32, 1))); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -61,10 +60,9 @@ TEST_F(BuilderTest, UnaryOp_Negation_Integer) { TEST_F(BuilderTest, UnaryOp_Negation_Float) { ast::type::F32Type f32; - ast::UnaryOpExpression expr( - ast::UnaryOp::kNegation, - std::make_unique( - std::make_unique(&f32, 1))); + ast::UnaryOpExpression expr(ast::UnaryOp::kNegation, + create( + create(&f32, 1))); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -81,10 +79,9 @@ TEST_F(BuilderTest, UnaryOp_Negation_Float) { TEST_F(BuilderTest, UnaryOp_Not) { ast::type::BoolType bool_type; - ast::UnaryOpExpression expr( - ast::UnaryOp::kNot, - std::make_unique( - std::make_unique(&bool_type, false))); + ast::UnaryOpExpression expr(ast::UnaryOp::kNot, + create( + create(&bool_type, false))); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -104,9 +101,8 @@ TEST_F(BuilderTest, UnaryOp_LoadRequired) { ast::Variable var("param", ast::StorageClass::kFunction, &vec); - ast::UnaryOpExpression expr( - ast::UnaryOp::kNegation, - std::make_unique("param")); + ast::UnaryOpExpression expr(ast::UnaryOp::kNegation, + create("param")); td.RegisterVariableForTesting(&var); EXPECT_TRUE(td.DetermineResultType(&expr)) << td.error(); diff --git a/src/writer/spirv/test_helper.h b/src/writer/spirv/test_helper.h index a7ff0158ca..03c897511c 100644 --- a/src/writer/spirv/test_helper.h +++ b/src/writer/spirv/test_helper.h @@ -15,6 +15,9 @@ #ifndef SRC_WRITER_SPIRV_TEST_HELPER_H_ #define SRC_WRITER_SPIRV_TEST_HELPER_H_ +#include +#include + #include "gtest/gtest.h" #include "src/ast/module.h" #include "src/context.h" @@ -26,12 +29,19 @@ namespace writer { namespace spirv { /// Helper class for testing -template -class TestHelperBase : public T { +template +class TestHelperBase : public BASE { public: TestHelperBase() : td(&ctx, &mod), b(&ctx, &mod) {} ~TestHelperBase() = default; + /// @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