ast: Remove statement constructors that don't take a Source

Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: I137f1017ca56125cf3d52ecbef2ff46d0574338b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35161
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-12-12 11:58:44 +00:00
committed by Commit Bot service account
parent 1ff59cd0e2
commit bbefff63a3
111 changed files with 1287 additions and 1145 deletions

View File

@@ -103,7 +103,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) {
auto* rhs = create<ast::ScalarConstructorExpression>(
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* body = create<ast::BlockStatement>();
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::AssignmentStatement>(
Source{Source::Location{12, 34}}, lhs, rhs));
@@ -199,8 +199,8 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) {
auto* rhs = create<ast::ScalarConstructorExpression>(
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::VariableDeclStatement>(Source{}, var));
body->append(create<ast::AssignmentStatement>(
Source{Source::Location{12, 34}}, lhs, rhs));
@@ -234,8 +234,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) {
auto* rhs = create<ast::ScalarConstructorExpression>(
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
ast::BlockStatement block;
block.append(create<ast::VariableDeclStatement>(var));
ast::BlockStatement block(Source{});
block.append(create<ast::VariableDeclStatement>(Source{}, var));
block.append(create<ast::AssignmentStatement>(
Source{Source::Location{12, 34}}, lhs, rhs));
@@ -339,7 +339,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::AssignmentStatement>(
Source{Source::Location{12, 34}}, lhs, rhs));
@@ -379,7 +379,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::AssignmentStatement>(
Source{Source::Location{12, 34}}, lhs, rhs));
body->append(create<ast::ReturnStatement>(Source{}));
@@ -415,15 +415,15 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) {
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::VariableDeclStatement>(Source{}, var));
auto* lhs = create<ast::IdentifierExpression>(
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
auto* rhs = create<ast::ScalarConstructorExpression>(
Source{}, create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
auto* outer_body = create<ast::BlockStatement>();
auto* outer_body = create<ast::BlockStatement>(Source{});
outer_body->append(
create<ast::IfStatement>(Source{}, cond, body, ast::ElseStatementList{}));
outer_body->append(create<ast::AssignmentStatement>(
@@ -461,12 +461,12 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* body = create<ast::BlockStatement>();
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::AssignmentStatement>(
Source{Source::Location{12, 34}}, lhs, rhs));
auto* outer_body = create<ast::BlockStatement>();
outer_body->append(create<ast::VariableDeclStatement>(var));
auto* outer_body = create<ast::BlockStatement>(Source{});
outer_body->append(create<ast::VariableDeclStatement>(Source{}, var));
outer_body->append(
create<ast::IfStatement>(Source{}, cond, body, ast::ElseStatementList{}));
EXPECT_TRUE(td()->DetermineStatements(outer_body)) << td()->error();
@@ -564,8 +564,8 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) {
auto* rhs = create<ast::ScalarConstructorExpression>(
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::VariableDeclStatement>(Source{}, var));
body->append(create<ast::AssignmentStatement>(
Source{Source::Location{12, 34}}, lhs, rhs));
@@ -609,7 +609,7 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
ast::VariableDecorationList{}); // decorations
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::VariableDeclStatement>(
Source{Source::Location{12, 34}}, var));
auto* func = create<ast::Function>(Source{}, mod()->RegisterSymbol("my_func"),
@@ -655,8 +655,8 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
ast::VariableDecorationList{}); // decorations
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::VariableDeclStatement>(Source{}, var));
body->append(create<ast::VariableDeclStatement>(
Source{Source::Location{12, 34}}, var_a_float));
auto* func = create<ast::Function>(Source{}, mod()->RegisterSymbol("my_func"),
@@ -691,8 +691,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::VariableDeclStatement>(Source{}, var));
auto* var_a_float = create<ast::Variable>(
Source{}, // source
@@ -705,7 +705,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
ast::VariableDecorationList{}); // decorations
auto* outer_body = create<ast::BlockStatement>();
auto* outer_body = create<ast::BlockStatement>(Source{});
outer_body->append(
create<ast::IfStatement>(Source{}, cond, body, ast::ElseStatementList{}));
outer_body->append(create<ast::VariableDeclStatement>(
@@ -748,12 +748,12 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
Source{}, create<ast::BoolLiteral>(Source{}, &bool_type, true));
auto* body = create<ast::BlockStatement>();
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::VariableDeclStatement>(
Source{Source::Location{12, 34}}, var));
auto* outer_body = create<ast::BlockStatement>();
outer_body->append(create<ast::VariableDeclStatement>(var_a_float));
auto* outer_body = create<ast::BlockStatement>(Source{});
outer_body->append(create<ast::VariableDeclStatement>(Source{}, var_a_float));
outer_body->append(
create<ast::IfStatement>(Source{}, cond, body, ast::ElseStatementList{}));
@@ -790,7 +790,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
ast::VariableDecorationList{}); // decorations
ast::VariableList params0;
auto* body0 = create<ast::BlockStatement>();
auto* body0 = create<ast::BlockStatement>(Source{});
body0->append(create<ast::VariableDeclStatement>(
Source{Source::Location{12, 34}}, var0));
body0->append(create<ast::ReturnStatement>(Source{}));
@@ -799,7 +799,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
ast::FunctionDecorationList{});
ast::VariableList params1;
auto* body1 = create<ast::BlockStatement>();
auto* body1 = create<ast::BlockStatement>(Source{});
body1->append(create<ast::VariableDeclStatement>(
Source{Source::Location{13, 34}}, var1));
body1->append(create<ast::ReturnStatement>(Source{}));
@@ -838,8 +838,8 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
auto* rhs = create<ast::ScalarConstructorExpression>(
Source{}, create<ast::SintLiteral>(Source{}, &i32, 2));
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
auto* body = create<ast::BlockStatement>(Source{});
body->append(create<ast::VariableDeclStatement>(Source{}, var));
body->append(create<ast::AssignmentStatement>(
Source{Source::Location{12, 34}}, lhs, rhs));