@@ -702,22 +702,19 @@ void CheckCondition::multiCondition2()
702702 }
703703 }
704704 } else {
705- std::stack<const Token *> tokens2;
706- tokens2.push (cond2);
707- while (!tokens2.empty ()) {
708- const Token *secondCondition = tokens2.top ();
709- tokens2.pop ();
710- if (!secondCondition)
711- continue ;
712- if (secondCondition->str () == " ||" || secondCondition->str () == " &&" ) {
713- tokens2.push (secondCondition->astOperand1 ());
714- tokens2.push (secondCondition->astOperand2 ());
715- } else if ((!cond1->hasKnownIntValue () || !secondCondition->hasKnownIntValue ()) &&
716- isSameExpression (mTokenizer ->isCPP (), true , cond1, secondCondition, mSettings ->library , true , true , &errorPath)) {
717- if (!isAliased (vars))
705+ visitAstNodes (cond2, [&](const Token *secondCondition) {
706+ if (secondCondition->str () == " ||" || secondCondition->str () == " &&" )
707+ return ChildrenToVisit::op1_and_op2;
708+
709+ if ((!cond1->hasKnownIntValue () || !secondCondition->hasKnownIntValue ()) &&
710+ isSameExpression (mTokenizer ->isCPP (), true , cond1, secondCondition, mSettings ->library , true , true , &errorPath)) {
711+ if (!isAliased (vars) && !mTokenizer ->hasIfdef (cond1, secondCondition)) {
718712 identicalConditionAfterEarlyExitError (cond1, secondCondition, errorPath);
713+ return ChildrenToVisit::done;
714+ }
719715 }
720- }
716+ return ChildrenToVisit::none;
717+ });
721718 }
722719 }
723720 if (Token::Match (tok, " %name% (" ) && isVariablesChanged (tok, tok->linkAt (1 ), true , varsInCond, mSettings , mTokenizer ->isCPP ())) {
0 commit comments