[llvm] [LLVM][ADT] Explicitly convert size_t values to SmallVector's size type (PR #77939)
Andrew Browne via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 15 09:58:44 PST 2024
================
@@ -468,7 +469,7 @@ void SmallVectorTemplateBase<T, TriviallyCopyable>::takeAllocationForGrow(
free(this->begin());
this->BeginX = NewElts;
- this->Capacity = NewCapacity;
+ this->Capacity = static_cast<SmallVectorSizeType<T>>(NewCapacity);
----------------
browneee wrote:
Thanks.
After seeing this change, I think it would probably make sense to include this line in the new function:
```
this->BeginX = NewElts;
```
... setting the allocation pointer and the capacity together makes sense.
This would also change the name of the new function:
```
/// Set the allocation to \p A and the capacity to \p M.
///
/// This does not construct or destroy any elements in the vector.
/// This does not clean up any existing allocation.
void set_allocation_and_capacity(void *A, size_t M) {
```
https://github.com/llvm/llvm-project/pull/77939
More information about the llvm-commits
mailing list