[PATCH] D136242: [IntervalMap] Add move and copy ctors and assignment operators

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 25 05:07:40 PDT 2022


Orlando updated this revision to Diff 470446.
Orlando added a comment.

This is somewhat fiddly - I think I've got it this time though.

I have used forwarding constructors this time. There's a gottcha - the move/copy constructors set the allocator field before calling the assignment operator, which calls `clear`. If the IntervalMap constructor was ever changed to allocate nodes then that `clear` call would deallocate using the wrong allocator. I've added an assertion to the move/copy constructors to help catch this.

I've slightly updated the test (see the inline comment).

I've added a few comments this time round, including a method group docu-comment explaining a requirement of the lifetime of the allocator of RHS.


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

https://reviews.llvm.org/D136242

Files:
  llvm/include/llvm/ADT/IntervalMap.h
  llvm/unittests/ADT/IntervalMapTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136242.470446.patch
Type: text/x-patch
Size: 7258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221025/757377d8/attachment.bin>


More information about the llvm-commits mailing list