[clang] [clang-tools-extra] [clang-tidy] Add [[clang::usable_on_move]] to inform bugprone-use-aft… (PR #216121)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 13 12:50:43 PDT 2026
================
@@ -7515,6 +7472,34 @@ a container class:
}];
}
+def UsableOnMovedDocs : Documentation {
+ let Category = DocCatFunction;
+ let Content = [{
+The ``usable_on_moved`` attribute can be applied to a non-static, C++
+member function to indicate that this member function can be invoked on a
+moved-from object.
+
+This attribute can be interpreted by static analyzers that warn about uses of an
+object that has been left in an indeterminate state by a move operation. If a
+member function marked with the ``usable_on_moved`` attribute is called on a
+moved-from object, the analyzer should not warn about usage in an indeterminate
----------------
Endilll wrote:
Is "indeterminate state" the way moved-from state described in the emitted diagnostic?
I find it unfortunate that it's so close to C++ standard's "indeterminate state" used for uninitialized locals while also not being correct, as there is nothing inherently non-deterministic about move constructors and move assignment operators.
https://github.com/llvm/llvm-project/pull/216121
More information about the cfe-commits
mailing list