[llvm] 529e6f8 - [ADT] Fix iplist_impl - use after move warnings (PR43943)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 6 03:24:02 PST 2020
Author: Simon Pilgrim
Date: 2020-02-06T11:22:21Z
New Revision: 529e6f8791b624d94c10a04dc4e530e4a22ac520
URL: https://github.com/llvm/llvm-project/commit/529e6f8791b624d94c10a04dc4e530e4a22ac520
DIFF: https://github.com/llvm/llvm-project/commit/529e6f8791b624d94c10a04dc4e530e4a22ac520.diff
LOG: [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
Added:
Modified:
llvm/include/llvm/ADT/ilist.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/ilist.h b/llvm/include/llvm/ADT/ilist.h
index 06c7abff965f..cb7480b82114 100644
--- a/llvm/include/llvm/ADT/ilist.h
+++ b/llvm/include/llvm/ADT/ilist.h
@@ -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;
}
More information about the llvm-commits
mailing list