Skip to content

Commit

Permalink
[ADT] Fix iplist_impl - use after move warnings (PR43943)
Browse files Browse the repository at this point in the history
As detailed on PR43943, we're seeing static analyzer use after move warnings in the iplist_impl move constructor/operator as they call std::move to both the TraitsT and IntrusiveListT base classes.

As suggested by @dexonsmith this patch casts the moved value to the base classes to silence the warnings.

Differential Revision: https://reviews.llvm.org/D74062
  • Loading branch information
RKSimon committed Feb 6, 2020
1 parent d5e6e0a commit 529e6f8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions llvm/include/llvm/ADT/ilist.h
Expand Up @@ -198,10 +198,12 @@ class iplist_impl : public TraitsT, IntrusiveListT {
iplist_impl &operator=(const iplist_impl &) = delete;

iplist_impl(iplist_impl &&X)
: TraitsT(std::move(X)), IntrusiveListT(std::move(X)) {}
: TraitsT(std::move(static_cast<TraitsT &>(X))),
IntrusiveListT(std::move(static_cast<IntrusiveListT &>(X))) {}
iplist_impl &operator=(iplist_impl &&X) {
*static_cast<TraitsT *>(this) = std::move(X);
*static_cast<IntrusiveListT *>(this) = std::move(X);
*static_cast<TraitsT *>(this) = std::move(static_cast<TraitsT &>(X));
*static_cast<IntrusiveListT *>(this) =
std::move(static_cast<IntrusiveListT &>);
return *this;
}

Expand Down

0 comments on commit 529e6f8

Please sign in to comment.