mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 22:17:51 +00:00
Add diag::List::add_error() helper
Refactors a common pattern in the tint codebase. Change-Id: Ia8a70d952fd8c204facd0120f24e43ccc9305622 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38840 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
a6b9a8eb2f
commit
1461cd96d6
@@ -102,11 +102,7 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
|
||||
auto* limit = b.Sub(arr_len, b.Expr(1u));
|
||||
new_idx = b.Call("min", b.Construct<u32>(ctx->Clone(old_idx)), limit);
|
||||
} else {
|
||||
diag::Diagnostic err;
|
||||
err.severity = diag::Severity::Error;
|
||||
err.message = "invalid 0 size";
|
||||
err.source = expr->source();
|
||||
diags->add(std::move(err));
|
||||
diags->add_error("invalid 0 size", expr->source());
|
||||
return nullptr;
|
||||
}
|
||||
} else if (auto* c = old_idx->As<ast::ScalarConstructorExpression>()) {
|
||||
@@ -118,11 +114,8 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform(
|
||||
} else if (auto* uint = lit->As<ast::UintLiteral>()) {
|
||||
new_idx = b.Expr(std::min(uint->value(), size - 1));
|
||||
} else {
|
||||
diag::Diagnostic err;
|
||||
err.severity = diag::Severity::Error;
|
||||
err.message = "unknown scalar constructor type for accessor";
|
||||
err.source = expr->source();
|
||||
diags->add(std::move(err));
|
||||
diags->add_error("unknown scalar constructor type for accessor",
|
||||
expr->source());
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -88,11 +88,9 @@ Transform::Output FirstIndexOffset::Run(const Program* in) {
|
||||
for (ast::Variable* var : in->AST().GlobalVariables()) {
|
||||
if (auto* dec_var = var->As<ast::Variable>()) {
|
||||
if (dec_var->symbol() == in->Symbols().Get(kBufferName)) {
|
||||
diag::Diagnostic err;
|
||||
err.message = "First index offset transform has already been applied.";
|
||||
err.severity = diag::Severity::Error;
|
||||
Output out;
|
||||
out.diagnostics.add(std::move(err));
|
||||
out.diagnostics.add_error(
|
||||
"First index offset transform has already been applied.");
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -106,11 +104,8 @@ Transform::Output FirstIndexOffset::Run(const Program* in) {
|
||||
ProgramBuilder builder = in->CloneAsBuilder();
|
||||
TypeDeterminer td(&builder);
|
||||
if (!td.Determine()) {
|
||||
diag::Diagnostic err;
|
||||
err.severity = diag::Severity::Error;
|
||||
err.message = td.error();
|
||||
Output out;
|
||||
out.diagnostics.add(std::move(err));
|
||||
out.diagnostics.add_error(td.error());
|
||||
return out;
|
||||
}
|
||||
program = Program(std::move(builder));
|
||||
|
||||
@@ -78,11 +78,8 @@ void VertexPulling::SetPullingBufferBindingSet(uint32_t number) {
|
||||
Transform::Output VertexPulling::Run(const Program* in) {
|
||||
// Check SetVertexState was called
|
||||
if (!cfg.vertex_state_set) {
|
||||
diag::Diagnostic err;
|
||||
err.severity = diag::Severity::Error;
|
||||
err.message = "SetVertexState not called";
|
||||
Output out;
|
||||
out.diagnostics.add(std::move(err));
|
||||
out.diagnostics.add_error("SetVertexState not called");
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -90,11 +87,8 @@ Transform::Output VertexPulling::Run(const Program* in) {
|
||||
auto* func = in->AST().Functions().Find(
|
||||
in->Symbols().Get(cfg.entry_point_name), ast::PipelineStage::kVertex);
|
||||
if (func == nullptr) {
|
||||
diag::Diagnostic err;
|
||||
err.severity = diag::Severity::Error;
|
||||
err.message = "Vertex stage entry point not found";
|
||||
Output out;
|
||||
out.diagnostics.add(std::move(err));
|
||||
out.diagnostics.add_error("Vertex stage entry point not found");
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user