[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:43:36 PST 2024


================
@@ -100,7 +100,18 @@ template <class Size_T> class SmallVectorBase {
   /// This does not construct or destroy any elements in the vector.
   void set_size(size_t N) {
     assert(N <= capacity());
-    Size = N;
+    Size = static_cast<Size_T>(N);
+    assert(size() == N);
+  }
+
+  /// Set the array capacity to \p M, which the current array size must
+  /// not be greater than.
+  ///
+  /// This does not construct or destroy any elements in the vector.
+  void set_capacity(size_t M) {
+    assert(size() <= M);
----------------
andrey-golubev wrote:

done

https://github.com/llvm/llvm-project/pull/77939


More information about the llvm-commits mailing list