@@ -1013,7 +1013,9 @@ static const Token * getVariableInitExpression(const Variable * var)
10131013
10141014const Token* isInLoopCondition (const Token* tok)
10151015{
1016- const Token* top = tok->astTop ();
1016+ if (!tok)
1017+ return nullptr ;
1018+ const Token* top = tok->astTop (true );
10171019 return Token::Match (top->previous (), " for|while (" ) ? top : nullptr ;
10181020}
10191021
@@ -2243,12 +2245,12 @@ bool isReturnScope(const Token* const endToken, const Library& library, const To
22432245 !Token::findsimplematch (prev->link (), " break" , prev)) {
22442246 return isReturnScope (prev, library, unknownFunc, functionScope);
22452247 }
2246- if (isEscaped (prev->link ()->astTop (), functionScope, library))
2248+ if (isEscaped (prev->link ()->astTop (true ), functionScope, library))
22472249 return true ;
22482250 if (Token::Match (prev->link ()->previous (), " [;{}] {" ))
22492251 return isReturnScope (prev, library, unknownFunc, functionScope);
22502252 } 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))
22522254 return true ;
22532255 // Unknown symbol
22542256 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
22572259 return false ;
22582260 }
22592261 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))
22612263 return true ;
2262- if (isEscaped (prev->previous ()->astTop (), functionScope, library))
2264+ if (isEscaped (prev->previous ()->astTop (true ), functionScope, library))
22632265 return true ;
22642266 // return/goto statement
22652267 prev = prev->previous ();
0 commit comments