[PATCH] D77601: Make SmallVector assert if it cannot grow.

David Tellenbach via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 17:29:27 PDT 2020


tellenbach added inline comments.


================
Comment at: llvm/lib/Support/SmallVector.cpp:42
 /// on POD-like datatypes and is out of line to reduce code duplication.
 void SmallVectorBase::grow_pod(void *FirstEl, size_t MinCapacity,
                                size_t TSize) {
----------------
Could you change this function's comment to include that the SmallVector needs to be able to grow by at least one element (please also change in `llvm/include/llvm/ADT/SmallVector.h`)? This is currently only documented for `grow` but your patch adds a restriction that should be documented locally. 


================
Comment at: llvm/lib/Support/SmallVector.cpp:51
+  // default MinCapacity of 0, but the current capacity cannot be increased.
+  if (capacity() == size_t(UINT32_MAX))
+    report_bad_alloc_error("SmallVector capacity unable to grow");
----------------
Can you use `Capacity` directly and omit the function call? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77601





More information about the llvm-commits mailing list