[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 07:23:21 PDT 2015


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);
 }
 
 




More information about the cfe-commits mailing list