================
@@ -208,6 +208,19 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder
*Finder) {
.bind("SizeCallExpr"),
this);
+ // Match non-member std::size(container) used in boolean context or compared
+ // with 0/1.
+ Finder->addMatcher(
+ callExpr(argumentCountIs(1),
+ callee(functionDecl(hasName("::std::size")).bind("SizeMethod")),
+ hasArgument(0, expr(anyOf(hasType(ValidContainer),
+ hasType(pointsTo(ValidContainer)),
+ hasType(references(ValidContainer))))
+ .bind("MemberCallObject")),
----------------
vbvictor wrote:
expr(anyOf(....)) can be refactored in separate matcher to avoid duplication
with previous , could be corrected later.
https://github.com/llvm/llvm-project/pull/201231
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits