From 529e6f8791b624d94c10a04dc4e530e4a22ac520 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 6 Feb 2020 11:22:06 +0000 Subject: [PATCH] [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 --- llvm/include/llvm/ADT/ilist.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/ADT/ilist.h b/llvm/include/llvm/ADT/ilist.h index 06c7abf..cb7480b 100644 --- a/llvm/include/llvm/ADT/ilist.h +++ b/llvm/include/llvm/ADT/ilist.h @@ -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(X))), + IntrusiveListT(std::move(static_cast(X))) {} iplist_impl &operator=(iplist_impl &&X) { - *static_cast(this) = std::move(X); - *static_cast(this) = std::move(X); + *static_cast(this) = std::move(static_cast(X)); + *static_cast(this) = + std::move(static_cast); return *this; } -- 2.7.4