]> granicus.if.org Git - clang/commitdiff
Remove redundant conditions of the form (A || (!A && B)) -> (A || B)
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 11 Apr 2016 08:26:13 +0000 (08:26 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 11 Apr 2016 08:26:13 +0000 (08:26 +0000)
Found by cppcheck! PR27286 PR27287 PR27288 PR27289

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265918 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
lib/Parse/ParseOpenMP.cpp
lib/Sema/SemaOverload.cpp
lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
lib/StaticAnalyzer/Core/RegionStore.cpp

index 1b99f100de15e14ea049dd9dd85dc256024ca646..8329e52bde3044514f464d805ddca4ce68a86f73 100644 (file)
@@ -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;
index 988916ac017e0edd43f519536f2a0102759f59e9..a874b8e8ebfad102de0a809102d5b6cf6da507bf 100644 (file)
@@ -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) &&
index 0790dd15e1349a9cf4ffe07464760d7beb2e6092..034b090fdf31c3492e3a0cecf2b47088c0ce5147 100644 (file)
@@ -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;
     }
 
index c663ccc1169d33b363df3937bcd3a77354cb0c48..8076ca09591f80500a1aa012ff492f7805adfe47 100644 (file)
@@ -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);
   }
 }
index a63f6e49627232b161e7e99075e7ad573d280a6e..9b450ddf8905d37cd33828beeaa9b723a9c4d113 100644 (file)
@@ -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.