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

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 5 08:51:07 PST 2020


RKSimon created this revision.
RKSimon added reviewers: dexonsmith, rnk, MaskRay.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74062

Files:
  llvm/include/llvm/ADT/ilist.h


Index: llvm/include/llvm/ADT/ilist.h
===================================================================
--- llvm/include/llvm/ADT/ilist.h
+++ llvm/include/llvm/ADT/ilist.h
@@ -198,10 +198,12 @@
   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;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74062.242643.patch
Type: text/x-patch
Size: 828 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200205/29c27d34/attachment.bin>


More information about the llvm-commits mailing list