@@ -196,11 +196,13 @@ Any occurrence of the moved variable that is not a reinitialization (see below)
196196is considered to be a use.
197197
198198An exception to this are objects of type ``std::unique_ptr ``,
199- ``std::shared_ptr `` and ``std::weak_ptr ``, which have defined move behavior
200- (objects of these classes are guaranteed to be empty after they have been moved
201- from). Therefore, an object of these classes will only be considered to be used
202- if it is dereferenced, i.e. if ``operator* ``, ``operator-> `` or ``operator[] ``
203- (in the case of ``std::unique_ptr<T []> ``) is called on it.
199+ ``std::shared_ptr ``, ``std::weak_ptr ``, ``std::optional ``, and ``std::any ``.
200+ An exception to this are objects of type ``std::unique_ptr ``,
201+ ``std::shared_ptr ``, ``std::weak_ptr ``, ``std::optional ``, and ``std::any ``, which
202+ can be reinitialized via ``reset ``. For smart pointers specifically, the
203+ moved-from objects have a well-defined state of being ``nullptr``s, and only
204+ ``operator* ``, ``operator-> `` and ``operator[] `` are considered bad accesses as
205+ they would be dereferencing a ``nullptr ``.
204206
205207If multiple uses occur after a move, only the first of these is flagged.
206208
@@ -222,7 +224,8 @@ The check considers a variable to be reinitialized in the following cases:
222224 ``unordered_multimap ``.
223225
224226 - ``reset() `` is called on the variable and the variable is of type
225- ``std::unique_ptr ``, ``std::shared_ptr `` or ``std::weak_ptr ``.
227+ ``std::unique_ptr ``, ``std::shared_ptr ``, ``std::weak_ptr ``,
228+ ``std::optional ``, or ``std::any ``.
226229
227230 - A member function marked with the ``[[clang::reinitializes]] `` attribute is
228231 called on the variable.
0 commit comments