Add ast::InternalDecoration

An tint-internal decoration used to add metadata between a sanitizer transform and a backend.

Will be used for declaring backend-specific intrinsic calls.

Change-Id: Ia05ba7dada0148de2d490605ba4d15c593075356
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46868
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2021-04-07 08:09:21 +00:00
committed by Commit Bot service account
parent 86c2cbfb7e
commit b502fdf82b
9 changed files with 138 additions and 11 deletions

View File

@@ -26,6 +26,7 @@
#include "src/ast/discard_statement.h"
#include "src/ast/fallthrough_statement.h"
#include "src/ast/if_statement.h"
#include "src/ast/internal_decoration.h"
#include "src/ast/loop_statement.h"
#include "src/ast/return_statement.h"
#include "src/ast/struct_block_decoration.h"
@@ -301,12 +302,18 @@ bool Resolver::ValidateFunction(const ast::Function* func) {
}
if (!func->return_type()->Is<type::Void>()) {
if (!func->get_last_statement() ||
!func->get_last_statement()->Is<ast::ReturnStatement>()) {
diagnostics_.add_error(
"v-0002", "non-void function must end with a return statement",
func->source());
return false;
if (func->body()) {
if (!func->get_last_statement() ||
!func->get_last_statement()->Is<ast::ReturnStatement>()) {
diagnostics_.add_error(
"v-0002", "non-void function must end with a return statement",
func->source());
return false;
}
} else if (!func->find_decoration<ast::InternalDecoration>()) {
TINT_ICE(diagnostics_)
<< "Function " << builder_->Symbols().NameFor(func->symbol())
<< " has no body and does not have the [[internal]] decoration";
}
for (auto* deco : func->return_type_decorations()) {
@@ -594,8 +601,10 @@ bool Resolver::Function(ast::Function* func) {
}
}
if (!BlockStatement(func->body())) {
return false;
if (func->body()) {
if (!BlockStatement(func->body())) {
return false;
}
}
variable_stack_.pop_scope();