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:
parent
0600796092
commit
b82acac68e
|
@ -45,7 +45,6 @@ Program::Program(ProgramBuilder&& builder) {
|
||||||
if (builder.ResolveOnBuild() && builder.IsValid()) {
|
if (builder.ResolveOnBuild() && builder.IsValid()) {
|
||||||
resolver::Resolver resolver(&builder);
|
resolver::Resolver resolver(&builder);
|
||||||
if (!resolver.Resolve()) {
|
if (!resolver.Resolve()) {
|
||||||
diagnostics_.add_error(resolver.error());
|
|
||||||
is_valid_ = false;
|
is_valid_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,9 @@ bool IsValidStorageTextureImageFormat(ast::ImageFormat format) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Resolver::Resolver(ProgramBuilder* builder)
|
Resolver::Resolver(ProgramBuilder* builder)
|
||||||
: builder_(builder), intrinsic_table_(IntrinsicTable::Create()) {}
|
: builder_(builder),
|
||||||
|
diagnostics_(builder->Diagnostics()),
|
||||||
|
intrinsic_table_(IntrinsicTable::Create()) {}
|
||||||
|
|
||||||
Resolver::~Resolver() = default;
|
Resolver::~Resolver() = default;
|
||||||
|
|
||||||
|
@ -158,7 +160,7 @@ bool Resolver::Resolve() {
|
||||||
|
|
||||||
bool result = ResolveInternal();
|
bool result = ResolveInternal();
|
||||||
|
|
||||||
if (result && diagnostics_.contains_errors()) {
|
if (!result && !diagnostics_.contains_errors()) {
|
||||||
TINT_ICE(diagnostics_) << "resolving failed, but no error was raised";
|
TINT_ICE(diagnostics_) << "resolving failed, but no error was raised";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,8 +360,8 @@ class Resolver {
|
||||||
void Mark(const ast::Node* node);
|
void Mark(const ast::Node* node);
|
||||||
|
|
||||||
ProgramBuilder* const builder_;
|
ProgramBuilder* const builder_;
|
||||||
|
diag::List& diagnostics_;
|
||||||
std::unique_ptr<IntrinsicTable> const intrinsic_table_;
|
std::unique_ptr<IntrinsicTable> const intrinsic_table_;
|
||||||
diag::List diagnostics_;
|
|
||||||
BlockInfo* current_block_ = nullptr;
|
BlockInfo* current_block_ = nullptr;
|
||||||
ScopeStack<VariableInfo*> variable_stack_;
|
ScopeStack<VariableInfo*> variable_stack_;
|
||||||
std::unordered_map<Symbol, FunctionInfo*> symbol_to_function_;
|
std::unordered_map<Symbol, FunctionInfo*> symbol_to_function_;
|
||||||
|
|
Loading…
Reference in New Issue