[llvm] [LLVM][ADT] Explicitly convert size_t values to SmallVector's size type (PR #77939)
Andrei Golubev via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 17 07:40:57 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);
----------------
andrey-golubev wrote:
> > i guess there are also cases when we only want to set the capacity?
>
> Such as?
Was thinking of realloc() but we'd anyway reset the pointer (since same memory block being "reused" is an implementation detail).
> I think setting a capacity is intrinsically linked to setting a new storage pointer, which is why it makes sense to do both at once..
yeah, fair point. I was wondering whether `data start != allocation start` but these seem to always be equal (I guess the case when they are not is the custom alignment requirements but I haven't found anything like this).
https://github.com/llvm/llvm-project/pull/77939
More information about the llvm-commits
mailing list