Move CheckBuffer to helper from CheckType. Spilt the CheckBuffer helper out of CheckType. Change-Id: I6121f28ea748a70a3322cd45dacf8c7b88381caf Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/320665 Reviewed-by: James Price <jrprice@google.com> Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/core/ir/structural_validator.cc b/src/tint/lang/core/ir/structural_validator.cc index 4d58242..ff00bd5 100644 --- a/src/tint/lang/core/ir/structural_validator.cc +++ b/src/tint/lang/core/ir/structural_validator.cc
@@ -706,13 +706,7 @@ [&](const core::type::BindingArray* t) { return CheckBindingArray(t, diag, addrspace); }, - [&](const core::type::Buffer*) { - if (!ir_.properties.Contains(Property::kAllowBufferTypes)) { - diag() << "buffer types are not allowed in this context"; - return false; - } - return true; - }, + [&](const core::type::Buffer*) { return CheckBuffer(diag); }, [](Default) { return true; }); }; @@ -773,6 +767,14 @@ } } +bool Structural::CheckBuffer(std::function<diag::Diagnostic&()>& diag) { + if (!ir_.properties.Contains(Property::kAllowBufferTypes)) { + diag() << "buffer types are not allowed in this context"; + return false; + } + return true; +} + bool Structural::CheckBindingArray(const core::type::BindingArray* ba, std::function<diag::Diagnostic&()>& diag, core::AddressSpace addrspace) {
diff --git a/src/tint/lang/core/ir/structural_validator.h b/src/tint/lang/core/ir/structural_validator.h index e051458..15e5265 100644 --- a/src/tint/lang/core/ir/structural_validator.h +++ b/src/tint/lang/core/ir/structural_validator.h
@@ -388,6 +388,10 @@ std::function<diag::Diagnostic&()>& diag, core::AddressSpace addrspace); + /// Checks that buffers are available + /// @param diag a function that creates an error diagnostic for the source of the type + bool CheckBuffer(std::function<diag::Diagnostic&()>& diag); + /// Checks that 8-bit types are permitted /// @param diag a function that creates an error diagnostic for the source of the type /// @param parent the parent type for the 8-bit type