@@ -1096,7 +1096,7 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett
10961096 value.setImpossible ();
10971097 setTokenValue (tok, std::move (value), settings);
10981098 }
1099- if (Token::simpleMatch (tok, " ?" ) && Token::Match (tok->astOperand1 (), " <|<=|>|>=" )) {
1099+ else if (Token::simpleMatch (tok, " ?" ) && Token::Match (tok->astOperand1 (), " <|<=|>|>=" )) {
11001100 const Token* condTok = tok->astOperand1 ();
11011101 const Token* branchesTok = tok->astOperand2 ();
11021102
@@ -1139,11 +1139,20 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett
11391139 setTokenValue (tok, std::move (value), settings);
11401140 }
11411141
1142- } else if (Token::simpleMatch ( tok, " % " ) && tok->astOperand2 () && tok->astOperand2 ()->hasKnownIntValue ()) {
1142+ } else if (tok-> isBinaryOp ( ) && tok->str () == " % " && tok->astOperand2 ()->hasKnownIntValue ()) {
11431143 ValueFlow::Value value{tok->astOperand2 ()->getKnownIntValue ()};
11441144 value.bound = ValueFlow::Value::Bound::Lower;
11451145 value.setImpossible ();
11461146 setTokenValue (tok, std::move (value), settings);
1147+ } else if (tok->isBinaryOp () && tok->str () == " |" ) {
1148+ const ValueFlow::Value* opVal = tok->astOperand1 ()->getKnownValue (ValueFlow::Value::ValueType::INT );
1149+ if (!opVal)
1150+ opVal = tok->astOperand2 ()->getKnownValue (ValueFlow::Value::ValueType::INT );
1151+ if (opVal && opVal->intvalue != 0 ) {
1152+ ValueFlow::Value value{0 };
1153+ value.setImpossible ();
1154+ setTokenValue (tok, std::move (value), settings);
1155+ }
11471156 } else if (Token::Match (tok, " abs|labs|llabs|fabs|fabsf|fabsl (" )) {
11481157 ValueFlow::Value value{-1 };
11491158 value.bound = ValueFlow::Value::Bound::Upper;
0 commit comments