ast: Remove ReturnStatement constructors that don't take a source

set_source() will be removed, so sources will only be specifiable at construction time.

Bug: tint:390
Change-Id: I2b81929e362ccf75145ebc45028dd973a77ae068
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35010
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-12-07 21:09:57 +00:00
committed by Commit Bot service account
parent 321e5a9d7e
commit d0dda258cc
23 changed files with 183 additions and 187 deletions

View File

@@ -124,7 +124,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) {
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
body->append(create<ast::ReturnStatement>(Source{}));
auto* func = create<ast::Function>(
Source{}, "func", params, &void_type, body,
ast::FunctionDecorationList{
@@ -193,7 +193,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
auto* return_expr = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
body->append(create<ast::ReturnStatement>(return_expr));
body->append(create<ast::ReturnStatement>(Source{}, return_expr));
auto* func = create<ast::Function>(Source{}, "func", params, &i32, body,
ast::FunctionDecorationList{});
@@ -202,7 +202,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
auto* return_expr_copy = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
body_copy->append(create<ast::ReturnStatement>(return_expr_copy));
body_copy->append(create<ast::ReturnStatement>(Source{}, return_expr_copy));
auto* func_copy = create<ast::Function>(Source{Source::Location{12, 34}},
"func", params_copy, &i32, body_copy,
ast::FunctionDecorationList{});
@@ -226,7 +226,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
ast::VariableList params0;
auto* body0 = create<ast::BlockStatement>();
body0->append(create<ast::CallStatement>(call_expr));
body0->append(create<ast::ReturnStatement>());
body0->append(create<ast::ReturnStatement>(Source{}));
auto* func0 = create<ast::Function>(Source{}, "func", params0, &f32, body0,
ast::FunctionDecorationList{});
mod()->AddFunction(func0);
@@ -252,7 +252,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
auto* return_expr = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2));
body0->append(create<ast::ReturnStatement>(return_expr));
body0->append(create<ast::ReturnStatement>(Source{}, return_expr));
auto* func0 = create<ast::Function>(Source{}, "func", params0, &i32, body0,
ast::FunctionDecorationList{});
mod()->AddFunction(func0);
@@ -271,7 +271,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
create<ast::SintLiteral>(&i32, 0));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>(return_expr));
body->append(create<ast::ReturnStatement>(Source{}, return_expr));
auto* func = create<ast::Function>(
Source{Source::Location{12, 34}}, "vtx_main", params, &i32, body,
ast::FunctionDecorationList{
@@ -294,7 +294,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) {
params.push_back(
create<ast::Variable>(Source{}, "a", ast::StorageClass::kNone, &i32));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
body->append(create<ast::ReturnStatement>(Source{}));
auto* func = create<ast::Function>(
Source{Source::Location{12, 34}}, "vtx_func", params, &void_type, body,
ast::FunctionDecorationList{
@@ -316,7 +316,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) {
ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
body->append(create<ast::ReturnStatement>(Source{}));
auto* func = create<ast::Function>(
Source{Source::Location{12, 34}}, "main", params, &void_type, body,
ast::FunctionDecorationList{
@@ -338,7 +338,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) {
ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
body->append(create<ast::ReturnStatement>(Source{}));
auto* func = create<ast::Function>(
Source{}, "vtx_func", params, &void_type, body,
ast::FunctionDecorationList{
@@ -355,7 +355,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) {
ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
body->append(create<ast::ReturnStatement>(Source{}));
auto* func = create<ast::Function>(Source{}, "vtx_func", params, &void_type,
body, ast::FunctionDecorationList{});
mod()->AddFunction(func);

View File

@@ -326,7 +326,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
auto* body = create<ast::BlockStatement>();
body->append(create<ast::AssignmentStatement>(
Source{Source::Location{12, 34}}, lhs, rhs));
body->append(create<ast::ReturnStatement>());
body->append(create<ast::ReturnStatement>(Source{}));
auto* func = create<ast::Function>(
Source{}, "my_func", params, &void_type, body,
ast::FunctionDecorationList{
@@ -634,7 +634,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
auto* body0 = create<ast::BlockStatement>();
body0->append(create<ast::VariableDeclStatement>(
Source{Source::Location{12, 34}}, var0));
body0->append(create<ast::ReturnStatement>());
body0->append(create<ast::ReturnStatement>(Source{}));
auto* func0 = create<ast::Function>(Source{}, "func0", params0, &void_type,
body0, ast::FunctionDecorationList{});
@@ -642,7 +642,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
auto* body1 = create<ast::BlockStatement>();
body1->append(create<ast::VariableDeclStatement>(
Source{Source::Location{13, 34}}, var1));
body1->append(create<ast::ReturnStatement>());
body1->append(create<ast::ReturnStatement>(Source{}));
auto* func1 = create<ast::Function>(
Source{}, "func1", params1, &void_type, body1,
ast::FunctionDecorationList{