[PATCH] D87237: [ADT] Add ASAN Support for SmallVector
Nathan James via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 08:46:35 PDT 2020
njames93 added inline comments.
================
Comment at: llvm/include/llvm/ADT/SmallVector.h:594-600
+ if (&Elt >= this->begin() && &Elt < this->end()) {
+ // If we are inserting from an element inside the SmallVector and we
+ // need to grow, the reference to the element will become invalidated on
+ // the call to grow.
+ T Copy(Elt);
+ return insert(I, std::move(Copy));
+ }
----------------
Is this check the right behaviour, or is inserting an item from a SmallVector into itself considered UB?
If that would be the right behaviour then there is case to also add this check to append, push_back and resize.
If its classed as UB then the test case `SmallVectorTest.PushPopTest` needs addressing, specifically [[ https://github.com/llvm/llvm-project/blob/2e1827271cb1c090cced7369282f9edcf9e59183/llvm/unittests/ADT/SmallVectorTest.cpp#L256 | this line ]].
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87237/new/
https://reviews.llvm.org/D87237
More information about the llvm-commits
mailing list