Remove tint's usage of Validator
Also update comments and arch design to remove references to the
Validator.
Bug: tint:642
Change-Id: Ic0b4779ae4712a393ff209014daf25e23f32be6d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47061
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
diff --git a/docs/arch.md b/docs/arch.md
index 39d14cb..de7fca7 100644
--- a/docs/arch.md
+++ b/docs/arch.md
@@ -36,9 +36,9 @@
┃ ┃ ┗━━━━━┛ ┗━━━━━━━┛ ┗━━━━━━━━━━┛ ┗━━━━━━━━━┛ ┃
┃ ┗━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┛
▲ ▼
-┏━━━━━┻━━━━━┓ ┏━━━━━┻━━━━━┓ ┏━━━━━━━━━━━┓
-┃ Transform ┃◄━━━━━━━━━━━━━━━━━◄┃ Validator ┣━━━━━━►┃ Inspector ┃
-┗━━━━━━━━━━━┛ ┗━━━━━┳━━━━━┛ ┗━━━━━━━━━━━┛
+┏━━━━━┻━━━━━┓ ┃ ┏━━━━━━━━━━━┓
+┃ Transform ┃◄━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━►┃ Inspector ┃
+┗━━━━━━━━━━━┛ ┃ ┗━━━━━━━━━━━┛
▼
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Writer ┃
@@ -148,11 +148,8 @@
A `Resolver` creates the `Program`s semantic information by analyzing the
`Program`s AST and type information.
-The `Resolver` will do the minimal amount of validation required in order
-to always be accessing valid nodes, reporting any errors found in the
-`Program`'s diagnostics. Even if the `Resolver` doesn't generate any
-errors doesn't mean the generated `Program` is semantically valid. Use the
-`Validator` to check for a `Program`'s final validity.
+The `Resolver` will validate to make sure the generated `Program` is
+semantically valid.
## Program
@@ -161,21 +158,13 @@
`Resolver`.
Like `ProgramBuilder`, `Program::IsValid()` may be called to ensure the AST is
-structurally correct and that the `Resolver` did not report any errors.
-`Program::IsValid()` does not perform semantic validation, use the `Validator`
-to check for a `Program`'s final validity.
+structurally correct and semantically valid, and that the `Resolver` did not
+report any errors.
Unlike the `ProgramBuilder`, a `Program` is fully immutable, and is part of the
public Tint API. The immutable nature of `Program`s make these entirely safe
to share between multiple threads without the use of synchronization primitives.
-## Validation
-
-The `Validator` checks a `Program` for static validity as specified by the WGSL
-language, and reports any validation errors found. Attempting to pass a
-`Program` that does not pass validation on to later stages will result in
-undefined behavior.
-
## Inspector
The inspectors job is to go through the `Program` and pull out various pieces of
diff --git a/fuzzers/tint_common_fuzzer.cc b/fuzzers/tint_common_fuzzer.cc
index 9cb7e67..1d96ec0 100644
--- a/fuzzers/tint_common_fuzzer.cc
+++ b/fuzzers/tint_common_fuzzer.cc
@@ -84,11 +84,6 @@
return 0;
}
- Validator v;
- if (!v.Validate(&program)) {
- return 0;
- }
-
if (inspector_enabled_) {
inspector::Inspector inspector(&program);
diff --git a/samples/main.cc b/samples/main.cc
index e0d2c6b..f31d8ad 100644
--- a/samples/main.cc
+++ b/samples/main.cc
@@ -671,12 +671,6 @@
return 1;
}
- tint::Validator v;
- if (!v.Validate(program.get())) {
- diag_formatter.format(v.diagnostics(), diag_printer.get());
- return 1;
- }
-
tint::transform::Manager transform_manager;
for (const auto& name : options.transforms) {
// TODO(dsinclair): The vertex pulling transform requires setup code to
diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc
index 17aa165..8e8770c 100644
--- a/src/inspector/inspector.cc
+++ b/src/inspector/inspector.cc
@@ -262,8 +262,8 @@
}
// If there are conflicting defintions for a constant id, that is invalid
- // WGSL, so the validator should catch it. Thus here the inspector just
- // assumes all definitians of the constant id are the same, so only needs
+ // WGSL, so the resolver should catch it. Thus here the inspector just
+ // assumes all definitions of the constant id are the same, so only needs
// to find the first reference to constant id.
uint32_t constant_id = var->constant_id();
if (result.find(constant_id) != result.end()) {
diff --git a/src/resolver/decoration_validation_test.cc b/src/resolver/decoration_validation_test.cc
index 1b43289..70d1b4c 100644
--- a/src/resolver/decoration_validation_test.cc
+++ b/src/resolver/decoration_validation_test.cc
@@ -256,7 +256,7 @@
}
}
INSTANTIATE_TEST_SUITE_P(
- ValidatorTest,
+ ResolverDecorationValidationTest,
VariableDecorationTest,
testing::Values(TestParams{DecorationKind::kAccess, false},
TestParams{DecorationKind::kAlign, false},
@@ -290,7 +290,7 @@
}
}
INSTANTIATE_TEST_SUITE_P(
- ValidatorTest,
+ ResolverDecorationValidationTest,
FunctionDecorationTest,
testing::Values(TestParams{DecorationKind::kAccess, false},
TestParams{DecorationKind::kAlign, false},
diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc
index 46bc613..da891d5 100644
--- a/src/resolver/resolver.cc
+++ b/src/resolver/resolver.cc
@@ -1252,8 +1252,7 @@
}
} else {
// The vector will have a number of components equal to the length of
- // the swizzle. This assumes the validator will check that the swizzle
- // is correct.
+ // the swizzle.
ret = builder_->create<type::Vector>(vec->type(),
static_cast<uint32_t>(size));
}