mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 07:36:15 +00:00
ast: Add Source argument to literals
Bug: tint:396 Bug: tint:390 Change-Id: Ib78c19533dc65c85e2381bf1ce0d0966dd7babe9 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35019 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
604bc72dd9
commit
5ed161b2d9
@@ -65,7 +65,7 @@ TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) {
|
||||
ast::type::I32 i32;
|
||||
|
||||
auto* lhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 1));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
auto* rhs = create<ast::IdentifierExpression>(mod()->RegisterSymbol("my_var"),
|
||||
"my_var");
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
@@ -83,7 +83,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariable_Fail) {
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
auto* assign = create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
|
||||
@@ -101,7 +101,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) {
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
@@ -123,13 +123,13 @@ TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
td()->RegisterVariableForTesting(var);
|
||||
@@ -154,13 +154,13 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.3f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
|
||||
|
||||
ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs);
|
||||
td()->RegisterVariableForTesting(var);
|
||||
@@ -188,13 +188,13 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
@@ -223,12 +223,12 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.3f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.3f));
|
||||
|
||||
ast::BlockStatement block;
|
||||
block.append(create<ast::VariableDeclStatement>(var));
|
||||
@@ -324,14 +324,14 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("not_global_var"),
|
||||
"not_global_var");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
@@ -363,13 +363,13 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{})); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
mod()->RegisterSymbol("global_var"), "global_var");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::VariableList params;
|
||||
|
||||
@@ -402,19 +402,19 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>();
|
||||
outer_body->append(
|
||||
@@ -442,17 +442,17 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14f));
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14f));
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs));
|
||||
@@ -479,8 +479,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var0);
|
||||
|
||||
auto* var1 = create<ast::Variable>(
|
||||
@@ -490,8 +490,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var1);
|
||||
|
||||
EXPECT_TRUE(v()->ValidateGlobalVariables(mod()->global_variables()))
|
||||
@@ -510,8 +510,8 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var0);
|
||||
|
||||
auto* var1 = create<ast::Variable>(
|
||||
@@ -521,8 +521,8 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(var1);
|
||||
|
||||
EXPECT_FALSE(v()->ValidateGlobalVariables(mod()->global_variables()));
|
||||
@@ -543,13 +543,13 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) {
|
||||
&i32, // type
|
||||
true, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
@@ -580,8 +580,8 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
mod()->AddGlobalVariable(global_var);
|
||||
|
||||
auto* var = create<ast::Variable>(
|
||||
@@ -591,8 +591,8 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
@@ -624,8 +624,8 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
||||
&i32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* var_a_float = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
@@ -634,8 +634,8 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 0.1)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
@@ -667,12 +667,12 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
@@ -683,8 +683,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>();
|
||||
outer_body->append(
|
||||
@@ -711,8 +711,8 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 3.14)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* var = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
@@ -721,12 +721,12 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::type::Bool bool_type;
|
||||
auto* cond = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::BoolLiteral>(&bool_type, true));
|
||||
create<ast::BoolLiteral>(Source{}, &bool_type, true));
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var));
|
||||
@@ -753,8 +753,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 2.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* var1 = create<ast::Variable>(
|
||||
Source{}, // source
|
||||
@@ -763,8 +763,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
||||
&void_type, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::FloatLiteral>(&f32, 1.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::FloatLiteral>(Source{}, &f32, 1.0)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::VariableList params0;
|
||||
auto* body0 = create<ast::BlockStatement>();
|
||||
@@ -813,7 +813,7 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
|
||||
auto* lhs =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
auto* rhs = create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&i32, 2));
|
||||
create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
body->append(create<ast::VariableDeclStatement>(var));
|
||||
|
||||
Reference in New Issue
Block a user