llvm-project/clang-tools-extra/test
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
..
Unit Also run extra tools unit tests in shared library builds. 2014-08-13 12:54:50 +00:00
clang-apply-replacements Handle newlines on Windows correctly. 2014-12-09 02:57:56 +00:00
clang-modernize Make LoopConvert work with containers that are used like arrays. 2015-01-12 13:17:56 +00:00
clang-query Add a makefile for clang-query. Patch by Alex Horn! 2014-02-18 19:46:01 +00:00
clang-rename Revert rL215947: "[clang-rename] revert r215839" 2014-08-20 01:39:05 +00:00
clang-tidy clang-tidy: 'size' call that could be replaced with 'empty' on STL containers 2015-01-15 15:46:58 +00:00
modularize Added module map generation option. 2013-10-15 13:52:33 +00:00
module-map-checker Initial checkin of new module-map-checker tool. 2014-01-07 15:22:08 +00:00
pp-trace Prune CRLF. 2014-10-27 12:37:26 +00:00
remove-cstr-calls Fix a remove-cstr-calls test that fails checking of the produced code. 2013-06-19 15:43:40 +00:00
.clang-format Add a .clang-format to avoid reflow of test RUN lines 2013-12-01 05:08:00 +00:00
CMakeLists.txt Revert rL215947: "[clang-rename] revert r215839" 2014-08-20 01:39:05 +00:00
Makefile Try to unbreak the Makefile build. 2014-08-13 13:20:04 +00:00
lit.cfg Make the clang-tidy-diff.py test conditional on the presence of Python 2.7. Use the python binary from the configuration. 2014-06-26 16:32:26 +00:00
lit.site.cfg.in Make the clang-tidy-diff.py test conditional on the presence of Python 2.7. Use the python binary from the configuration. 2014-06-26 16:32:26 +00:00