brintos

brintos / llvm-project-archived public Read only

0
0
Text · 803 B · f1987c5 Raw
31 lines · plain
1.. title:: clang-tidy - bugprone-unused-raii2 3bugprone-unused-raii4====================5 6Finds temporaries that look like RAII objects.7 8The canonical example for this is a scoped lock.9 10.. code-block:: c++11 12  {13    scoped_lock(&global_mutex);14    critical_section();15  }16 17The destructor of the scoped_lock is called before the ``critical_section`` is18entered, leaving it unprotected.19 20We apply a number of heuristics to reduce the false positive count of this21check:22 23- Ignore code expanded from macros. Testing frameworks make heavy use of this.24 25- Ignore types with trivial destructors. They are very unlikely to be RAII26  objects and there's no difference when they are deleted.27 28- Ignore objects at the end of a compound statement (doesn't change behavior).29 30- Ignore objects returned from a call.31