hanchenye-llvm-project/clang-tools-extra/test/clang-tidy
Alexander Kornienko 4babd689f9 clang-tidy: 'size' call that could be replaced with 'empty' on STL containers
We are porting some of the checkers at a company we developed to the Clang Tidy
infrastructure. We would like to open source the checkers that may be useful
for the community as well. This patch is the first checker that is being ported
to Clang Tidy. We also added fix-it hints, and applied them to LLVM:
http://reviews.llvm.org/D6924

The code compiled and the unit tests are passed after the fixits was applied.

The documentation of the checker:

/// The emptiness of a container should be checked using the empty method
/// instead of the size method. It is not guaranteed that size is a
/// constant-time function, and it is generally more efficient and also shows
/// clearer intent to use empty. Furthermore some containers may implement the
/// empty method but not implement the size method. Using empty whenever
/// possible makes it easier to switch to another container in the future.

It also uses some custom ASTMatchers. In case you find them useful I can submit
them as separate patches to clang. I will apply your suggestions to this patch.

http://reviews.llvm.org/D6925

Patch by Gábor Horváth!

llvm-svn: 226172
2015-01-15 15:46:58 +00:00
..
Inputs [clang-tidy] Added -system-headers option. 2014-10-28 22:16:13 +00:00
arg-comments.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
basic.cpp [clang-tidy] Move the missing namespace comment warnings to the closing brace 2014-11-17 17:32:32 +00:00
check_clang_tidy.sh [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
clang-tidy-diff.cpp [clang-tidy] Count errors in ClangTidyDiagnosticConsumer 2014-11-20 12:05:51 +00:00
config-files.cpp Implemented clang-tidy configurability via .clang-tidy files. 2014-09-04 14:23:36 +00:00
deduplication.cpp [clang-tidy] Support initializer_list in google-explicit-constructor check 2014-11-27 11:11:47 +00:00
diagnostic.cpp [clang-tidy] Support initializer_list in google-explicit-constructor check 2014-11-27 11:11:47 +00:00
file-filter.cpp [clang-tidy] Support initializer_list in google-explicit-constructor check 2014-11-27 11:11:47 +00:00
fix-errors.cpp [clang-tidy] Added -fix-errors option 2014-11-03 14:06:31 +00:00
fix.cpp [clang-tidy] Add an option to export suggested fixes into a file. 2014-09-04 10:31:23 +00:00
google-explicit-constructor.cpp [clang-tidy] google-explicit-constructor: don't match in template instantiations 2014-11-30 19:41:41 +00:00
google-explicit-make-pair.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
google-member-string-references.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
google-memset-zero-length.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
google-module.cpp [clang-tidy] Set google-readability-namespace-comments.ShortNamespaceLines to 10 2014-11-20 15:05:32 +00:00
google-namespaces.cpp [clang-tidy] Add namespaces checkers. 2014-07-16 14:16:56 +00:00
google-overloaded-unary-and.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
google-readability-casting.c [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
google-readability-casting.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
google-readability-function.cpp [clang-tidy] google-readability-function: skip std::nullptr_t 2014-11-05 11:08:39 +00:00
google-readability-namespace-comments.cpp [clang-tidy] Set google-readability-namespace-comments.ShortNamespaceLines to 10 2014-11-20 15:05:32 +00:00
google-readability-todo.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
google-runtime-int.c [clang-tidy] google-runtime-int: Don't check C code. 2014-12-08 11:17:25 +00:00
google-runtime-int.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
line-filter.cpp [clang-tidy] Support initializer_list in google-explicit-constructor check 2014-11-27 11:11:47 +00:00
llvm-include-order.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
llvm-twine-local.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
macros.cpp [clang-tidy] Support initializer_list in google-explicit-constructor check 2014-11-27 11:11:47 +00:00
misc-bool-pointer-implicit-conversion.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
misc-swapped-arguments.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
misc-undelegated-constructor.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
misc-uniqueptr-reset-release.cpp [clang-tidy] Add clang-tidy check for unique_ptr's reset+release -> move 2014-12-05 11:59:05 +00:00
misc-unused-raii.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
misc-use-override.cpp clang-tidy: [misc-use-override] Simplify regular expressions in test. 2015-01-09 14:10:15 +00:00
nolint.cpp [clang-tidy] Support initializer_list in google-explicit-constructor check 2014-11-27 11:11:47 +00:00
readability-braces-around-statements-few-lines.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
readability-braces-around-statements-same-line.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
readability-braces-around-statements-single-line.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
readability-braces-around-statements.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
readability-else-after-return.cpp clang-tidy: Add initial check for "Don't use else after return". 2015-01-14 19:37:54 +00:00
readability-function-size.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
readability-redundant-smartptr-get.cpp [clang-tidy] check_clang_tidy_fix.sh -> check_clang_tidy.sh 2014-10-26 02:58:07 +00:00
readibility-container-size-empty.cpp clang-tidy: 'size' call that could be replaced with 'empty' on STL containers 2015-01-15 15:46:58 +00:00
select-checks.cpp [clang-tidy] Move the missing namespace comment warnings to the closing brace 2014-11-17 17:32:32 +00:00
serialize-diagnostics.cpp [clang-tidy] Make a test independent of the default check set. 2014-12-03 13:48:46 +00:00
static-analyzer.cpp Change the behavior of clang-tidy -checks=, remove -disable-checks. 2014-05-15 14:27:36 +00:00
temporaries.cpp Change the behavior of clang-tidy -checks=, remove -disable-checks. 2014-05-15 14:27:36 +00:00
validate-check-names.cpp Implemented clang-tidy configurability via .clang-tidy files. 2014-09-04 14:23:36 +00:00