[clang-tools-extra] [clang-tidy] Fix FP in readability-container-size-empty with compairing to unrelated type (PR #190535)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 6 02:34:24 PDT 2026
================
@@ -209,7 +209,7 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
const auto WrongComparend =
anyOf(stringLiteral(hasSize(0)),
userDefinedLiteral(hasLiteral(stringLiteral(hasSize(0)))),
- cxxConstructExpr(argumentCountIs(0)),
+ cxxConstructExpr(argumentCountIs(0), hasType(ValidContainer)),
----------------
5chmidti wrote:
This still allows comparing two different valid containers though.
```c++
std::string a{"abc"};
a == std::vector<char>{};
```
I think we should use `equalsBoundNode`
https://github.com/llvm/llvm-project/pull/190535
More information about the cfe-commits
mailing list