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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 09:24:21 PDT 2022


nikic added inline comments.


================
Comment at: llvm/include/llvm/ADT/SmallVector.h:1290
 template <typename R>
-SmallVector<ValueTypeFromRangeType<R>,
-            CalculateSmallVectorDefaultInlinedElements<
-                ValueTypeFromRangeType<R>>::value>
+SmallVector<ValueTypeFromRangeType<R>, InlineSize<R>::value>
 to_vector(R &&Range) {
----------------
Why do we need to explicitly pass `InlineSize<R>::value`? Isn't that the default anyway?


================
Comment at: llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp:814
   // Otherwise, create TBAA with the new Len
-  ArrayRef<MDOperand> MDOperands = MD->operands();
-  SmallVector<Metadata *, 4> NextNodes(MDOperands.begin(), MDOperands.end());
+  auto NextNodes = llvm::to_vector_of<Metadata *, 4>(MD->operands());
   ConstantInt *PreviousSize = mdconst::extract<ConstantInt>(NextNodes[3]);
----------------
llvm prefix unnecessary


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