[clang-tools-extra] [clang-tidy] Fix smart pointers handling in bugprone-use-after-move (PR #94869)

via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 12 07:13:55 PDT 2024


================
@@ -250,3 +251,14 @@ For example, if an additional member variable is added to ``S``, it is easy to
 forget to add the reinitialization for this additional member. Instead, it is
 safer to assign to the entire struct in one go, and this will also avoid the
 use-after-move warning.
+
+Options
+-------
+
+.. option:: AllowMovedSmartPtrUse
+
+   If this option is set to `true`, the check will not warn about uses of
+   ``std::unique_ptr``, ``std::shared_ptr`` that are not dereferences. This
+   can be useful if you are using these smart pointers in a way that is not
+   idiomatic, but that you know is safe. Default is `false`.
----------------
martinboehme wrote:

"This can be useful if you are using these smart pointers in a way that is not idiomatic, but that you know is safe."

I think "not idiomatic" is too strong -- I would say this is a question of style. Maybe just leave out this entire sentence (i.e. describe only the behavior)?

https://github.com/llvm/llvm-project/pull/94869


More information about the cfe-commits mailing list