aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp')
-rw-r--r--contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp28
1 files changed, 9 insertions, 19 deletions
diff --git a/contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp b/contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
index 7db1a1c378cc..f81133f3aad3 100644
--- a/contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
+++ b/contrib/llvm/tools/clang/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
@@ -150,11 +150,8 @@ public:
return true;
}
- if (!hasSideEffects(rec, Pass.Ctx)) {
- if (tryRemoving(RecContainer))
- return true;
- }
- Pass.TA.replace(RecContainer->getSourceRange(), RecRange);
+ if (hasSideEffects(rec, Pass.Ctx) || !tryRemoving(RecContainer))
+ Pass.TA.replace(RecContainer->getSourceRange(), RecRange);
return true;
}
@@ -174,11 +171,8 @@ private:
/// return var;
///
bool isCommonUnusedAutorelease(ObjCMessageExpr *E) {
- if (isPlusOneAssignBeforeOrAfterAutorelease(E))
- return true;
- if (isReturnedAfterAutorelease(E))
- return true;
- return false;
+ return isPlusOneAssignBeforeOrAfterAutorelease(E) ||
+ isReturnedAfterAutorelease(E);
}
bool isReturnedAfterAutorelease(ObjCMessageExpr *E) {
@@ -225,11 +219,7 @@ private:
// Check for "RefD = [+1 retained object];".
if (BinaryOperator *Bop = dyn_cast<BinaryOperator>(S)) {
- if (RefD != getReferencedDecl(Bop->getLHS()))
- return false;
- if (isPlusOneAssign(Bop))
- return true;
- return false;
+ return (RefD == getReferencedDecl(Bop->getLHS())) && isPlusOneAssign(Bop);
}
if (DeclStmt *DS = dyn_cast<DeclStmt>(S)) {
@@ -359,16 +349,16 @@ private:
return;
Stmt::child_range StmtExprChild = StmtE->children();
- if (!StmtExprChild)
+ if (StmtExprChild.begin() == StmtExprChild.end())
return;
- CompoundStmt *CompS = dyn_cast_or_null<CompoundStmt>(*StmtExprChild);
+ auto *CompS = dyn_cast_or_null<CompoundStmt>(*StmtExprChild.begin());
if (!CompS)
return;
Stmt::child_range CompStmtChild = CompS->children();
- if (!CompStmtChild)
+ if (CompStmtChild.begin() == CompStmtChild.end())
return;
- DeclStmt *DeclS = dyn_cast_or_null<DeclStmt>(*CompStmtChild);
+ auto *DeclS = dyn_cast_or_null<DeclStmt>(*CompStmtChild.begin());
if (!DeclS)
return;
if (!DeclS->isSingleDecl())