[PATCH] D56644: [clang-tidy] readability-container-size-empty handle std::string length()

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 13 03:06:47 PST 2019


lebedev.ri added a comment.

Seems to look good.



================
Comment at: clang-tidy/readability/ContainerSizeEmptyCheck.cpp:65
                                       hasType(references(ValidContainer))))),
-                        callee(cxxMethodDecl(hasName("size"))), WrongUse,
+                        callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))), WrongUse,
                         unless(hasAncestor(cxxMethodDecl(
----------------
This line looks too long, clang-format might be too intrusive, so at least
```
                        callee(cxxMethodDecl(anyOf(hasName("size"), 
                                                   hasName("length")))),
                        WrongUse,

```


================
Comment at: test/clang-tidy/readability-container-size-empty.cpp:19-20
   basic_string<T> operator+(const basic_string<T>& other) const;
   unsigned long size() const;
+  unsigned long length() const;
   bool empty() const;
----------------
Does it still work if only one of these exists?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56644/new/

https://reviews.llvm.org/D56644





More information about the cfe-commits mailing list