[PATCH] D93532: [ADT] Add resize_for_overwrite method to SmallVector.

Nathan James via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 18 15:24:28 PST 2020


njames93 added a comment.

In D93532#2463881 <https://reviews.llvm.org/D93532#2463881>, @dexonsmith wrote:

> I wonder if this can be tested, something like:
>
>   V.push_back(5);
>   V.pop_back();
>   V.resize_for_overwrite(V.size() + 1);
>   EXPECT_EQ(5, V.back());
>   V.pop_back();
>   V.resize(V.size() + 1);
>   EXPECT_EQ(0, V.back());

Was thinking of a good way to test what is essentially undefined behaviour, how will this work under msan??



================
Comment at: llvm/include/llvm/ADT/SmallVector.h:466
     if (N < this->size()) {
-      this->destroy_range(this->begin()+N, this->end());
+      this->destroy_range(this->begin() + N, this->end());
       this->set_size(N);
----------------
dexonsmith wrote:
> This whitespace change seems unrelated; can you commit separately?
It's not strictly unrelated, but it was a clang format artefact 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93532



More information about the llvm-commits mailing list