[PATCH] D129781: [NFC] Introduce llvm::to_vector_of to allow creation of SmallVector<T> from range of items convertible to type T

Dawid Jurczak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 2 01:14:53 PDT 2022


yurai007 added inline comments.


================
Comment at: llvm/unittests/ADT/SmallVectorTest.cpp:1182-1221
+  {
+    llvm::SmallVector<From *> Vector = llvm::to_vector_of<From *>(StdVector);
+
+    ASSERT_EQ(StdVector.size(), Vector.size());
+    for (size_t I = 0; I < StdVector.size(); ++I) {
+      EXPECT_EQ(StdVector[I], Vector[I]);
+      EXPECT_EQ(*StdVector[I], *Vector[I]);
----------------
dblaikie wrote:
> I guess this is how the other to_vectors were already tested? But if you're up for it in a pre or post commit, might be nice to simplify this - like I'm not sure it's necessary to test all these variants. The implementation is generic - it tests anything you can do begin(x) and end(x) on, so we probably only need to test one such type? But if we really want to test 4, perhaps we can avoid rewriting the code and use a type expansion in gunit?)
I agree it's not necessary so eventually decided to remove ArrayRef variants.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129781



More information about the llvm-commits mailing list