From da3658e2b7f59c8a32f815f3309b61ef1a86c86b Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 23 Jul 2014 11:49:46 +0000 Subject: 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 --- clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp') diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp index 669ad081112..e3dbdc3bcbe 100644 --- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp @@ -14,6 +14,7 @@ #include "BoolPointerImplicitConversion.h" #include "RedundantSmartptrGet.h" #include "SwappedArgumentsCheck.h" +#include "UnusedRAII.h" #include "UseOverride.h" namespace clang { @@ -34,6 +35,9 @@ public: CheckFactories.addCheckFactory( "misc-swapped-arguments", new ClangTidyCheckFactory()); + CheckFactories.addCheckFactory( + "misc-unused-raii", + new ClangTidyCheckFactory()); CheckFactories.addCheckFactory( "misc-use-override", new ClangTidyCheckFactory()); -- cgit v1.2.3