Commit Graph

4 Commits

Author SHA1 Message Date
Alexander Kornienko 106c8e0898 [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh
Summary: Make the script suitable for checking just messages. Move most of the tests to use it. Clean up the tests: shorten messages, insert line numbers, remove unnecessary RUN: lines, etc.

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

Differential Revision: http://reviews.llvm.org/D5989

llvm-svn: 220634
2014-10-26 02:58:07 +00:00
Benjamin Kramer da3658e2b7 Reapply r213647 with a fix.
ASTMatchers currently have problems mixing bound TypeLoc nodes with Decl/Stmt
nodes. That should be fixed soon but for this checker there we only need the
TypeLoc to generate a fixit so postpone the potentially heavyweight AST walking
until after we know that we're going to emit a warning.

This is covered by existing test cases.

Original message:
[clang-tidy] Add a check for RAII temporaries.

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.

llvm-svn: 213738
2014-07-23 11:49:46 +00:00
Richard Smith a714469d02 Revert r213647; the added test triggers an assertion.
llvm-svn: 213722
2014-07-23 04:13:00 +00:00
Benjamin Kramer 8ca8651171 [clang-tidy] Add a check for RAII temporaries.
Summary:
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.

Reviewers: alexfh, djasper

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4615

llvm-svn: 213647
2014-07-22 12:30:35 +00:00