@@ -1013,7 +1013,9 @@ static const Token * getVariableInitExpression(const Variable * var)
1013
1013
1014
1014
const Token* isInLoopCondition (const Token* tok)
1015
1015
{
1016
- const Token* top = tok->astTop ();
1016
+ if (!tok)
1017
+ return nullptr ;
1018
+ const Token* top = tok->astTop (true );
1017
1019
return Token::Match (top->previous (), " for|while (" ) ? top : nullptr ;
1018
1020
}
1019
1021
@@ -2243,12 +2245,12 @@ bool isReturnScope(const Token* const endToken, const Library& library, const To
2243
2245
!Token::findsimplematch (prev->link (), " break" , prev)) {
2244
2246
return isReturnScope (prev, library, unknownFunc, functionScope);
2245
2247
}
2246
- if (isEscaped (prev->link ()->astTop (), functionScope, library))
2248
+ if (isEscaped (prev->link ()->astTop (true ), functionScope, library))
2247
2249
return true ;
2248
2250
if (Token::Match (prev->link ()->previous (), " [;{}] {" ))
2249
2251
return isReturnScope (prev, library, unknownFunc, functionScope);
2250
2252
} else if (Token::simpleMatch (prev, " ;" )) {
2251
- if (prev->tokAt (-2 ) && hasNoreturnFunction (prev->tokAt (-2 )->astTop (), library, unknownFunc))
2253
+ if (prev->tokAt (-2 ) && hasNoreturnFunction (prev->tokAt (-2 )->astTop (true ), library, unknownFunc))
2252
2254
return true ;
2253
2255
// Unknown symbol
2254
2256
if (Token::Match (prev->tokAt (-2 ), " ;|}|{ %name% ;" ) && prev->previous ()->isIncompleteVar ()) {
@@ -2257,9 +2259,9 @@ bool isReturnScope(const Token* const endToken, const Library& library, const To
2257
2259
return false ;
2258
2260
}
2259
2261
if (Token::simpleMatch (prev->previous (), " ) ;" ) && prev->linkAt (-1 ) &&
2260
- isEscaped (prev->linkAt (-1 )->astTop (), functionScope, library))
2262
+ isEscaped (prev->linkAt (-1 )->astTop (true ), functionScope, library))
2261
2263
return true ;
2262
- if (isEscaped (prev->previous ()->astTop (), functionScope, library))
2264
+ if (isEscaped (prev->previous ()->astTop (true ), functionScope, library))
2263
2265
return true ;
2264
2266
// return/goto statement
2265
2267
prev = prev->previous ();
0 commit comments