Simplify calls to ast::Node::[to_]str()

Add helpers on Program and ProgramBuilder that significantly simplify
usage.
Also demangle - this also reduces a bunch of copy-pasta code.

Change-Id: I6215c346e7f6e49c20aced058a6150603253ed93
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/39342
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2021-01-29 11:22:40 +00:00
committed by Commit Bot service account
parent dd1b6fca9f
commit 708dc2d040
69 changed files with 356 additions and 465 deletions

View File

@@ -16,7 +16,6 @@
#include <string>
#include <unordered_set>
#include "src/demangler.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/writer/wgsl/generator.h"
@@ -62,8 +61,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
tint::Program dst(src.Clone());
// Expect the demangled AST printed with to_str() to match
tint::Demangler d;
ASSERT_EQ(d.Demangle(src), d.Demangle(dst));
ASSERT_EQ(src.to_str(), dst.to_str());
// Check that none of the AST nodes or type pointers in dst are found in src
std::unordered_set<tint::ast::Node*> src_nodes;