Hi akyrtzi, rafael, dblaikie, bkramer, chandlerc, aaron.ballman, doug.gregor,
Use clang-tidy to simplify boolean conditional return statements
http://reviews.llvm.org/D10009
Files:
lib/ARCMigrate/ObjCMT.cpp
lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
lib/ARCMigrate/TransGCAttrs.cpp
lib/ARCMigrate/TransRetainReleaseDealloc.cpp
lib/ARCMigrate/Transforms.cpp
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
Index: lib/ARCMigrate/ObjCMT.cpp
===================================================================
--- lib/ARCMigrate/ObjCMT.cpp
+++ lib/ARCMigrate/ObjCMT.cpp
@@ -214,25 +214,15 @@
// FIXME. This duplicates one in RewriteObjCFoundationAPI.cpp
bool subscriptOperatorNeedsParens(const Expr *FullExpr) {
const Expr* Expr = FullExpr->IgnoreImpCasts();
- if (isa<ArraySubscriptExpr>(Expr) ||
- isa<CallExpr>(Expr) ||
- isa<DeclRefExpr>(Expr) ||
- isa<CXXNamedCastExpr>(Expr) ||
- isa<CXXConstructExpr>(Expr) ||
- isa<CXXThisExpr>(Expr) ||
- isa<CXXTypeidExpr>(Expr) ||
- isa<CXXUnresolvedConstructExpr>(Expr) ||
- isa<ObjCMessageExpr>(Expr) ||
- isa<ObjCPropertyRefExpr>(Expr) ||
- isa<ObjCProtocolExpr>(Expr) ||
- isa<MemberExpr>(Expr) ||
- isa<ObjCIvarRefExpr>(Expr) ||
- isa<ParenExpr>(FullExpr) ||
- isa<ParenListExpr>(Expr) ||
- isa<SizeOfPackExpr>(Expr))
- return false;
-
- return true;
+ return !(isa<ArraySubscriptExpr>(Expr) || isa<CallExpr>(Expr) ||
+ isa<DeclRefExpr>(Expr) || isa<CXXNamedCastExpr>(Expr) ||
+ isa<CXXConstructExpr>(Expr) || isa<CXXThisExpr>(Expr) ||
+ isa<CXXTypeidExpr>(Expr) ||
+ isa<CXXUnresolvedConstructExpr>(Expr) ||
+ isa<ObjCMessageExpr>(Expr) || isa<ObjCPropertyRefExpr>(Expr) ||
+ isa<ObjCProtocolExpr>(Expr) || isa<MemberExpr>(Expr) ||
+ isa<ObjCIvarRefExpr>(Expr) || isa<ParenExpr>(FullExpr) ||
+ isa<ParenListExpr>(Expr) || isa<SizeOfPackExpr>(Expr));
}
/// \brief - Rewrite message expression for Objective-C setter and getters into
@@ -665,9 +655,7 @@
return false;
}
}
- if (HasAtleastOneRequiredProperty || HasAtleastOneRequiredMethod)
- return true;
- return false;
+ return HasAtleastOneRequiredProperty || HasAtleastOneRequiredMethod;
}
static bool rewriteToObjCInterfaceDecl(const ObjCInterfaceDecl *IDecl,
Index: lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
===================================================================
--- lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
+++ lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
@@ -104,9 +104,7 @@
return false;
if (!S->getThen() || !Visit(S->getThen()))
return false;
- if (S->getElse() && !Visit(S->getElse()))
- return false;
- return true;
+ return !S->getElse() || Visit(S->getElse());
}
bool VisitWhileStmt(WhileStmt *S) {
if (S->getConditionVariable())
Index: lib/ARCMigrate/TransGCAttrs.cpp
===================================================================
--- lib/ARCMigrate/TransGCAttrs.cpp
+++ lib/ARCMigrate/TransGCAttrs.cpp
@@ -152,9 +152,7 @@
return ID->getImplementation() != nullptr;
if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContD))
return CD->getImplementation() != nullptr;
- if (isa<ObjCImplDecl>(ContD))
- return true;
- return false;
+ return isa<ObjCImplDecl>(ContD);
}
return false;
}
Index: lib/ARCMigrate/TransRetainReleaseDealloc.cpp
===================================================================
--- lib/ARCMigrate/TransRetainReleaseDealloc.cpp
+++ lib/ARCMigrate/TransRetainReleaseDealloc.cpp
@@ -176,9 +176,7 @@
bool isCommonUnusedAutorelease(ObjCMessageExpr *E) {
if (isPlusOneAssignBeforeOrAfterAutorelease(E))
return true;
- if (isReturnedAfterAutorelease(E))
- return true;
- return false;
+ return isReturnedAfterAutorelease(E);
}
bool isReturnedAfterAutorelease(ObjCMessageExpr *E) {
@@ -227,9 +225,7 @@
if (BinaryOperator *Bop = dyn_cast<BinaryOperator>(S)) {
if (RefD != getReferencedDecl(Bop->getLHS()))
return false;
- if (isPlusOneAssign(Bop))
- return true;
- return false;
+ return isPlusOneAssign(Bop);
}
if (DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
Index: lib/ARCMigrate/Transforms.cpp
===================================================================
--- lib/ARCMigrate/Transforms.cpp
+++ lib/ARCMigrate/Transforms.cpp
@@ -112,10 +112,7 @@
while (implCE && implCE->getCastKind() == CK_BitCast)
implCE = dyn_cast<ImplicitCastExpr>(implCE->getSubExpr());
- if (implCE && implCE->getCastKind() == CK_ARCConsumeObject)
- return true;
-
- return false;
+ return implCE && implCE->getCastKind() == CK_ARCConsumeObject;
}
/// \brief 'Loc' is the end of a statement range. This returns the location
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits