mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-08 13:14:56 +00:00
validator: Migrate to using diagnostics
Unlike error strings, diagnostics can: * Describe more than one error * Be printed with colors * Highlight (`^^^`) the particular error on the line * Can have separate severities Change-Id: I4ead391ffbe190e55f79c5f23536a4524768478d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33820 Commit-Queue: David Neto <dneto@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
b7b6a3f3f4
commit
ba06db6e00
@@ -420,6 +420,9 @@ int main(int argc, const char** argv) {
|
||||
|
||||
tint::Context ctx(std::make_unique<tint::NoopNamer>());
|
||||
|
||||
auto diag_printer = tint::diag::Printer::create(stderr, true);
|
||||
tint::diag::Formatter diag_formatter;
|
||||
|
||||
std::unique_ptr<tint::reader::Reader> reader;
|
||||
std::unique_ptr<tint::Source::File> source_file;
|
||||
#if TINT_BUILD_WGSL_READER
|
||||
@@ -478,8 +481,7 @@ int main(int argc, const char** argv) {
|
||||
return 1;
|
||||
}
|
||||
if (!reader->Parse()) {
|
||||
auto printer = tint::diag::Printer::create(stderr, true);
|
||||
tint::diag::Formatter().format(reader->diagnostics(), printer.get());
|
||||
diag_formatter.format(reader->diagnostics(), diag_printer.get());
|
||||
return 1;
|
||||
}
|
||||
auto mod = reader->module();
|
||||
@@ -503,7 +505,7 @@ int main(int argc, const char** argv) {
|
||||
|
||||
tint::Validator v;
|
||||
if (!v.Validate(&mod)) {
|
||||
std::cerr << "Validation: " << v.error() << std::endl;
|
||||
diag_formatter.format(v.diagnostics(), diag_printer.get());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user