inspector: Use diagnostic lists

Instead of concatenating to a string

Change-Id: Ib70bba2b0dbf9fcb04a232e0e78d3b576ab3ba88
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59203
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-07-21 19:34:03 +00:00 committed by Tint LUCI CQ
parent 81d4ed0d9c
commit fe3ba95e6a
2 changed files with 6 additions and 5 deletions

View File

@ -563,12 +563,13 @@ uint32_t Inspector::GetWorkgroupStorageSize(const std::string& entry_point) {
ast::Function* Inspector::FindEntryPointByName(const std::string& name) { ast::Function* Inspector::FindEntryPointByName(const std::string& name) {
auto* func = program_->AST().Functions().Find(program_->Symbols().Get(name)); auto* func = program_->AST().Functions().Find(program_->Symbols().Get(name));
if (!func) { if (!func) {
error_ += name + " was not found!"; diagnostics_.add_error(diag::System::Inspector, name + " was not found!");
return nullptr; return nullptr;
} }
if (!func->IsEntryPoint()) { if (!func->IsEntryPoint()) {
error_ += name + " is not an entry point!"; diagnostics_.add_error(diag::System::Inspector,
name + " is not an entry point!");
return nullptr; return nullptr;
} }

View File

@ -43,9 +43,9 @@ class Inspector {
~Inspector(); ~Inspector();
/// @returns error messages from the Inspector /// @returns error messages from the Inspector
const std::string& error() { return error_; } std::string error() { return diagnostics_.str(); }
/// @returns true if an error was encountered /// @returns true if an error was encountered
bool has_error() const { return !error_.empty(); } bool has_error() const { return diagnostics_.contains_errors(); }
/// @returns vector of entry point information /// @returns vector of entry point information
std::vector<EntryPoint> GetEntryPoints(); std::vector<EntryPoint> GetEntryPoints();
@ -139,7 +139,7 @@ class Inspector {
private: private:
const Program* program_; const Program* program_;
std::string error_; diag::List diagnostics_;
std::unique_ptr< std::unique_ptr<
std::unordered_map<std::string, UniqueVector<SamplerTexturePair>>> std::unordered_map<std::string, UniqueVector<SamplerTexturePair>>>
sampler_targets_; sampler_targets_;