diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-07-11 08:08:47 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-07-11 08:08:47 +0000 |
commit | 1c8b31753b0699960d314a67dba2c71ba832e6ae (patch) | |
tree | baa10f2e41cb0f56787cb9fe1776011537c8211b /clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp | |
parent | 780ce0f8e3505e7a3df0ee5f5d421d8e0e253079 (diff) | |
download | bcm5719-llvm-1c8b31753b0699960d314a67dba2c71ba832e6ae.tar.gz bcm5719-llvm-1c8b31753b0699960d314a67dba2c71ba832e6ae.zip |
[clang-tidy] Add a checker for implicit bool conversion of a bool*.
The goal is to find code like the example below, which is likely a typo
where someone meant to write "if (*b)".
bool *b = SomeFunction();
if (b) {
// b never dereferenced
}
This checker naturally has a relatively high false positive rate so it
applies some heuristics to avoid cases where the pointer is checked for
nullptr before being written.
Differential Revision: http://reviews.llvm.org/D4458
llvm-svn: 212797
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 28a2f0be788..ee992928057 100644 --- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp @@ -11,6 +11,7 @@ #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" #include "ArgumentCommentCheck.h" +#include "BoolPointerImplicitConversion.h" #include "RedundantSmartptrGet.h" #include "UseOverride.h" @@ -24,6 +25,9 @@ public: "misc-argument-comment", new ClangTidyCheckFactory<ArgumentCommentCheck>()); CheckFactories.addCheckFactory( + "misc-bool-pointer-implicit-conversion", + new ClangTidyCheckFactory<BoolPointerImplicitConversion>()); + CheckFactories.addCheckFactory( "misc-redundant-smartptr-get", new ClangTidyCheckFactory<RedundantSmartptrGet>()); CheckFactories.addCheckFactory( |