mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 07:06:11 +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
@@ -50,8 +50,8 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) {
|
||||
&f32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&f32, 3.14f)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &f32, 3.14f)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond = create<ast::IdentifierExpression>(
|
||||
Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a");
|
||||
@@ -84,13 +84,13 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_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* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
ast::CaseStatementList body;
|
||||
body.push_back(
|
||||
create<ast::CaseStatement>(csl, create<ast::BlockStatement>()));
|
||||
@@ -122,8 +122,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_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
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
@@ -135,7 +135,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
|
||||
create<ast::CaseStatement>(default_csl_1, block_default_1));
|
||||
|
||||
ast::CaseSelectorList csl_case_1;
|
||||
csl_case_1.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
csl_case_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
auto* block_case_1 = create<ast::BlockStatement>();
|
||||
switch_body.push_back(create<ast::CaseStatement>(csl_case_1, block_case_1));
|
||||
|
||||
@@ -172,15 +172,15 @@ TEST_F(ValidateControlBlockTest,
|
||||
&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
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::UintLiteral>(&u32, 1));
|
||||
csl.push_back(create<ast::UintLiteral>(Source{}, &u32, 1));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl, create<ast::BlockStatement>()));
|
||||
|
||||
@@ -215,15 +215,15 @@ TEST_F(ValidateControlBlockTest,
|
||||
&u32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::UintLiteral>(Source{}, &u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::SintLiteral>(&i32, -1));
|
||||
csl.push_back(create<ast::SintLiteral>(Source{}, &i32, -1));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl, create<ast::BlockStatement>()));
|
||||
|
||||
@@ -257,21 +257,21 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) {
|
||||
&u32, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::UintLiteral>(&u32, 3)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::UintLiteral>(Source{}, &u32, 3)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::UintLiteral>(&u32, 0));
|
||||
csl_1.push_back(create<ast::UintLiteral>(Source{}, &u32, 0));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(csl_1, create<ast::BlockStatement>()));
|
||||
|
||||
ast::CaseSelectorList csl_2;
|
||||
csl_2.push_back(create<ast::UintLiteral>(&u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(&u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(Source{}, &u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(Source{}, &u32, 2));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl_2, create<ast::BlockStatement>()));
|
||||
|
||||
@@ -305,23 +305,23 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_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
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::SintLiteral>(&i32, 10));
|
||||
csl_1.push_back(create<ast::SintLiteral>(Source{}, &i32, 10));
|
||||
switch_body.push_back(
|
||||
create<ast::CaseStatement>(csl_1, create<ast::BlockStatement>()));
|
||||
|
||||
ast::CaseSelectorList csl_2;
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 0));
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 1));
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 2));
|
||||
csl_2.push_back(create<ast::SintLiteral>(&i32, 10));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 0));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 1));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 2));
|
||||
csl_2.push_back(create<ast::SintLiteral>(Source{}, &i32, 10));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl_2, create<ast::BlockStatement>()));
|
||||
|
||||
@@ -353,8 +353,8 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_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* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
@@ -390,8 +390,8 @@ TEST_F(ValidateControlBlockTest, SwitchCase_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* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
@@ -401,7 +401,7 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) {
|
||||
body.push_back(create<ast::CaseStatement>(Source{Source::Location{12, 34}},
|
||||
default_csl, block_default));
|
||||
ast::CaseSelectorList case_csl;
|
||||
case_csl.push_back(create<ast::SintLiteral>(&i32, 5));
|
||||
case_csl.push_back(create<ast::SintLiteral>(Source{}, &i32, 5));
|
||||
auto* block_case = create<ast::BlockStatement>();
|
||||
body.push_back(create<ast::CaseStatement>(case_csl, block_case));
|
||||
|
||||
@@ -430,8 +430,8 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) {
|
||||
&my_int, // type
|
||||
false, // is_const
|
||||
create<ast::ScalarConstructorExpression>(
|
||||
create<ast::SintLiteral>(&u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
create<ast::SintLiteral>(Source{}, &u32, 2)), // constructor
|
||||
ast::VariableDecorationList{}); // decorations
|
||||
|
||||
auto* cond =
|
||||
create<ast::IdentifierExpression>(mod()->RegisterSymbol("a"), "a");
|
||||
|
||||
Reference in New Issue
Block a user