This patch is https://reviews.llvm.org/D129468 follow-up and address one of comment coming from that review: https://reviews.llvm.org/D129468#3643295
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/include/llvm/IR/Metadata.h | ||
---|---|---|
1348 | I’m surprised SmallVector doesn’t have a generic constructor from ArrayRef. I wonder if it should? (why did the iterator_range work before, but ArrayRef doesn’t?) |
llvm/include/llvm/IR/Metadata.h | ||
---|---|---|
1348 | That's because SmallVector has appropriate constructor: template <typename RangeTy> explicit SmallVector(const iterator_range<RangeTy> &R); but is lacking one for ArrayRef. However from what I can see by browsing containers definitions in llvm/ADT, convenience constructors taking ArrayRefs are not very popular. There is only TinyPtrVector which has one. But the same can be said for iterator_range - only SmallVector constructor takes it. |
This looks good to me, but it’d be nice to clean up further somehow later, maybe by adding a new free function.
llvm/include/llvm/IR/Metadata.h | ||
---|---|---|
1348 | I was wondering if to_vector<Metadata *>(operands()) would work here, but it doesn’t have a template for the value type. We’d need a new thing, to_vector_of<>, which took the desired value type as the first parameter. |
Thanks for the review! Sure, I'm gonna continue cleaning up this with to_vector_of in next patch.
I’m surprised SmallVector doesn’t have a generic constructor from ArrayRef. I wonder if it should?
(why did the iterator_range work before, but ArrayRef doesn’t?)