[clang-tools-extra] r246444 - Using an early return as it is more clear; NFC.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 31 08:19:48 PDT 2015


On Mon, Aug 31, 2015 at 11:18 AM, Alexander Kornienko <alexfh at google.com> wrote:
> Thanks! Could you do the same for the other files changed in that revision?

Can do.

~Aaron

>
>
> On Mon, Aug 31, 2015 at 4:23 PM, Aaron Ballman via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
>>
>> Author: aaronballman
>> Date: Mon Aug 31 09:23:21 2015
>> New Revision: 246444
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=246444&view=rev
>> Log:
>> Using an early return as it is more clear; NFC.
>>
>> Modified:
>>
>> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
>>
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp?rev=246444&r1=246443&r2=246444&view=diff
>>
>> ==============================================================================
>> ---
>> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/clang-tidy/misc/AssignOperatorSignatureCheck.cpp Mon
>> Aug 31 09:23:21 2015
>> @@ -21,35 +21,35 @@ void AssignOperatorSignatureCheck::regis
>>      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"))))));
>> -
>> -    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");
>> -
>> -    Finder->addMatcher(
>> -        methodDecl(IsSelfAssign,
>> unless(HasGoodReturnType)).bind("ReturnType"),
>> -        this);
>> -
>> -    const auto BadSelf = referenceType(
>> -        anyOf(lValueReferenceType(pointee(unless(isConstQualified()))),
>> -              rValueReferenceType(pointee(isConstQualified()))));
>> -
>> -    Finder->addMatcher(
>> -        methodDecl(IsSelfAssign, hasParameter(0,
>> parmVarDecl(hasType(BadSelf))))
>> -            .bind("ArgumentType"),
>> -        this);
>> +  if (!getLangOpts().CPlusPlus)
>> +    return;
>>
>> -    Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"),
>> this);
>> -  }
>> +  const auto HasGoodReturnType =
>> methodDecl(returns(lValueReferenceType(pointee(
>> +      unless(isConstQualified()),
>> hasDeclaration(equalsBoundNode("class"))))));
>> +
>> +  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");
>> +
>> +  Finder->addMatcher(
>> +      methodDecl(IsSelfAssign,
>> unless(HasGoodReturnType)).bind("ReturnType"),
>> +      this);
>> +
>> +  const auto BadSelf = referenceType(
>> +      anyOf(lValueReferenceType(pointee(unless(isConstQualified()))),
>> +            rValueReferenceType(pointee(isConstQualified()))));
>> +
>> +  Finder->addMatcher(
>> +      methodDecl(IsSelfAssign, hasParameter(0,
>> parmVarDecl(hasType(BadSelf))))
>> +          .bind("ArgumentType"),
>> +      this);
>> +
>> +  Finder->addMatcher(methodDecl(IsSelfAssign, isConst()).bind("Const"),
>> this);
>>  }
>>
>>
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>


More information about the cfe-commits mailing list