blob: f1987c5319daea779cf1b559e97c0a2669863a15 [file] [log] [blame]
.. title:: clang-tidy - bugprone-unused-raii
Finds temporaries that look like RAII objects.
The canonical example for this is a scoped lock.
.. code-block:: c++
The destructor of the scoped_lock is called before the ``critical_section`` is
entered, leaving it unprotected.
We apply a number of heuristics to reduce the false positive count of this
- Ignore code expanded from macros. Testing frameworks make heavy use of this.
- Ignore types with trivial destructors. They are very unlikely to be RAII
objects and there's no difference when they are deleted.
- Ignore objects at the end of a compound statement (doesn't change behavior).
- Ignore objects returned from a call.