ast/type: Remove Type suffix from all types

They already exist in a `ast::type` namespace, so `ast::type::BlahType` is just stuttering.
This is more important now that Is<> and As<> use the full type name.

Change-Id: I7c661fe58cdc33ba7e9a95c82c996a799786661f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34321
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2020-11-30 23:30:58 +00:00
parent 03ae9a397f
commit f1b0e1ee57
202 changed files with 3909 additions and 3998 deletions

View File

@@ -42,7 +42,7 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) {
// switch (a) {
// default: {}
// }
ast::type::F32Type f32;
ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&f32, 3.14f)));
@@ -70,7 +70,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) {
// switch (a) {
// case 1: {}
// }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -101,7 +101,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
// case 1: {}
// default: {}
// }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -143,8 +143,8 @@ TEST_F(ValidateControlBlockTest,
// case 1: {}
// default: {}
// }
ast::type::U32Type u32;
ast::type::I32Type i32;
ast::type::U32 u32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -179,8 +179,8 @@ TEST_F(ValidateControlBlockTest,
// case -1: {}
// default: {}
// }
ast::type::U32Type u32;
ast::type::I32Type i32;
ast::type::U32 u32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &u32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(&u32, 2)));
@@ -215,7 +215,7 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) {
// case 2, 2: {}
// default: {}
// }
ast::type::U32Type u32;
ast::type::U32 u32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &u32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::UintLiteral>(&u32, 3)));
@@ -256,7 +256,7 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) {
// case 0,1,2,10: {}
// default: {}
// }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -297,7 +297,7 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) {
// switch (a) {
// default: { fallthrough; }
// }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -327,7 +327,7 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) {
// default: {}
// case 5: {}
// }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -358,8 +358,8 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) {
// default: {}
// }
ast::type::U32Type u32;
ast::type::AliasType my_int{"MyInt", &u32};
ast::type::U32 u32;
ast::type::Alias my_int{"MyInt", &u32};
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &my_int);
var->set_constructor(create<ast::ScalarConstructorExpression>(

View File

@@ -38,13 +38,13 @@ class ValidateFunctionTest : public ValidatorTestHelper,
TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) {
// [[stage(vertex)]]
// fn func -> void { var a:i32 = 2; }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
ast::VariableList params;
ast::type::VoidType void_type;
ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
auto* func = create<ast::Function>(Source{Source::Location{12, 34}}, "func",
@@ -61,7 +61,7 @@ TEST_F(ValidateFunctionTest,
VoidFunctionEndWithoutReturnStatementEmptyBody_Pass) {
// [[stage(vertex)]]
// fn func -> void {}
ast::type::VoidType void_type;
ast::type::Void void_type;
ast::VariableList params;
auto* func =
create<ast::Function>(Source{Source::Location{12, 34}}, "func", params,
@@ -77,13 +77,13 @@ TEST_F(ValidateFunctionTest,
TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
// fn func -> int { var a:i32 = 2; }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
ast::VariableList params;
ast::type::VoidType void_type;
ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(var));
auto* func = create<ast::Function>(Source{Source::Location{12, 34}}, "func",
@@ -98,8 +98,8 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) {
// fn func -> int {}
ast::type::VoidType void_type;
ast::type::I32Type i32;
ast::type::Void void_type;
ast::type::I32 i32;
ast::VariableList params;
auto* func =
create<ast::Function>(Source{Source::Location{12, 34}}, "func", params,
@@ -115,7 +115,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) {
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) {
// [[stage(vertex)]]
// fn func -> void { return; }
ast::type::VoidType void_type;
ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
@@ -131,8 +131,8 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) {
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
// fn func -> void { return 2; }
ast::type::VoidType void_type;
ast::type::I32Type i32;
ast::type::Void void_type;
ast::type::I32 i32;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
auto* return_expr = create<ast::ScalarConstructorExpression>(
@@ -153,8 +153,8 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
// fn func -> f32 { return 2; }
ast::type::I32Type i32;
ast::type::F32Type f32;
ast::type::I32 i32;
ast::type::F32 f32;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
auto* return_expr = create<ast::ScalarConstructorExpression>(
@@ -176,8 +176,8 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
// fn func -> i32 { return 2; }
// fn func -> i32 { return 2; }
ast::type::VoidType void_type;
ast::type::I32Type i32;
ast::type::Void void_type;
ast::type::I32 i32;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
@@ -206,8 +206,8 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
// fn func() -> void {func(); return; }
ast::type::F32Type f32;
ast::type::VoidType void_type;
ast::type::F32 f32;
ast::type::Void void_type;
ast::ExpressionList call_params;
auto* call_expr = create<ast::CallExpression>(
Source{Source::Location{12, 34}},
@@ -226,7 +226,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
// fn func() -> i32 {var a: i32 = func(); return 2; }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
ast::ExpressionList call_params;
auto* call_expr = create<ast::CallExpression>(
@@ -251,7 +251,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
// [[stage(vertex)]]
// fn vtx_main() -> i32 { return 0; }
ast::type::I32Type i32;
ast::type::I32 i32;
ast::VariableList params;
auto* return_expr = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 0));
@@ -273,8 +273,8 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) {
// [[stage(vertex)]]
// fn vtx_func(a : i32) -> void { return; }
ast::type::I32Type i32;
ast::type::VoidType void_type;
ast::type::I32 i32;
ast::type::Void void_type;
ast::VariableList params;
params.push_back(create<ast::Variable>("a", ast::StorageClass::kNone, &i32));
auto* body = create<ast::BlockStatement>();
@@ -296,7 +296,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) {
// [[stage(fragment)]]
// [[stage(vertex)]]
// fn main() -> void { return; }
ast::type::VoidType void_type;
ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -317,7 +317,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) {
TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) {
// [[stage(vertex)]]
// fn vtx_func() -> void { return; }
ast::type::VoidType void_type;
ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());
@@ -332,7 +332,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) {
TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) {
// fn vtx_func() -> void { return; }
ast::type::VoidType void_type;
ast::type::Void void_type;
ast::VariableList params;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::ReturnStatement>());

View File

@@ -85,11 +85,11 @@ bool ValidatorImpl::Validate(const ast::Module* module) {
bool ValidatorImpl::ValidateConstructedTypes(
const std::vector<ast::type::Type*>& constructed_types) {
for (auto* const ct : constructed_types) {
if (ct->Is<ast::type::StructType>()) {
auto* st = ct->As<ast::type::StructType>();
if (ct->Is<ast::type::Struct>()) {
auto* st = ct->As<ast::type::Struct>();
for (auto* member : st->impl()->members()) {
if (member->type()->UnwrapAll()->Is<ast::type::ArrayType>()) {
auto* r = member->type()->UnwrapAll()->As<ast::type::ArrayType>();
if (member->type()->UnwrapAll()->Is<ast::type::Array>()) {
auto* r = member->type()->UnwrapAll()->As<ast::type::Array>();
if (r->IsRuntimeArray()) {
if (member != st->impl()->members().back()) {
add_error(member->source(), "v-0015",
@@ -168,7 +168,7 @@ bool ValidatorImpl::ValidateEntryPoint(const ast::FunctionList& funcs) {
return false;
}
if (!func->return_type()->Is<ast::type::VoidType>()) {
if (!func->return_type()->Is<ast::type::Void>()) {
add_error(
func->source(), "v-0024",
"Entry point function must return void: '" + func->name() + "'");
@@ -207,7 +207,7 @@ bool ValidatorImpl::ValidateFunction(const ast::Function* func) {
}
variable_stack_.pop_scope();
if (!current_function_->return_type()->Is<ast::type::VoidType>()) {
if (!current_function_->return_type()->Is<ast::type::Void>()) {
if (!func->get_last_statement() ||
!func->get_last_statement()->Is<ast::ReturnStatement>()) {
add_error(func->source(), "v-0002",
@@ -223,7 +223,7 @@ bool ValidatorImpl::ValidateReturnStatement(const ast::ReturnStatement* ret) {
// https://github.com/gpuweb/gpuweb/issues/996
ast::type::Type* func_type = current_function_->return_type();
ast::type::VoidType void_type;
ast::type::Void void_type;
auto* ret_type =
ret->has_value() ? ret->value()->result_type()->UnwrapAll() : &void_type;
@@ -265,11 +265,11 @@ bool ValidatorImpl::ValidateDeclStatement(
return false;
}
variable_stack_.set(name, decl->variable());
if (decl->variable()->type()->UnwrapAll()->Is<ast::type::ArrayType>()) {
if (decl->variable()->type()->UnwrapAll()->Is<ast::type::Array>()) {
if (decl->variable()
->type()
->UnwrapAll()
->As<ast::type::ArrayType>()
->As<ast::type::Array>()
->IsRuntimeArray()) {
add_error(decl->source(), "v-0015",
"runtime arrays may only appear as the last "
@@ -317,8 +317,7 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) {
}
auto* cond_type = s->condition()->result_type()->UnwrapAll();
if (!(cond_type->Is<ast::type::I32Type>() ||
cond_type->Is<ast::type::U32Type>())) {
if (!(cond_type->Is<ast::type::I32>() || cond_type->Is<ast::type::U32>())) {
add_error(s->condition()->source(), "v-0025",
"switch statement selector expression must be of a "
"scalar integer type");
@@ -345,11 +344,11 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) {
}
auto v =
static_cast<int32_t>(selector->type()->Is<ast::type::U32Type>()
static_cast<int32_t>(selector->type()->Is<ast::type::U32>()
? selector->As<ast::UintLiteral>()->value()
: selector->As<ast::SintLiteral>()->value());
if (selector_set.count(v)) {
auto v_str = selector->type()->Is<ast::type::U32Type>()
auto v_str = selector->type()->Is<ast::type::U32>()
? selector->As<ast::UintLiteral>()->to_str()
: selector->As<ast::SintLiteral>()->to_str();
add_error(case_stmt->source(), "v-0027",

View File

@@ -62,7 +62,7 @@ class ValidatorTest : public ValidatorTestHelper, public testing::Test {};
TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) {
// 1 = my_var;
ast::type::I32Type i32;
ast::type::I32 i32;
auto* lhs = create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 1));
@@ -77,7 +77,7 @@ TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) {
TEST_F(ValidatorTest, UsingUndefinedVariable_Fail) {
// b = 2;
ast::type::I32Type i32;
ast::type::I32 i32;
auto* lhs =
create<ast::IdentifierExpression>(Source{Source::Location{12, 34}}, "b");
@@ -95,7 +95,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) {
// {
// b = 2;
// }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* lhs =
create<ast::IdentifierExpression>(Source{Source::Location{12, 34}}, "b");
@@ -114,7 +114,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) {
TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) {
// var a :i32 = 2;
// a = 2
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -136,8 +136,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) {
// var a :i32 = 2;
// a = 2.3;
// }
ast::type::F32Type f32;
ast::type::I32Type i32;
ast::type::F32 f32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -164,7 +164,7 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) {
// var a :i32 = 2;
// a = 2
// }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -190,8 +190,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) {
// var a :i32 = 2;
// a = 2.3;
// }
ast::type::F32Type f32;
ast::type::I32Type i32;
ast::type::F32 f32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -218,7 +218,7 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) {
TEST_F(ValidatorTest, GlobalVariableWithStorageClass_Pass) {
// var<in> gloabl_var: f32;
ast::type::F32Type f32;
ast::type::F32 f32;
auto* global_var =
create<ast::Variable>(Source{Source::Location{12, 34}}, "global_var",
ast::StorageClass::kInput, &f32);
@@ -229,7 +229,7 @@ TEST_F(ValidatorTest, GlobalVariableWithStorageClass_Pass) {
TEST_F(ValidatorTest, GlobalVariableNoStorageClass_Fail) {
// var gloabl_var: f32;
ast::type::F32Type f32;
ast::type::F32 f32;
auto* global_var =
create<ast::Variable>(Source{Source::Location{12, 34}}, "global_var",
ast::StorageClass::kNone, &f32);
@@ -241,7 +241,7 @@ TEST_F(ValidatorTest, GlobalVariableNoStorageClass_Fail) {
}
TEST_F(ValidatorTest, GlobalConstantWithStorageClass_Fail) {
// const<in> gloabl_var: f32;
ast::type::F32Type f32;
ast::type::F32 f32;
auto* global_var =
create<ast::Variable>(Source{Source::Location{12, 34}}, "global_var",
ast::StorageClass::kInput, &f32);
@@ -257,7 +257,7 @@ TEST_F(ValidatorTest, GlobalConstantWithStorageClass_Fail) {
TEST_F(ValidatorTest, GlobalConstNoStorageClass_Pass) {
// const gloabl_var: f32;
ast::type::F32Type f32;
ast::type::F32 f32;
auto* global_var =
create<ast::Variable>(Source{Source::Location{12, 34}}, "global_var",
ast::StorageClass::kNone, &f32);
@@ -273,7 +273,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
// fn my_func() -> f32 {
// not_global_var = 3.14f;
// }
ast::type::F32Type f32;
ast::type::F32 f32;
auto* global_var =
create<ast::Variable>("global_var", ast::StorageClass::kPrivate, &f32);
global_var->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -303,8 +303,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
// global_var = 3.14;
// return;
// }
ast::type::F32Type f32;
ast::type::VoidType void_type;
ast::type::F32 f32;
ast::type::Void void_type;
auto* global_var =
create<ast::Variable>("global_var", ast::StorageClass::kPrivate, &f32);
@@ -336,12 +336,12 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) {
// if (true) { var a : f32 = 2.0; }
// a = 3.14;
// }
ast::type::F32Type f32;
ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 2.0)));
ast::type::BoolType bool_type;
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(&bool_type, true));
auto* body = create<ast::BlockStatement>();
@@ -369,7 +369,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
// var a : f32 = 2.0;
// if (true) { a = 3.14; }
// }
ast::type::F32Type f32;
ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 2.0)));
@@ -379,7 +379,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
auto* rhs = create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 3.14f));
ast::type::BoolType bool_type;
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(&bool_type, true));
auto* body = create<ast::BlockStatement>();
@@ -398,8 +398,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
// var global_var0 : f32 = 0.1;
// var global_var1 : i32 = 0;
ast::type::F32Type f32;
ast::type::I32Type i32;
ast::type::F32 f32;
ast::type::I32 i32;
auto* var0 =
create<ast::Variable>("global_var0", ast::StorageClass::kPrivate, &f32);
var0->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -420,8 +420,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
// var global_var : f32 = 0.1;
// var global_var : i32 = 0;
ast::type::F32Type f32;
ast::type::I32Type i32;
ast::type::F32 f32;
ast::type::I32 i32;
auto* var0 =
create<ast::Variable>("global_var", ast::StorageClass::kPrivate, &f32);
var0->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -445,7 +445,7 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) {
// const a :i32 = 2;
// a = 2
// }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -475,8 +475,8 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
// return 0;
// }
ast::type::VoidType void_type;
ast::type::F32Type f32;
ast::type::Void void_type;
ast::type::F32 f32;
auto* global_var =
create<ast::Variable>("a", ast::StorageClass::kPrivate, &f32);
global_var->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -505,9 +505,9 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
// var a :i32 = 2;
// var a :f21 = 2.0;
// }
ast::type::VoidType void_type;
ast::type::I32Type i32;
ast::type::F32Type f32;
ast::type::Void void_type;
ast::type::I32 i32;
ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::SintLiteral>(&i32, 2)));
@@ -537,12 +537,12 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
// if (true) { var a : f32 = 2.0; }
// var a : f32 = 3.14;
// }
ast::type::F32Type f32;
ast::type::F32 f32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 2.0)));
ast::type::BoolType bool_type;
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(&bool_type, true));
auto* body = create<ast::BlockStatement>();
@@ -569,7 +569,7 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
// var a : f32 = 3.14;
// if (true) { var a : f32 = 2.0; }
// }
ast::type::F32Type f32;
ast::type::F32 f32;
auto* var_a_float =
create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var_a_float->set_constructor(create<ast::ScalarConstructorExpression>(
@@ -579,7 +579,7 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
var->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 2.0)));
ast::type::BoolType bool_type;
ast::type::Bool bool_type;
auto* cond = create<ast::ScalarConstructorExpression>(
create<ast::BoolLiteral>(&bool_type, true));
auto* body = create<ast::BlockStatement>();
@@ -598,8 +598,8 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
// func0 { var a : f32 = 2.0; return; }
// func1 { var a : f32 = 3.0; return; }
ast::type::F32Type f32;
ast::type::VoidType void_type;
ast::type::F32 f32;
ast::type::Void void_type;
auto* var0 = create<ast::Variable>("a", ast::StorageClass::kNone, &f32);
var0->set_constructor(create<ast::ScalarConstructorExpression>(
create<ast::FloatLiteral>(&f32, 2.0)));
@@ -636,7 +636,7 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
// var a :i32;
// a = 2;
// }
ast::type::I32Type i32;
ast::type::I32 i32;
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &i32);
td()->RegisterVariableForTesting(var);

View File

@@ -55,7 +55,7 @@ class ValidatorTestHelper {
Context ctx_;
ast::Module mod_;
std::unique_ptr<TypeDeterminer> td_;
ast::type::VoidType void_type_;
ast::type::Void void_type_;
};
} // namespace tint

View File

@@ -42,8 +42,8 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) {
// rt: array<f32>;
// };
ast::type::F32Type f32;
ast::type::ArrayType arr(&f32);
ast::type::F32 f32;
ast::type::Array arr(&f32);
ast::StructMemberList members;
{
ast::StructMemberDecorationList deco;
@@ -57,7 +57,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) {
ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members);
ast::type::StructType struct_type("Foo", st);
ast::type::Struct struct_type("Foo", st);
mod()->AddConstructedType(&struct_type);
EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types()));
@@ -69,8 +69,8 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) {
// rt: array<f32>;
// };
ast::type::F32Type f32;
ast::type::ArrayType arr(&f32);
ast::type::F32 f32;
ast::type::Array arr(&f32);
ast::StructMemberList members;
{
ast::StructMemberDecorationList deco;
@@ -83,7 +83,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) {
}
ast::StructDecorationList decos;
auto* st = create<ast::Struct>(decos, members);
ast::type::StructType struct_type("Foo", st);
ast::type::Struct struct_type("Foo", st);
mod()->AddConstructedType(&struct_type);
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
@@ -99,8 +99,8 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) {
// vf: f32;
// };
ast::type::F32Type f32;
ast::type::ArrayType arr(&f32);
ast::type::F32 f32;
ast::type::Array arr(&f32);
ast::StructMemberList members;
{
ast::StructMemberDecorationList deco;
@@ -114,7 +114,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) {
ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members);
ast::type::StructType struct_type("Foo", st);
ast::type::Struct struct_type("Foo", st);
mod()->AddConstructedType(&struct_type);
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
@@ -131,9 +131,9 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) {
// a: u32;
//}
ast::type::F32Type u32;
ast::type::ArrayType array(&u32);
ast::type::AliasType alias{"RTArr", &array};
ast::type::F32 u32;
ast::type::Array array(&u32);
ast::type::Alias alias{"RTArr", &array};
ast::StructMemberList members;
{
@@ -149,7 +149,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) {
ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members);
ast::type::StructType struct_type("s", st);
ast::type::Struct struct_type("s", st);
mod()->AddConstructedType(&struct_type);
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
EXPECT_EQ(v()->error(),
@@ -165,9 +165,9 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) {
// b: RTArr;
//}
ast::type::F32Type u32;
ast::type::ArrayType array(&u32);
ast::type::AliasType alias{"RTArr", &array};
ast::type::F32 u32;
ast::type::Array array(&u32);
ast::type::Alias alias{"RTArr", &array};
ast::StructMemberList members;
{
@@ -182,7 +182,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) {
ast::StructDecorationList decos;
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
auto* st = create<ast::Struct>(decos, members);
ast::type::StructType struct_type("s", st);
ast::type::Struct struct_type("s", st);
mod()->AddConstructedType(&struct_type);
EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types()));
}
@@ -190,12 +190,12 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) {
TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) {
/// [[stage(vertex)]]
// fn func -> void { var a : array<i32>; }
ast::type::I32Type i32;
ast::type::ArrayType array(&i32);
ast::type::I32 i32;
ast::type::Array array(&i32);
auto* var = create<ast::Variable>("a", ast::StorageClass::kNone, &array);
ast::VariableList params;
ast::type::VoidType void_type;
ast::type::Void void_type;
auto* body = create<ast::BlockStatement>();
body->append(create<ast::VariableDeclStatement>(
Source{Source::Location{12, 34}}, var));