diag: Add System enumerator to all diagnostics
Describes what Tint system raised the diagnostic.
Use this information in the fuzzers to distinguish between expected and unexpected failure cases in the Transform fuzzer tests.
Fixed: chromium:1206407
Fixed: chromium:1207154
Change-Id: I3b807acafe384a2fc363d2a4165a29693450b3cf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55254
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/src/transform/array_length_from_uniform.cc b/src/transform/array_length_from_uniform.cc
index e965cae..e7fa0f7 100644
--- a/src/transform/array_length_from_uniform.cc
+++ b/src/transform/array_length_from_uniform.cc
@@ -38,6 +38,7 @@
auto* cfg = data.Get<Config>();
if (cfg == nullptr) {
out.Diagnostics().add_error(
+ diag::System::Transform,
"missing transform data for ArrayLengthFromUniform");
return Output(Program(std::move(out)));
}
@@ -95,13 +96,13 @@
// have been run before this transform.
auto* param = call_expr->params()[0]->As<ast::UnaryOpExpression>();
if (!param || param->op() != ast::UnaryOp::kAddressOf) {
- TINT_ICE(ctx.dst->Diagnostics())
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "expected form of arrayLength argument to be &resource.array";
break;
}
auto* accessor = param->expr()->As<ast::MemberAccessorExpression>();
if (!accessor) {
- TINT_ICE(ctx.dst->Diagnostics())
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "expected form of arrayLength argument to be &resource.array";
break;
}
@@ -109,7 +110,7 @@
auto* storage_buffer_sem =
sem.Get(storage_buffer_expr)->As<sem::VariableUser>();
if (!storage_buffer_sem) {
- TINT_ICE(ctx.dst->Diagnostics())
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "expected form of arrayLength argument to be &resource.array";
break;
}
@@ -119,9 +120,10 @@
auto idx_itr = cfg->bindpoint_to_size_index.find(binding);
if (idx_itr == cfg->bindpoint_to_size_index.end()) {
ctx.dst->Diagnostics().add_error(
+ diag::System::Transform,
"missing size index mapping for binding point (" +
- std::to_string(binding.group) + "," +
- std::to_string(binding.binding) + ")");
+ std::to_string(binding.group) + "," +
+ std::to_string(binding.binding) + ")");
continue;
}
diff --git a/src/transform/binding_remapper.cc b/src/transform/binding_remapper.cc
index 3755fff..5873cfe 100644
--- a/src/transform/binding_remapper.cc
+++ b/src/transform/binding_remapper.cc
@@ -45,6 +45,7 @@
auto* remappings = datamap.Get<Remappings>();
if (!remappings) {
out.Diagnostics().add_error(
+ diag::System::Transform,
"BindingRemapper did not find the remapping data");
return Output(Program(std::move(out)));
}
diff --git a/src/transform/bound_array_accessors.cc b/src/transform/bound_array_accessors.cc
index 8d7b68e..e2b1860 100644
--- a/src/transform/bound_array_accessors.cc
+++ b/src/transform/bound_array_accessors.cc
@@ -74,7 +74,8 @@
auto* limit = b.Sub(arr_len, b.Expr(1u));
new_idx = b.Call("min", b.Construct<u32>(ctx->Clone(old_idx)), limit);
} else {
- diags.add_error("invalid 0 size", expr->source());
+ diags.add_error(diag::System::Transform, "invalid 0 size",
+ expr->source());
return nullptr;
}
} else if (auto* c = old_idx->As<ast::ScalarConstructorExpression>()) {
@@ -86,7 +87,8 @@
} else if (auto* uint = lit->As<ast::UintLiteral>()) {
new_idx = b.Expr(std::min(uint->value(), size - 1));
} else {
- diags.add_error("unknown scalar constructor type for accessor",
+ diags.add_error(diag::System::Transform,
+ "unknown scalar constructor type for accessor",
expr->source());
return nullptr;
}
diff --git a/src/transform/calculate_array_length.cc b/src/transform/calculate_array_length.cc
index 4a6f571..ee48611 100644
--- a/src/transform/calculate_array_length.cc
+++ b/src/transform/calculate_array_length.cc
@@ -134,7 +134,7 @@
auto* arg = call_expr->params()[0];
auto* address_of = arg->As<ast::UnaryOpExpression>();
if (!address_of || address_of->op() != ast::UnaryOp::kAddressOf) {
- TINT_ICE(ctx.dst->Diagnostics())
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "arrayLength() expected pointer to member access, got "
<< address_of->TypeInfo().name;
}
@@ -142,7 +142,7 @@
auto* accessor = array_expr->As<ast::MemberAccessorExpression>();
if (!accessor) {
- TINT_ICE(ctx.dst->Diagnostics())
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "arrayLength() expected pointer to member access, got "
"pointer to "
<< array_expr->TypeInfo().name;
@@ -158,7 +158,7 @@
auto buffer_size = get_buffer_size_intrinsic(storage_buffer_type);
if (!storage_buffer_type) {
- TINT_ICE(ctx.dst->Diagnostics())
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "arrayLength(X.Y) expected X to be sem::Struct, got "
<< storage_buffer_type->FriendlyName(ctx.src->Symbols());
break;
diff --git a/src/transform/canonicalize_entry_point_io.cc b/src/transform/canonicalize_entry_point_io.cc
index 41fc8fa..ebac0b9 100644
--- a/src/transform/canonicalize_entry_point_io.cc
+++ b/src/transform/canonicalize_entry_point_io.cc
@@ -69,6 +69,7 @@
auto* cfg = data.Get<Config>();
if (cfg == nullptr) {
out.Diagnostics().add_error(
+ diag::System::Transform,
"missing transform data for CanonicalizeEntryPointIO");
return Output(Program(std::move(out)));
}
@@ -146,7 +147,8 @@
ast::ExpressionList init_values;
for (auto* member : str->Members()) {
if (member->Type()->Is<sem::Struct>()) {
- TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct";
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
+ << "nested pipeline IO struct";
}
if (cfg->builtin_style == BuiltinStyle::kParameter &&
@@ -239,7 +241,8 @@
// Rebuild struct with only the entry point IO attributes.
for (auto* member : str->Members()) {
if (member->Type()->Is<sem::Struct>()) {
- TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct";
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
+ << "nested pipeline IO struct";
}
ast::DecorationList new_decorations = RemoveDecorations(
diff --git a/src/transform/decompose_memory_access.cc b/src/transform/decompose_memory_access.cc
index 57e40346..96a373a 100644
--- a/src/transform/decompose_memory_access.cc
+++ b/src/transform/decompose_memory_access.cc
@@ -352,7 +352,7 @@
op = DecomposeMemoryAccess::Intrinsic::Op::kAtomicCompareExchangeWeak;
break;
default:
- TINT_ICE(builder->Diagnostics())
+ TINT_ICE(Transform, builder->Diagnostics())
<< "invalid IntrinsicType for DecomposeMemoryAccess::Intrinsic: "
<< ty->type_name();
break;
@@ -435,7 +435,7 @@
/// @param expr the expression that performs the access
/// @param access the access
void AddAccess(ast::Expression* expr, BufferAccess&& access) {
- TINT_ASSERT(access.type);
+ TINT_ASSERT(Transform, access.type);
accesses.emplace(expr, std::move(access));
expression_order.emplace_back(expr);
}
@@ -672,7 +672,7 @@
auto* atomic = IntrinsicAtomicFor(ctx.dst, op, el_ty);
if (atomic == nullptr) {
- TINT_ICE(ctx.dst->Diagnostics())
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "IntrinsicAtomicFor() returned nullptr for op " << op
<< " and type " << el_ty->type_name();
}
diff --git a/src/transform/external_texture_transform.cc b/src/transform/external_texture_transform.cc
index 81e4fab..4d48ff7 100644
--- a/src/transform/external_texture_transform.cc
+++ b/src/transform/external_texture_transform.cc
@@ -58,7 +58,7 @@
->Is<sem::ExternalTexture>()) {
if (intrinsic->Type() == sem::IntrinsicType::kTextureLoad &&
call_expr->params().size() != 2) {
- TINT_ICE(ctx.dst->Diagnostics())
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "expected textureLoad call with a texture_external to "
"have 2 parameters, found "
<< call_expr->params().size() << " parameters";
@@ -67,7 +67,7 @@
if (intrinsic->Type() ==
sem::IntrinsicType::kTextureSampleLevel &&
call_expr->params().size() != 3) {
- TINT_ICE(ctx.dst->Diagnostics())
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "expected textureSampleLevel call with a "
"texture_external to have 3 parameters, found "
<< call_expr->params().size() << " parameters";
diff --git a/src/transform/fold_constants.cc b/src/transform/fold_constants.cc
index 9ef726b..3fe3691 100644
--- a/src/transform/fold_constants.cc
+++ b/src/transform/fold_constants.cc
@@ -67,7 +67,7 @@
operator bool() const { return Valid(); }
void Append(const Value& value) {
- TINT_ASSERT(value.type == type);
+ TINT_ASSERT(Transform, value.type == type);
elems.insert(elems.end(), value.elems.begin(), value.elems.end());
}
@@ -89,7 +89,7 @@
return func(elems[index].bool_);
}
}
- TINT_ASSERT(false && "Unreachable");
+ TINT_ASSERT(Transform, false && "Unreachable");
return func(~0);
}
};
@@ -105,7 +105,7 @@
} else if (t->Is<ast::Bool>()) {
return Value::Type::bool_;
}
- TINT_ASSERT(false && "Invalid type");
+ TINT_ASSERT(Transform, false && "Invalid type");
return {};
}
@@ -193,7 +193,7 @@
if (auto* lit = literal->As<ast::BoolLiteral>()) {
return {lit->IsTrue()};
}
- TINT_ASSERT(false && "Unreachable");
+ TINT_ASSERT(Transform, false && "Unreachable");
return {};
}
diff --git a/src/transform/promote_initializers_to_const_var.cc b/src/transform/promote_initializers_to_const_var.cc
index aed8e5d..d0724d3 100644
--- a/src/transform/promote_initializers_to_const_var.cc
+++ b/src/transform/promote_initializers_to_const_var.cc
@@ -52,7 +52,7 @@
if (auto* src_init = src_node->As<ast::TypeConstructorExpression>()) {
auto* src_sem_expr = ctx.src->Sem().Get(src_init);
if (!src_sem_expr) {
- TINT_ICE(ctx.dst->Diagnostics())
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "ast::TypeConstructorExpression has no semantic expression node";
continue;
}
diff --git a/src/transform/renamer.cc b/src/transform/renamer.cc
index d1371b2..c39171f 100644
--- a/src/transform/renamer.cc
+++ b/src/transform/renamer.cc
@@ -857,7 +857,7 @@
if (auto* member = node->As<ast::MemberAccessorExpression>()) {
auto* sem = in->Sem().Get(member);
if (!sem) {
- TINT_ICE(out.Diagnostics())
+ TINT_ICE(Transform, out.Diagnostics())
<< "MemberAccessorExpression has no semantic info";
continue;
}
@@ -867,7 +867,8 @@
} else if (auto* call = node->As<ast::CallExpression>()) {
auto* sem = in->Sem().Get(call);
if (!sem) {
- TINT_ICE(out.Diagnostics()) << "CallExpression has no semantic info";
+ TINT_ICE(Transform, out.Diagnostics())
+ << "CallExpression has no semantic info";
continue;
}
if (sem->Target()->Is<sem::Intrinsic>()) {
diff --git a/src/transform/single_entry_point.cc b/src/transform/single_entry_point.cc
index a926d11..15afa5f 100644
--- a/src/transform/single_entry_point.cc
+++ b/src/transform/single_entry_point.cc
@@ -35,7 +35,8 @@
auto* cfg = data.Get<Config>();
if (cfg == nullptr) {
- out.Diagnostics().add_error("missing transform data for SingleEntryPoint");
+ out.Diagnostics().add_error(diag::System::Transform,
+ "missing transform data for SingleEntryPoint");
return Output(Program(std::move(out)));
}
@@ -51,8 +52,9 @@
}
}
if (entry_point == nullptr) {
- out.Diagnostics().add_error("entry point '" + cfg->entry_point_name +
- "' not found");
+ out.Diagnostics().add_error(
+ diag::System::Transform,
+ "entry point '" + cfg->entry_point_name + "' not found");
return Output(Program(std::move(out)));
}
@@ -81,7 +83,7 @@
out.AST().AddFunction(ctx.Clone(func));
}
} else {
- TINT_UNREACHABLE(out.Diagnostics())
+ TINT_UNREACHABLE(Transform, out.Diagnostics())
<< "unhandled global declaration: " << decl->TypeInfo().name;
return Output(Program(std::move(out)));
}
diff --git a/src/transform/transform.cc b/src/transform/transform.cc
index c334337..914b167 100644
--- a/src/transform/transform.cc
+++ b/src/transform/transform.cc
@@ -134,7 +134,7 @@
if (auto* s = ty->As<sem::Sampler>()) {
return ctx->dst->create<ast::Sampler>(s->kind());
}
- TINT_UNREACHABLE(ctx->dst->Diagnostics())
+ TINT_UNREACHABLE(Transform, ctx->dst->Diagnostics())
<< "Unhandled type: " << ty->TypeInfo().name;
return nullptr;
}
diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc
index dc7e70c..e06dd7c 100644
--- a/src/transform/vertex_pulling.cc
+++ b/src/transform/vertex_pulling.cc
@@ -304,7 +304,8 @@
}
new_function_parameters.push_back(ctx.Clone(param));
} else {
- TINT_ICE(ctx.dst->Diagnostics()) << "Invalid entry point parameter";
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
+ << "Invalid entry point parameter";
}
}
@@ -346,7 +347,8 @@
}
members_to_clone.push_back(member);
} else {
- TINT_ICE(ctx.dst->Diagnostics()) << "Invalid entry point parameter";
+ TINT_ICE(Transform, ctx.dst->Diagnostics())
+ << "Invalid entry point parameter";
}
}
@@ -466,7 +468,8 @@
auto* func = in->AST().Functions().Find(
in->Symbols().Get(cfg.entry_point_name), ast::PipelineStage::kVertex);
if (func == nullptr) {
- out.Diagnostics().add_error("Vertex stage entry point not found");
+ out.Diagnostics().add_error(diag::System::Transform,
+ "Vertex stage entry point not found");
return Output(Program(std::move(out)));
}
diff --git a/src/transform/zero_init_workgroup_memory.cc b/src/transform/zero_init_workgroup_memory.cc
index 100a379..287018c 100644
--- a/src/transform/zero_init_workgroup_memory.cc
+++ b/src/transform/zero_init_workgroup_memory.cc
@@ -78,7 +78,7 @@
return;
}
- TINT_UNREACHABLE(ctx.dst->Diagnostics())
+ TINT_UNREACHABLE(Transform, ctx.dst->Diagnostics())
<< "could not zero workgroup type: " << ty->type_name();
}