aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.

================
Comment at: clang-tidy/readability/ContainerSizeEmptyCheck.cpp:33
@@ +32,3 @@
+  const auto validContainer = namedDecl(
+      has(functionDecl(isPublic(), hasName("size"), returns(isInteger()))),
+      has(functionDecl(isPublic(), hasName("empty"), returns(booleanType()))));
----------------
While it's not entirely unreasonable, it makes me uneasy to assume that 
anything with a size() and empty() member function must be a container. Is 
there a way to silence false positives aside from disabling the check entirely?

Perhaps this should instead be a user-configurable list of containers that's 
prepopulated with STL container names?

Also note: `returns(isInteger())` seems a bit permissive. Consider:
```
bool size() const;

enum E { one };
enum E size() const;
```
These both will qualify for that matcher, but don't seem like particularly 
valid indications that the object is a container.


https://reviews.llvm.org/D24349



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to