[clang-tools-extra] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 1 13:22:38 PDT 2024
================
@@ -0,0 +1,125 @@
+// RUN: %check_clang_tidy %s bugprone-move-shared-pointer-contents %t -- -config="{CheckOptions: {bugprone-move-shared-pointer-contents.SharedPointerClasses: '::std::shared_ptr;my::OtherSharedPtr;'}}"
+
+// Some dummy definitions we'll need.
+
+namespace std {
+
+using size_t = int;
+
+template <typename> struct remove_reference;
+template <typename _Tp> struct remove_reference { typedef _Tp type; };
+template <typename _Tp> struct remove_reference<_Tp &> { typedef _Tp type; };
+template <typename _Tp> struct remove_reference<_Tp &&> { typedef _Tp type; };
+
+template <typename _Tp>
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
+ return static_cast<typename std::remove_reference<_Tp>::type &&>(__t);
+}
+
+template <typename T>
+struct shared_ptr {
----------------
pizzud wrote:
Oooh thanks! This also exposed a tricky issue where types inheriting from a shared pointer class aren't caught if get() is defined in the parent. Thankfully it only affected the direct call path, not the unresolved path, since there we can easily convert to CXXRecordDecl and look at bases.
https://github.com/llvm/llvm-project/pull/67467
More information about the cfe-commits
mailing list