forked from OSchip/llvm-project
Using an early return as it is more clear; NFC.
llvm-svn: 246444
This commit is contained in:
parent
f08bd00229
commit
a96b33b1b1
|
@ -21,35 +21,35 @@ void AssignOperatorSignatureCheck::registerMatchers(
|
|||
ast_matchers::MatchFinder *Finder) {
|
||||
// Only register the matchers for C++; the functionality currently does not
|
||||
// provide any benefit to other languages, despite being benign.
|
||||
if (getLangOpts().CPlusPlus) {
|
||||
const auto HasGoodReturnType = methodDecl(returns(lValueReferenceType(
|
||||
pointee(unless(isConstQualified()),
|
||||
hasDeclaration(equalsBoundNode("class"))))));
|
||||
if (!getLangOpts().CPlusPlus)
|
||||
return;
|
||||
|
||||
const auto IsSelf = qualType(anyOf(
|
||||
hasDeclaration(equalsBoundNode("class")),
|
||||
referenceType(pointee(hasDeclaration(equalsBoundNode("class"))))));
|
||||
const auto IsSelfAssign =
|
||||
methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
|
||||
hasName("operator="), ofClass(recordDecl().bind("class")),
|
||||
hasParameter(0, parmVarDecl(hasType(IsSelf))))
|
||||
.bind("method");
|
||||
const auto HasGoodReturnType = methodDecl(returns(lValueReferenceType(pointee(
|
||||
unless(isConstQualified()), hasDeclaration(equalsBoundNode("class"))))));
|
||||
|
||||
Finder->addMatcher(
|
||||
methodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"),
|
||||
this);
|
||||
const auto IsSelf = qualType(
|
||||
anyOf(hasDeclaration(equalsBoundNode("class")),
|
||||
referenceType(pointee(hasDeclaration(equalsBoundNode("class"))))));
|
||||
const auto IsSelfAssign =
|
||||
methodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
|
||||
hasName("operator="), ofClass(recordDecl().bind("class")),
|
||||
hasParameter(0, parmVarDecl(hasType(IsSelf))))
|
||||
.bind("method");
|
||||
|
||||
const auto BadSelf = referenceType(
|
||||
anyOf(lValueReferenceType(pointee(unless(isConstQualified()))),
|
||||
rValueReferenceType(pointee(isConstQualified()))));
|
||||
Finder->addMatcher(
|
||||
methodDecl(IsSelfAssign, unless(HasGoodReturnType)).bind("ReturnType"),
|
||||
this);
|
||||
|
||||
Finder->addMatcher(
|
||||
methodDecl(IsSelfAssign, hasParameter(0, parmVarDecl(hasType(BadSelf))))
|
||||
.bind("ArgumentType"),
|
||||
this);
|
||||
const auto BadSelf = referenceType(
|
||||
anyOf(lValueReferenceType(pointee(unless(isConstQualified()))),
|
||||
rValueReferenceType(pointee(isConstQualified()))));
|
||||
|
||||
Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"), this);
|
||||
}
|
||||
Finder->addMatcher(
|
||||
methodDecl(IsSelfAssign, hasParameter(0, parmVarDecl(hasType(BadSelf))))
|
||||
.bind("ArgumentType"),
|
||||
this);
|
||||
|
||||
Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"), this);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue