[PATCH] D93654: [TableGen] Change getAllDerivedDefinitions() to return const vector &

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 21 11:44:41 PST 2020


dblaikie added a comment.

In D93654#2466565 <https://reviews.llvm.org/D93654#2466565>, @Paul-C-Anagnostopoulos wrote:

> Is ArrayRef better in some stylistic sense? I'm happy to switch to it.

It allows more flexibility in the implementation of such a function (eg: if you change the backing storage to be SmallVector<T>, the API doesn't change - whereas if the API is "const std::vector<T> &" then implementations are constrained to only be able to implement their backing store using std::vector)

> How do you declare that the vector pointed to by the ArrayRef is constant?

ArrayRef<T> is constant - there is no API to mutate elements of the array. MutableArrayRef<T> is the mutable equivalent.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93654/new/

https://reviews.llvm.org/D93654



More information about the llvm-commits mailing list