[tint] Remove current_function from ValidateReturn.

The current_function was used to retrieve the functions return type.
Pass it in directly instead of using current_function.

Bug: tint:1313
Change-Id: Ie29407aecc51e8453460f46437b5c011088c3749
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87145
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2022-04-19 03:26:34 +00:00 committed by Dawn LUCI CQ
parent 8c67fec731
commit 5d4cac1da1
3 changed files with 5 additions and 5 deletions

View File

@ -2507,7 +2507,7 @@ sem::Statement* Resolver::ReturnStatement(const ast::ReturnStatement* stmt) {
// Validate after processing the return value expression so that its type // Validate after processing the return value expression so that its type
// is available for validation. // is available for validation.
return ValidateReturn(stmt); return ValidateReturn(stmt, current_function_->ReturnType());
}); });
} }

View File

@ -280,7 +280,8 @@ class Resolver {
bool ValidateFunctionParameter(const ast::Function* func, bool ValidateFunctionParameter(const ast::Function* func,
const sem::Variable* var); const sem::Variable* var);
bool ValidateParameter(const ast::Function* func, const sem::Variable* var); bool ValidateParameter(const ast::Function* func, const sem::Variable* var);
bool ValidateReturn(const ast::ReturnStatement* ret); bool ValidateReturn(const ast::ReturnStatement* ret,
const sem::Type* func_type);
bool ValidateStatements(const ast::StatementList& stmts); bool ValidateStatements(const ast::StatementList& stmts);
bool ValidateStorageTexture(const ast::StorageTexture* t); bool ValidateStorageTexture(const ast::StorageTexture* t);
bool ValidateStructure(const sem::Struct* str, ast::PipelineStage stage); bool ValidateStructure(const sem::Struct* str, ast::PipelineStage stage);

View File

@ -2181,9 +2181,8 @@ bool Resolver::ValidateLocationAttribute(
return true; return true;
} }
bool Resolver::ValidateReturn(const ast::ReturnStatement* ret) { bool Resolver::ValidateReturn(const ast::ReturnStatement* ret,
auto* func_type = current_function_->ReturnType(); const sem::Type* func_type) {
auto* ret_type = ret->value ? TypeOf(ret->value)->UnwrapRef() auto* ret_type = ret->value ? TypeOf(ret->value)->UnwrapRef()
: builder_->create<sem::Void>(); : builder_->create<sem::Void>();