File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1609,8 +1609,15 @@ namespace {
16091609 key.operand1 = op1 ? (i1 >= refs1.size () ? op1->exprId () : refs1[i1].token ->exprId ()) : 0 ;
16101610 key.operand2 = op2 ? (i2 >= refs2.size () ? op2->exprId () : refs2[i2].token ->exprId ()) : 0 ;
16111611
1612- if (key.operand1 > key.operand2 && key.operand2 && key.parentOp == " +" )
1613- std::swap (key.operand1 , key.operand2 );
1612+ if (key.operand1 > key.operand2 && key.operand2 &&
1613+ Token::Match (tok->astParent (), " %or%|%oror%|+|*|&|&&|^|==|!=" )) {
1614+ // In C++ the order of operands of + might matter
1615+ if (key.parentOp != " +" ||
1616+ !tok->astParent ()->valueType () ||
1617+ tok->astParent ()->valueType ()->isIntegral () ||
1618+ tok->astParent ()->valueType ()->isFloat ())
1619+ std::swap (key.operand1 , key.operand2 );
1620+ }
16141621
16151622 const auto it = exprIdMap.find (key);
16161623 if (it == exprIdMap.end ()) {
You can’t perform that action at this time.
0 commit comments