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 <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton 2021-05-06 16:04:03 +00:00 committed by Commit Bot service account
parent 0600796092
commit b82acac68e
3 changed files with 5 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -360,8 +360,8 @@ class Resolver {
void Mark(const ast::Node* node);
ProgramBuilder* const builder_;
diag::List& diagnostics_;
std::unique_ptr<IntrinsicTable> const intrinsic_table_;
diag::List diagnostics_;
BlockInfo* current_block_ = nullptr;
ScopeStack<VariableInfo*> variable_stack_;
std::unordered_map<Symbol, FunctionInfo*> symbol_to_function_;