From b82acac68ebc2294b2a5155e0f2b7f0609e515b4 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Thu, 6 May 2021 16:04:03 +0000 Subject: [PATCH] Resolver: Clean up diagnostics Don't have a separate diagnostic list, just put the errors straight into the ProgramBuilder's diagnostics. This also fixes an issue where we were taking the stringified diagnostic list and creating a single error on resolution failure. This was the cause of the `error: error:` messages sometimes seen. Also fix a stupid negated-logic bug around the "resolving failed, but no error was raised" ICE. Change-Id: Iddf1f61e4be21137731dfc204210562abbf612b0 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49963 Commit-Queue: Ben Clayton Reviewed-by: James Price --- src/program.cc | 1 - src/resolver/resolver.cc | 6 ++++-- src/resolver/resolver.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/program.cc b/src/program.cc index 9029bb5d3d..dff561617b 100644 --- a/src/program.cc +++ b/src/program.cc @@ -45,7 +45,6 @@ Program::Program(ProgramBuilder&& builder) { if (builder.ResolveOnBuild() && builder.IsValid()) { resolver::Resolver resolver(&builder); if (!resolver.Resolve()) { - diagnostics_.add_error(resolver.error()); is_valid_ = false; } } diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc index 9779c40bc6..b46e4fef75 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -124,7 +124,9 @@ bool IsValidStorageTextureImageFormat(ast::ImageFormat format) { } // namespace Resolver::Resolver(ProgramBuilder* builder) - : builder_(builder), intrinsic_table_(IntrinsicTable::Create()) {} + : builder_(builder), + diagnostics_(builder->Diagnostics()), + intrinsic_table_(IntrinsicTable::Create()) {} Resolver::~Resolver() = default; @@ -158,7 +160,7 @@ bool Resolver::Resolve() { bool result = ResolveInternal(); - if (result && diagnostics_.contains_errors()) { + if (!result && !diagnostics_.contains_errors()) { TINT_ICE(diagnostics_) << "resolving failed, but no error was raised"; return false; } diff --git a/src/resolver/resolver.h b/src/resolver/resolver.h index 1780cb86e5..442613878c 100644 --- a/src/resolver/resolver.h +++ b/src/resolver/resolver.h @@ -360,8 +360,8 @@ class Resolver { void Mark(const ast::Node* node); ProgramBuilder* const builder_; + diag::List& diagnostics_; std::unique_ptr const intrinsic_table_; - diag::List diagnostics_; BlockInfo* current_block_ = nullptr; ScopeStack variable_stack_; std::unordered_map symbol_to_function_;