forked from OSchip/llvm-project
[clang-tidy] Ignore `size() == 0` in the container implementation.
llvm-svn: 290289
This commit is contained in:
parent
ec9ebba778
commit
b5ca17f817
|
@ -58,7 +58,9 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
|
|||
hasType(pointsTo(ValidContainer)),
|
||||
hasType(references(ValidContainer))))
|
||||
.bind("STLObject")),
|
||||
callee(cxxMethodDecl(hasName("size"))), WrongUse)
|
||||
callee(cxxMethodDecl(hasName("size"))), WrongUse,
|
||||
unless(hasAncestor(cxxMethodDecl(
|
||||
ofClass(equalsBoundNode("container"))))))
|
||||
.bind("SizeCallExpr"),
|
||||
this);
|
||||
}
|
||||
|
|
|
@ -61,6 +61,20 @@ public:
|
|||
class Derived : public Container {
|
||||
};
|
||||
|
||||
class Container2 {
|
||||
public:
|
||||
int size() const;
|
||||
bool empty() const { return size() == 0; }
|
||||
};
|
||||
|
||||
class Container3 {
|
||||
public:
|
||||
int size() const;
|
||||
bool empty() const;
|
||||
};
|
||||
|
||||
bool Container3::empty() const { return this->size() == 0; }
|
||||
|
||||
int main() {
|
||||
std::set<int> intSet;
|
||||
std::string str;
|
||||
|
|
Loading…
Reference in New Issue