[PATCH] [clang-tidy] Add a check for RAII temporaries.

Benjamin Kramer benny.kra at gmail.com
Tue Jul 22 02:24:51 PDT 2014


Hi alexfh, djasper,

This tries to find code similar that immediately destroys
an object that looks like it's trying to follow RAII.
  {
    scoped_lock(&global_mutex);
    critical_section();
  }

This checker will have false positives if someone uses this pattern
to legitimately invoke a destructor immediately (or the statement is
at the end of a scope anyway). To reduce the number we ignore this
pattern in macros (this is heavily used by gtest) and ignore objects
with no user-defined destructor.

http://reviews.llvm.org/D4615

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/UnusedRAII.cpp
  clang-tidy/misc/UnusedRAII.h
  test/clang-tidy/misc-unused-raii.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4615.11741.patch
Type: text/x-patch
Size: 5700 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140722/bad494d4/attachment.bin>


More information about the cfe-commits mailing list