Go to file
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
clang [PM] Track an LLVM API update which separates the TargetLibraryInfo 2015-01-15 10:42:26 +00:00
clang-tools-extra clang-tidy: 'size' call that could be replaced with 'empty' on STL containers 2015-01-15 15:46:58 +00:00
compiler-rt [sanitizer] Flag parser rewrite. 2015-01-15 15:13:43 +00:00
debuginfo-tests New round of fixes for "Always compile debuginfo-tests for the host triple" 2014-10-18 23:47:59 +00:00
libclc Use amdgcn triple for SI+ GPUs 2015-01-06 20:42:12 +00:00
libcxx Rename src_root -> libcxx_src_root. NFC 2015-01-15 00:03:14 +00:00
libcxxabi Update PACKAGE_VERSION to 3.7.0svn 2015-01-14 18:30:55 +00:00
lld Rename InputGraph.h -> Node.h. 2015-01-15 08:58:38 +00:00
lldb In commit clang r226096, DefinitionRequired has been removed. Do the same in lldb implementation 2015-01-15 11:50:50 +00:00
llgo Introduce llgoi, a REPL for Go 2015-01-15 04:13:29 +00:00
llvm [mips] Fix a typo in the compare patterns for MIPS32r6/MIPS64r6. 2015-01-15 15:41:03 +00:00
openmp fixed the missed bracket introduced by checkin rev 225792 2015-01-13 15:16:49 +00:00
polly [PM] Track an LLVM API change by switching this code to directly create 2015-01-15 10:43:18 +00:00