Commit 529e6f87 authored by Simon Pilgrim's avatar Simon Pilgrim
Browse files

[ADT] Fix iplist_impl - use after move warnings (PR43943)

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
parent d5e6e0a5
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -198,10 +198,12 @@ public:
  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;
  }