diff --git a/docs/arch.md b/docs/arch.md index 39d14cb3fb..de7fca7a58 100644 --- a/docs/arch.md +++ b/docs/arch.md @@ -36,9 +36,9 @@ ┃ ┃ ┗━━━━━┛ ┗━━━━━━━┛ ┗━━━━━━━━━━┛ ┗━━━━━━━━━┛ ┃ ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┛ ▲ ▼ -┏━━━━━┻━━━━━┓ ┏━━━━━┻━━━━━┓ ┏━━━━━━━━━━━┓ -┃ Transform ┃◄━━━━━━━━━━━━━━━━━◄┃ Validator ┣━━━━━━►┃ Inspector ┃ -┗━━━━━━━━━━━┛ ┗━━━━━┳━━━━━┛ ┗━━━━━━━━━━━┛ +┏━━━━━┻━━━━━┓ ┃ ┏━━━━━━━━━━━┓ +┃ Transform ┃◄━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━►┃ Inspector ┃ +┗━━━━━━━━━━━┛ ┃ ┗━━━━━━━━━━━┛ ▼ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Writer ┃ @@ -148,11 +148,8 @@ The `Resolver` will automatically run when a `Program` is built. 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 @@ A `Program` holds an immutable version of the information from the `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 9cb7e6717d..1d96ec04c3 100644 --- a/fuzzers/tint_common_fuzzer.cc +++ b/fuzzers/tint_common_fuzzer.cc @@ -84,11 +84,6 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) { 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 e0d2c6bb71..f31d8add7d 100644 --- a/samples/main.cc +++ b/samples/main.cc @@ -671,12 +671,6 @@ int main(int argc, const char** argv) { 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 17aa165aac..8e8770c0c8 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -262,8 +262,8 @@ std::map Inspector::GetConstantIDs() { } // 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 1b43289e57..70d1b4c132 100644 --- a/src/resolver/decoration_validation_test.cc +++ b/src/resolver/decoration_validation_test.cc @@ -256,7 +256,7 @@ TEST_P(VariableDecorationTest, IsValid) { } } INSTANTIATE_TEST_SUITE_P( - ValidatorTest, + ResolverDecorationValidationTest, VariableDecorationTest, testing::Values(TestParams{DecorationKind::kAccess, false}, TestParams{DecorationKind::kAlign, false}, @@ -290,7 +290,7 @@ TEST_P(FunctionDecorationTest, IsValid) { } } 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 46bc613df8..da891d58c7 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -1252,8 +1252,7 @@ bool Resolver::MemberAccessor(ast::MemberAccessorExpression* expr) { } } 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(vec->type(), static_cast(size)); }