Remove redundant conditions of the form (A || (!A && B)) -> (A || B)

Found by cppcheck! PR27286 PR27287 PR27288 PR27289

llvm-svn: 265918
This commit is contained in:
Benjamin Kramer 2016-04-11 08:26:13 +00:00
parent 85eda12d09
commit 5ff6747e04
5 changed files with 8 additions and 12 deletions

View 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;

View 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) &&

View 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;
}

View 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);
}
}

View 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.