diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-07-22 12:30:35 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-07-22 12:30:35 +0000 |
commit | 8ca8651171ae2caeb93c15a9ec6189cff8d2444a (patch) | |
tree | 27527e7a36aba0a245f2c401f32da6dcdcfc7b27 /clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp | |
parent | 8f41c3eb74619a82b1c41bba3e09467d0a65db0c (diff) | |
download | bcm5719-llvm-8ca8651171ae2caeb93c15a9ec6189cff8d2444a.tar.gz bcm5719-llvm-8ca8651171ae2caeb93c15a9ec6189cff8d2444a.zip |
[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
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
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 { @@ -35,6 +36,9 @@ public: "misc-swapped-arguments", new ClangTidyCheckFactory<SwappedArgumentsCheck>()); CheckFactories.addCheckFactory( + "misc-unused-raii", + new ClangTidyCheckFactory<UnusedRAIICheck>()); + CheckFactories.addCheckFactory( "misc-use-override", new ClangTidyCheckFactory<UseOverride>()); } |