From 5ff6747e04021d52f4ed654fe82007be14b8267b Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 11 Apr 2016 08:26:13 +0000 Subject: [PATCH] Remove redundant conditions of the form (A || (!A && B)) -> (A || B) Found by cppcheck! PR27286 PR27287 PR27288 PR27289 llvm-svn: 265918 --- clang/lib/CodeGen/CGExpr.cpp | 2 +- clang/lib/Parse/ParseOpenMP.cpp | 3 +-- clang/lib/Sema/SemaOverload.cpp | 3 +-- .../StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp | 3 +-- clang/lib/StaticAnalyzer/Core/RegionStore.cpp | 9 ++++----- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 1b99f100de15..8329e52bde30 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -2994,7 +2994,7 @@ LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E, else ResultExprTy = BaseTy->getPointeeType(); llvm::Value *Idx = nullptr; - if (IsLowerBound || (!IsLowerBound && E->getColonLoc().isInvalid())) { + if (IsLowerBound || E->getColonLoc().isInvalid()) { // Requesting lower bound or upper bound, but without provided length and // without ':' symbol for the default length -> length = 1. // Idx = LowerBound ?: 0; diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 988916ac017e..a874b8e8ebfa 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -1596,8 +1596,7 @@ OMPClause *Parser::ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, (Kind != OMPC_map)) || ((Kind == OMPC_reduction) && !InvalidReductionId) || ((Kind == OMPC_map) && (MapType != OMPC_MAP_unknown) && - (!MapTypeModifierSpecified || - (MapTypeModifierSpecified && MapTypeModifier == OMPC_MAP_always))) || + (!MapTypeModifierSpecified || MapTypeModifier == OMPC_MAP_always)) || ((Kind == OMPC_depend) && DepKind != OMPC_DEPEND_unknown); const bool MayHaveTail = (Kind == OMPC_linear || Kind == OMPC_aligned); while (IsComma || (Tok.isNot(tok::r_paren) && Tok.isNot(tok::colon) && diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 0790dd15e134..034b090fdf31 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1828,8 +1828,7 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) { (FromType->isSignedIntegerType() || // We can promote any unsigned integer type whose size is // less than int to an int. - (!FromType->isSignedIntegerType() && - Context.getTypeSize(FromType) < Context.getTypeSize(ToType)))) { + Context.getTypeSize(FromType) < Context.getTypeSize(ToType))) { return To->getKind() == BuiltinType::Int; } diff --git a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp index c663ccc1169d..8076ca09591f 100644 --- a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp @@ -582,8 +582,7 @@ void IvarInvalidationCheckerImpl::MethodCrawler::markInvalidated( // If InvalidationMethod is present, we are processing the message send and // should ensure we are invalidating with the appropriate method, // otherwise, we are processing setting to 'nil'. - if (!InvalidationMethod || - (InvalidationMethod && I->second.hasMethod(InvalidationMethod))) + if (!InvalidationMethod || I->second.hasMethod(InvalidationMethod)) IVars.erase(I); } } diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp index a63f6e496272..9b450ddf8905 100644 --- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1130,11 +1130,10 @@ void invalidateRegionsWorker::VisitCluster(const MemRegion *baseR, // Check offset is not symbolic and within array's boundaries. // Handles arrays of 0 elements and of 0-sized elements as well. if (!ROffset || - (ROffset && - ((*ROffset >= LowerOffset && *ROffset < UpperOffset) || - (UpperOverflow && - (*ROffset >= LowerOffset || *ROffset < UpperOffset)) || - (LowerOffset == UpperOffset && *ROffset == LowerOffset)))) { + ((*ROffset >= LowerOffset && *ROffset < UpperOffset) || + (UpperOverflow && + (*ROffset >= LowerOffset || *ROffset < UpperOffset)) || + (LowerOffset == UpperOffset && *ROffset == LowerOffset))) { B = B.removeBinding(I.getKey()); // Bound symbolic regions need to be invalidated for dead symbol // detection.