[tint] Remove current_function from ValidateStructure.

The ValidateStructure method only required the current pipeline stage.
Pass that in directly instead of depending on current_function_.

Bug: tint:1313
Change-Id: I13a429aa9d77c8c43fb82d2aa02b25e05b0e3a6c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87143
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2022-04-19 02:32:55 +00:00 committed by Dawn LUCI CQ
parent 3dbeb8b7a5
commit d382e20b00
3 changed files with 7 additions and 6 deletions

View File

@ -2477,7 +2477,10 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) {
}
}
if (!ValidateStructure(out)) {
auto stage = current_function_
? current_function_->Declaration()->PipelineStage()
: ast::PipelineStage::kNone;
if (!ValidateStructure(out, stage)) {
return nullptr;
}

View File

@ -283,7 +283,7 @@ class Resolver {
bool ValidateReturn(const ast::ReturnStatement* ret);
bool ValidateStatements(const ast::StatementList& stmts);
bool ValidateStorageTexture(const ast::StorageTexture* t);
bool ValidateStructure(const sem::Struct* str);
bool ValidateStructure(const sem::Struct* str, ast::PipelineStage stage);
bool ValidateStructureConstructorOrCast(const ast::CallExpression* ctor,
const sem::Struct* struct_type);
bool ValidateSwitch(const ast::SwitchStatement* s);

View File

@ -2043,7 +2043,8 @@ bool Resolver::ValidateAlias(const ast::Alias* alias) {
return true;
}
bool Resolver::ValidateStructure(const sem::Struct* str) {
bool Resolver::ValidateStructure(const sem::Struct* str,
ast::PipelineStage stage) {
auto name = builder_->Symbols().NameFor(str->Declaration()->name);
if (sem::ParseBuiltinType(name) != sem::BuiltinType::kNone) {
AddError("'" + name + "' is a builtin and cannot be redeclared as a struct",
@ -2099,9 +2100,6 @@ bool Resolver::ValidateStructure(const sem::Struct* str) {
return false;
}
auto stage = current_function_
? current_function_->Declaration()->PipelineStage()
: ast::PipelineStage::kNone;
if (auto* invariant = attr->As<ast::InvariantAttribute>()) {
invariant_attribute = invariant;
} else if (auto* location = attr->As<ast::LocationAttribute>()) {