[all-commits] [llvm/llvm-project] 9abac6: ADT: Fix reference invalidation in SmallVector::pu...

Duncan P. N. Exon Smith via All-commits all-commits at lists.llvm.org
Wed Jan 13 18:59:06 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9abac60309006db00eca0af406c2e16bef26807c
      https://github.com/llvm/llvm-project/commit/9abac60309006db00eca0af406c2e16bef26807c
  Author: Duncan P. N. Exon Smith <dexonsmith at apple.com>
  Date:   2021-01-13 (Wed, 13 Jan 2021)

  Changed paths:
    M llvm/include/llvm/ADT/SmallVector.h
    M llvm/unittests/ADT/SmallVectorTest.cpp

  Log Message:
  -----------
  ADT: Fix reference invalidation in SmallVector::push_back and single-element insert

For small enough, trivially copyable `T`, take the argument by value in
`SmallVector::push_back` and copy it when forwarding to
`SmallVector::insert_one_impl`. Otherwise, when growing, update the
argument appropriately.

Differential Revision: https://reviews.llvm.org/D93779




More information about the All-commits mailing list