Index: lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -992,9 +992,7 @@ ProgramPoint P = N->getLocation(); if (Optional BE = P.getAs()) { - if (BE->getSrc()->getLoopTarget() == FCS) - return true; - return false; + return BE->getSrc()->getLoopTarget() == FCS; } // Keep looking for a block edge. @@ -1038,11 +1036,8 @@ CountSelectorII = &C.getASTContext().Idents.get("count"); // If the method returns collection count, record the value. - if (S.isUnarySelector() && - (S.getIdentifierInfoForSlot(0) == CountSelectorII)) - return true; - - return false; + return S.isUnarySelector() && + (S.getIdentifierInfoForSlot(0) == CountSelectorII); } void ObjCLoopChecker::checkPostObjCMessage(const ObjCMethodCall &M, Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -1931,10 +1931,7 @@ // properties are held. However, if the user chooses to turn off some of these // checks, we ignore the issues and leave the call evaluation to a generic // handler. - if (!C.isDifferent()) - return false; - - return true; + return C.isDifferent(); } void CStringChecker::checkPreStmt(const DeclStmt *DS, CheckerContext &C) const { Index: lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp +++ lib/StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp @@ -127,9 +127,7 @@ return true; // - sizeof(src) - if (isSizeof(LenArg, SrcArg)) - return true; - return false; + return isSizeof(LenArg, SrcArg); } void WalkAST::VisitCallExpr(CallExpr *CE) { Index: lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp +++ lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp @@ -82,10 +82,7 @@ if (Left.isNegative()) return false; - if (Left % FlexSize == 0) - return true; - - return false; + return Left % FlexSize == 0; } void CastSizeChecker::checkPreStmt(const CastExpr *CE,CheckerContext &C) const { Index: lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp +++ lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp @@ -41,13 +41,12 @@ /// Checks for the init, dealloc, and any other functions that might be allowed /// to perform direct instance variable assignment based on their name. static bool DefaultMethodFilter(const ObjCMethodDecl *M) { - if (M->getMethodFamily() == OMF_init || M->getMethodFamily() == OMF_dealloc || - M->getMethodFamily() == OMF_copy || - M->getMethodFamily() == OMF_mutableCopy || - M->getSelector().getNameForSlot(0).find("init") != StringRef::npos || - M->getSelector().getNameForSlot(0).find("Init") != StringRef::npos) - return true; - return false; + return M->getMethodFamily() == OMF_init || + M->getMethodFamily() == OMF_dealloc || + M->getMethodFamily() == OMF_copy || + M->getMethodFamily() == OMF_mutableCopy || + M->getSelector().getNameForSlot(0).find("init") != StringRef::npos || + M->getSelector().getNameForSlot(0).find("Init") != StringRef::npos; } class DirectIvarAssignment : Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp +++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp @@ -417,10 +417,7 @@ if (checkSystemCall(CE, Name, C)) return true; - if (checkTaintedBufferSize(CE, FDecl, C)) - return true; - - return false; + return checkTaintedBufferSize(CE, FDecl, C); } SymbolRef GenericTaintChecker::getPointedToSymbol(CheckerContext &C, @@ -658,10 +655,8 @@ return false; // If either the format string content or the pointer itself are tainted, warn. - if (generateReportIfTainted(CE->getArg(ArgNum), - MsgUncontrolledFormatString, C)) - return true; - return false; + return generateReportIfTainted(CE->getArg(ArgNum), + MsgUncontrolledFormatString, C); } bool GenericTaintChecker::checkSystemCall(const CallExpr *CE, @@ -686,11 +681,7 @@ if (ArgNum == UINT_MAX || CE->getNumArgs() < (ArgNum + 1)) return false; - if (generateReportIfTainted(CE->getArg(ArgNum), - MsgSanitizeSystemArgs, C)) - return true; - - return false; + return generateReportIfTainted(CE->getArg(ArgNum), MsgSanitizeSystemArgs, C); } // TODO: Should this check be a part of the CString checker? @@ -728,11 +719,8 @@ ArgNum = 2; } - if (ArgNum != InvalidArgIndex && CE->getNumArgs() > ArgNum && - generateReportIfTainted(CE->getArg(ArgNum), MsgTaintedBufferSize, C)) - return true; - - return false; + return ArgNum != InvalidArgIndex && CE->getNumArgs() > ArgNum && + generateReportIfTainted(CE->getArg(ArgNum), MsgTaintedBufferSize, C); } void ento::registerGenericTaintChecker(CheckerManager &mgr) { Index: lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp +++ lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp @@ -287,9 +287,7 @@ const Stmt *Stmt2, bool IgnoreSideEffects) { if (!Stmt1 || !Stmt2) { - if (!Stmt1 && !Stmt2) - return true; - return false; + return !Stmt1 && !Stmt2; } // If Stmt1 & Stmt2 are of different class then they are not @@ -364,10 +362,8 @@ if (!isIdenticalStmt(Ctx, ForStmt1->getInc(), ForStmt2->getInc(), IgnoreSideEffects)) return false; - if (!isIdenticalStmt(Ctx, ForStmt1->getBody(), ForStmt2->getBody(), - IgnoreSideEffects)) - return false; - return true; + return isIdenticalStmt(Ctx, ForStmt1->getBody(), ForStmt2->getBody(), + IgnoreSideEffects); } case Stmt::DoStmtClass: { const DoStmt *DStmt1 = cast(Stmt1); @@ -376,10 +372,8 @@ if (!isIdenticalStmt(Ctx, DStmt1->getCond(), DStmt2->getCond(), IgnoreSideEffects)) return false; - if (!isIdenticalStmt(Ctx, DStmt1->getBody(), DStmt2->getBody(), - IgnoreSideEffects)) - return false; - return true; + return isIdenticalStmt(Ctx, DStmt1->getBody(), DStmt2->getBody(), + IgnoreSideEffects); } case Stmt::WhileStmtClass: { const WhileStmt *WStmt1 = cast(Stmt1); @@ -388,10 +382,8 @@ if (!isIdenticalStmt(Ctx, WStmt1->getCond(), WStmt2->getCond(), IgnoreSideEffects)) return false; - if (!isIdenticalStmt(Ctx, WStmt1->getBody(), WStmt2->getBody(), - IgnoreSideEffects)) - return false; - return true; + return isIdenticalStmt(Ctx, WStmt1->getBody(), WStmt2->getBody(), + IgnoreSideEffects); } case Stmt::IfStmtClass: { const IfStmt *IStmt1 = cast(Stmt1); @@ -403,10 +395,8 @@ if (!isIdenticalStmt(Ctx, IStmt1->getThen(), IStmt2->getThen(), IgnoreSideEffects)) return false; - if (!isIdenticalStmt(Ctx, IStmt1->getElse(), IStmt2->getElse(), - IgnoreSideEffects)) - return false; - return true; + return isIdenticalStmt(Ctx, IStmt1->getElse(), IStmt2->getElse(), + IgnoreSideEffects); } case Stmt::CompoundStmtClass: { const CompoundStmt *CompStmt1 = cast(Stmt1); Index: lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp +++ lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp @@ -203,12 +203,8 @@ static bool isBadDeallocationArgument(const MemRegion *Arg) { if (!Arg) return false; - if (isa(Arg) || - isa(Arg) || - isa(Arg)) { - return true; - } - return false; + return isa(Arg) || isa(Arg) || + isa(Arg); } /// Given the address expression, retrieve the value it's pointing to. Assume @@ -242,11 +238,7 @@ DefinedOrUnknownSVal NoErr = Builder.evalEQ(State, NoErrVal, nonloc::SymbolVal(RetSym)); ProgramStateRef ErrState = State->assume(NoErr, noError); - if (ErrState == State) { - return true; - } - - return false; + return ErrState == State; } // Report deallocator mismatch. Remove the region from tracking - reporting a Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -555,10 +555,7 @@ if (isCMemFunction(FD, C, AF_Alloca, MemoryOperationKind::MOK_Any)) return true; - if (isStandardNewDelete(FD, C)) - return true; - - return false; + return isStandardNewDelete(FD, C); } bool MallocChecker::isCMemFunction(const FunctionDecl *FD, @@ -996,12 +993,9 @@ // Ex: [NSData dataWithBytesNoCopy:bytes length:10]; // (...unless a 'freeWhenDone' parameter is false, but that's checked later.) StringRef FirstSlot = Call.getSelector().getNameForSlot(0); - if (FirstSlot == "dataWithBytesNoCopy" || - FirstSlot == "initWithBytesNoCopy" || - FirstSlot == "initWithCharactersNoCopy") - return true; - - return false; + return FirstSlot == "dataWithBytesNoCopy" || + FirstSlot == "initWithBytesNoCopy" || + FirstSlot == "initWithCharactersNoCopy"; } static Optional getFreeWhenDoneArg(const ObjCMethodCall &Call) { Index: lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp +++ lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp @@ -66,9 +66,7 @@ // The type must be an array/pointer type. // This could be a null constant, which is allowed. - if (E->isNullPointerConstant(ASTC, Expr::NPC_ValueDependentIsNull)) - return true; - return false; + return E->isNullPointerConstant(ASTC, Expr::NPC_ValueDependentIsNull); } public: Index: lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp +++ lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp @@ -405,10 +405,7 @@ if (II == NSObjectII) break; } - if (!ID) - return false; - - return true; + return ID; } /// \brief Returns true if the location is 'self'. Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -235,12 +235,9 @@ return false; // Run each of the checks on the conditions - if (containsMacro(cond) || containsEnum(cond) - || containsStaticLocal(cond) || containsBuiltinOffsetOf(cond) - || containsStmt(cond)) - return true; - - return false; + return containsMacro(cond) || containsEnum(cond) || + containsStaticLocal(cond) || containsBuiltinOffsetOf(cond) || + containsStmt(cond); } // Returns true if the given CFGBlock is empty