diff --git a/src/program_builder.cc b/src/program_builder.cc index f20b76a587..c7e6751420 100644 --- a/src/program_builder.cc +++ b/src/program_builder.cc @@ -116,9 +116,6 @@ ProgramBuilder::TypesBuilder::TypesBuilder(ProgramBuilder* pb) : builder(pb) {} const ast::Statement* ProgramBuilder::WrapInStatement( const ast::Expression* expr) { - if (auto* ce = expr->As()) { - return CallStmt(ce); - } // Create a temporary variable of inferred type from expr. return Decl(Const(symbols_.New(), nullptr, expr)); } diff --git a/src/resolver/resolver_test.cc b/src/resolver/resolver_test.cc index a92c19c0de..f6d465b219 100644 --- a/src/resolver/resolver_test.cc +++ b/src/resolver/resolver_test.cc @@ -913,8 +913,8 @@ TEST_F(ResolverTest, Function_CallSites) { auto* call_2 = Call("foo"); auto* bar = Func("bar", ast::VariableList{}, ty.void_(), { - WrapInStatement(call_1), - WrapInStatement(call_2), + CallStmt(call_1), + CallStmt(call_2), }); EXPECT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/writer/glsl/generator_impl_intrinsic_test.cc b/src/writer/glsl/generator_impl_intrinsic_test.cc index 7891bebc17..8e81801246 100644 --- a/src/writer/glsl/generator_impl_intrinsic_test.cc +++ b/src/writer/glsl/generator_impl_intrinsic_test.cc @@ -264,7 +264,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Intrinsic_Call) { Global("param1", ty.vec3(), ast::StorageClass::kPrivate); Global("param2", ty.vec3(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -276,7 +276,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Intrinsic_Call) { TEST_F(GlslGeneratorImplTest_Intrinsic, Select_Scalar) { auto* call = Call("select", 1.0f, 2.0f, true); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -288,7 +288,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Select_Scalar) { TEST_F(GlslGeneratorImplTest_Intrinsic, Select_Vector) { auto* call = Call("select", vec2(1, 2), vec2(3, 4), vec2(true, false)); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -385,7 +385,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, IsNormal_Vector) { TEST_F(GlslGeneratorImplTest_Intrinsic, Pack4x8Snorm) { auto* call = Call("pack4x8snorm", "p1"); Global("p1", ty.vec4(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -400,7 +400,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Pack4x8Snorm) { TEST_F(GlslGeneratorImplTest_Intrinsic, Pack4x8Unorm) { auto* call = Call("pack4x8unorm", "p1"); Global("p1", ty.vec4(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -415,7 +415,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Pack4x8Unorm) { TEST_F(GlslGeneratorImplTest_Intrinsic, Pack2x16Snorm) { auto* call = Call("pack2x16snorm", "p1"); Global("p1", ty.vec2(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -429,7 +429,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Pack2x16Snorm) { TEST_F(GlslGeneratorImplTest_Intrinsic, Pack2x16Unorm) { auto* call = Call("pack2x16unorm", "p1"); Global("p1", ty.vec2(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -443,7 +443,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Pack2x16Unorm) { TEST_F(GlslGeneratorImplTest_Intrinsic, Pack2x16Float) { auto* call = Call("pack2x16float", "p1"); Global("p1", ty.vec2(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -456,7 +456,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Pack2x16Float) { TEST_F(GlslGeneratorImplTest_Intrinsic, Unpack4x8Snorm) { auto* call = Call("unpack4x8snorm", "p1"); Global("p1", ty.u32(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -473,7 +473,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Unpack4x8Snorm) { TEST_F(GlslGeneratorImplTest_Intrinsic, Unpack4x8Unorm) { auto* call = Call("unpack4x8unorm", "p1"); Global("p1", ty.u32(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -490,7 +490,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Unpack4x8Unorm) { TEST_F(GlslGeneratorImplTest_Intrinsic, Unpack2x16Snorm) { auto* call = Call("unpack2x16snorm", "p1"); Global("p1", ty.u32(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -507,7 +507,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Unpack2x16Snorm) { TEST_F(GlslGeneratorImplTest_Intrinsic, Unpack2x16Unorm) { auto* call = Call("unpack2x16unorm", "p1"); Global("p1", ty.u32(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -523,7 +523,7 @@ TEST_F(GlslGeneratorImplTest_Intrinsic, Unpack2x16Unorm) { TEST_F(GlslGeneratorImplTest_Intrinsic, Unpack2x16Float) { auto* call = Call("unpack2x16float", "p1"); Global("p1", ty.u32(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -601,7 +601,7 @@ void main() { TEST_F(GlslGeneratorImplTest_Intrinsic, DotI32) { Global("v", ty.vec3(), ast::StorageClass::kPrivate); - WrapInFunction(Call("dot", "v", "v")); + WrapInFunction(CallStmt(Call("dot", "v", "v"))); GeneratorImpl& gen = SanitizeAndBuild(); @@ -630,7 +630,7 @@ void main() { TEST_F(GlslGeneratorImplTest_Intrinsic, DotU32) { Global("v", ty.vec3(), ast::StorageClass::kPrivate); - WrapInFunction(Call("dot", "v", "v")); + WrapInFunction(CallStmt(Call("dot", "v", "v"))); GeneratorImpl& gen = SanitizeAndBuild(); diff --git a/src/writer/hlsl/generator_impl_intrinsic_test.cc b/src/writer/hlsl/generator_impl_intrinsic_test.cc index 92f5c55b0b..cda470aaec 100644 --- a/src/writer/hlsl/generator_impl_intrinsic_test.cc +++ b/src/writer/hlsl/generator_impl_intrinsic_test.cc @@ -264,7 +264,7 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Intrinsic_Call) { Global("param1", ty.vec3(), ast::StorageClass::kPrivate); Global("param2", ty.vec3(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -276,7 +276,7 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Intrinsic_Call) { TEST_F(HlslGeneratorImplTest_Intrinsic, Select_Scalar) { auto* call = Call("select", 1.0f, 2.0f, true); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -288,7 +288,7 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Select_Scalar) { TEST_F(HlslGeneratorImplTest_Intrinsic, Select_Vector) { auto* call = Call("select", vec2(1, 2), vec2(3, 4), vec2(true, false)); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); gen.increment_indent(); @@ -299,7 +299,7 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Select_Vector) { TEST_F(HlslGeneratorImplTest_Intrinsic, Modf_Scalar) { auto* call = Call("modf", 1.0f); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = SanitizeAndBuild(); @@ -325,7 +325,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Modf_Vector) { auto* call = Call("modf", vec3()); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = SanitizeAndBuild(); @@ -351,7 +351,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Frexp_Scalar_i32) { auto* call = Call("frexp", 1.0f); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = SanitizeAndBuild(); @@ -377,7 +377,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Frexp_Vector_i32) { auto* call = Call("frexp", vec3()); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = SanitizeAndBuild(); @@ -418,7 +418,7 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, IsNormal_Scalar) { [numthreads(1, 1, 1)] void test_function() { float val = 0.0f; - tint_isNormal(val); + const bool tint_symbol = tint_isNormal(val); return; } )"); @@ -441,7 +441,7 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, IsNormal_Vector) { [numthreads(1, 1, 1)] void test_function() { float3 val = float3(0.0f, 0.0f, 0.0f); - tint_isNormal(val); + const bool3 tint_symbol = tint_isNormal(val); return; } )"); @@ -450,7 +450,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Pack4x8Snorm) { auto* call = Call("pack4x8snorm", "p1"); Global("p1", ty.vec4(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); @@ -472,7 +472,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Pack4x8Unorm) { auto* call = Call("pack4x8unorm", "p1"); Global("p1", ty.vec4(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); @@ -494,7 +494,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Snorm) { auto* call = Call("pack2x16snorm", "p1"); Global("p1", ty.vec2(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); @@ -516,7 +516,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Unorm) { auto* call = Call("pack2x16unorm", "p1"); Global("p1", ty.vec2(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); @@ -538,7 +538,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Float) { auto* call = Call("pack2x16float", "p1"); Global("p1", ty.vec2(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); @@ -560,7 +560,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack4x8Snorm) { auto* call = Call("unpack4x8snorm", "p1"); Global("p1", ty.u32(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); @@ -583,7 +583,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack4x8Unorm) { auto* call = Call("unpack4x8unorm", "p1"); Global("p1", ty.u32(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); @@ -606,7 +606,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Snorm) { auto* call = Call("unpack2x16snorm", "p1"); Global("p1", ty.u32(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); @@ -629,7 +629,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Unorm) { auto* call = Call("unpack2x16unorm", "p1"); Global("p1", ty.u32(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); @@ -652,7 +652,7 @@ void test_function() { TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Float) { auto* call = Call("unpack2x16float", "p1"); Global("p1", ty.u32(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); diff --git a/src/writer/msl/generator_impl_intrinsic_test.cc b/src/writer/msl/generator_impl_intrinsic_test.cc index 1f5c78e414..413b49dfcf 100644 --- a/src/writer/msl/generator_impl_intrinsic_test.cc +++ b/src/writer/msl/generator_impl_intrinsic_test.cc @@ -288,7 +288,7 @@ TEST_F(MslGeneratorImplTest, Intrinsic_Call) { Global("param2", ty.vec2(), ast::StorageClass::kPrivate); auto* call = Call("dot", "param1", "param2"); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -322,7 +322,7 @@ TEST_F(MslGeneratorImplTest, WorkgroupBarrier) { TEST_F(MslGeneratorImplTest, Pack2x16Float) { auto* call = Call("pack2x16float", "p1"); Global("p1", ty.vec2(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -334,7 +334,7 @@ TEST_F(MslGeneratorImplTest, Pack2x16Float) { TEST_F(MslGeneratorImplTest, Unpack2x16Float) { auto* call = Call("unpack2x16float", "p1"); Global("p1", ty.u32(), ast::StorageClass::kPrivate); - WrapInFunction(call); + WrapInFunction(CallStmt(call)); GeneratorImpl& gen = Build(); @@ -345,7 +345,7 @@ TEST_F(MslGeneratorImplTest, Unpack2x16Float) { TEST_F(MslGeneratorImplTest, DotI32) { Global("v", ty.vec3(), ast::StorageClass::kPrivate); - WrapInFunction(Call("dot", "v", "v")); + WrapInFunction(CallStmt(Call("dot", "v", "v"))); GeneratorImpl& gen = SanitizeAndBuild();