@@ -2174,17 +2174,28 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings *settings,
2174
2174
return !fun->isConst ();
2175
2175
}
2176
2176
2177
- const Token * ftok = tok2;
2178
- while (ftok && (!Token::Match (ftok, " [({]" ) || ftok->isCast ()))
2177
+ const Token* ftok = tok2, *ptok{} ;
2178
+ while (ftok && (!Token::Match (ftok, " [({]" ) || ftok->isCast ())) {
2179
2179
ftok = ftok->astParent ();
2180
+ if (ftok && ftok->tokType () == Token::eLogicalOp)
2181
+ ptok = ftok->astOperand1 (); // check lhs
2182
+ }
2183
+
2184
+ if ((ftok && Token::Match (ftok->link (), " )|} !!{" )) || (ptok && Token::Match (ptok->link (), " )|} !!{" ))) {
2185
+ bool isChanged = false , inconclusive = false ;
2186
+ if (ptok) {
2187
+ isChanged |= isVariableChangedByFunctionCall (ptok->next (), indirect, settings, &inconclusive); // lhs can be a function
2188
+ isChanged |= inconclusive;
2189
+ }
2180
2190
2181
- if (ftok && Token::Match (ftok->link (), " )|} !!{" )) {
2182
- const Token * ptok = tok2;
2183
- while (Token::Match (ptok->astParent (), " .|::|[" ))
2184
- ptok = ptok->astParent ();
2185
- bool inconclusive = false ;
2186
- bool isChanged = isVariableChangedByFunctionCall (ptok, indirect, settings, &inconclusive);
2187
- isChanged |= inconclusive;
2191
+ if (!isChanged) {
2192
+ ptok = tok2;
2193
+ while (Token::Match (ptok->astParent (), " .|::|[" ))
2194
+ ptok = ptok->astParent ();
2195
+
2196
+ isChanged = isVariableChangedByFunctionCall (ptok, indirect, settings, &inconclusive);
2197
+ isChanged |= inconclusive;
2198
+ }
2188
2199
if (isChanged)
2189
2200
return true ;
2190
2201
}
0 commit comments