[PATCH] D83877: [Analyzer] Handle unique_ptr::swap() in SmartPtrModeling

Nithin VR via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 2 13:34:33 PDT 2020


vrnithinkumar marked an inline comment as done.
vrnithinkumar added a comment.

In D83877#2189637 <https://reviews.llvm.org/D83877#2189637>, @NoQ wrote:

> These patches look like they're done, maybe let's land them?

I have already committed this changes.  
https://github.com/llvm/llvm-project/commit/76c0577763505ea3db1017a9aab579c1c2f135d0



================
Comment at: clang/test/Analysis/Inputs/system-header-simulator-cxx.h:964-965
+
+  template <typename T>
+  void swap(unique_ptr<T> &x, unique_ptr<T> &y) noexcept {
+    x.swap(y);
----------------
NoQ wrote:
> vrnithinkumar wrote:
> > xazax.hun wrote:
> > > NoQ wrote:
> > > > You seem to be relying on the fact that global `std::swap` is implemented in terms of the member `std::swap`. That's an implementation detail of the standard library; i'm not sure that this is always the case. Ideally we should model the global `std::swap` separately.
> > > I am not sure how reliable cppreference is, but I think this overload might actually be guaranteed by the standard: https://en.cppreference.com/w/cpp/memory/unique_ptr/swap2
> > I also made the assumption based on this (https://en.cppreference.com/w/cpp/memory/unique_ptr/swap2).
> > 
> Aha, interesting. We still probably can't rely on it being always inlined though, so we'll still probably have to model it separately.
Okay. We will add the separate modeling for `std::swap`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83877



More information about the cfe-commits mailing list