tint/utils: Remove non-const accessors on VectorRef

Nothing uses these, and the mutability of these breaks
const-correctness.

Switch functions that used to return `const utils::Vector<T, N>&`
to returning `utils::VectorRef<T>`. Removes the templated size from the
public interface.

Replace all `const utils::VectorRef<T>&` with `utils::Vector<T>`,
there's no point in using yet another level of pointer indirection.

Change-Id: Ib96e3171500606d9afffbb13f40023552a74fffc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113021
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton
2022-12-06 19:39:02 +00:00
committed by Dawn LUCI CQ
parent 6016d1e5cd
commit 49334b05cf
20 changed files with 50 additions and 84 deletions

View File

@@ -1745,7 +1745,7 @@ const sem::Type* Resolver::ConcreteType(const sem::Type* ty,
return nullptr;
},
[&](const sem::Struct* s) -> const sem::Type* {
if (auto& tys = s->ConcreteTypes(); !tys.IsEmpty()) {
if (auto tys = s->ConcreteTypes(); !tys.IsEmpty()) {
return target_ty ? target_ty : tys[0];
}
return nullptr;

View File

@@ -1811,7 +1811,7 @@ bool Validator::Matrix(const sem::Matrix* ty, const Source& source) const {
return true;
}
bool Validator::PipelineStages(const utils::VectorRef<sem::Function*> entry_points) const {
bool Validator::PipelineStages(utils::VectorRef<sem::Function*> entry_points) const {
auto backtrace = [&](const sem::Function* func, const sem::Function* entry_point) {
if (func != entry_point) {
TraverseCallChain(diagnostics_, entry_point, func, [&](const sem::Function* f) {
@@ -1906,7 +1906,7 @@ bool Validator::PipelineStages(const utils::VectorRef<sem::Function*> entry_poin
return true;
}
bool Validator::PushConstants(const utils::VectorRef<sem::Function*> entry_points) const {
bool Validator::PushConstants(utils::VectorRef<sem::Function*> entry_points) const {
for (auto* entry_point : entry_points) {
// State checked and modified by check_push_constant so that it remembers previously seen
// push_constant variables for an entry-point.
@@ -2422,7 +2422,7 @@ bool Validator::CheckTypeAccessAddressSpace(
const sem::Type* store_ty,
ast::Access access,
ast::AddressSpace address_space,
const utils::VectorRef<const tint::ast::Attribute*> attributes,
utils::VectorRef<const tint::ast::Attribute*> attributes,
const Source& source) const {
if (!AddressSpaceLayout(store_ty, address_space, source)) {
return false;

View File

@@ -135,12 +135,12 @@ class Validator {
/// Validates pipeline stages
/// @param entry_points the entry points to the module
/// @returns true on success, false otherwise.
bool PipelineStages(const utils::VectorRef<sem::Function*> entry_points) const;
bool PipelineStages(utils::VectorRef<sem::Function*> entry_points) const;
/// Validates push_constant variables
/// @param entry_points the entry points to the module
/// @returns true on success, false otherwise.
bool PushConstants(const utils::VectorRef<sem::Function*> entry_points) const;
bool PushConstants(utils::VectorRef<sem::Function*> entry_points) const;
/// Validates aliases
/// @param alias the alias to validate
@@ -508,7 +508,7 @@ class Validator {
bool CheckTypeAccessAddressSpace(const sem::Type* store_ty,
ast::Access access,
ast::AddressSpace address_space,
const utils::VectorRef<const tint::ast::Attribute*> attributes,
utils::VectorRef<const tint::ast::Attribute*> attributes,
const Source& source) const;
SymbolTable& symbols_;
diag::List& diagnostics_;