File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3918,3 +3918,23 @@ const Token *skipUnreachableBranch(const Token *tok)
39183918
39193919 return tok;
39203920}
3921+
3922+ bool isEscapeKeyword (const Token *tok, const Settings &settings)
3923+ {
3924+ if (!tok)
3925+ return false ;
3926+
3927+ if (tok->str () == " return" )
3928+ return true ;
3929+
3930+ if (!tok->isCpp ())
3931+ return false ;
3932+
3933+ if (tok->str () == " throw" )
3934+ return true ;
3935+
3936+ if (settings.standards .cpp < Standards::CPP20 )
3937+ return false ;
3938+
3939+ return tok->str () == " co_return" ;
3940+ }
Original file line number Diff line number Diff line change @@ -463,4 +463,6 @@ bool isUnreachableOperand(const Token *tok);
463463
464464const Token *skipUnreachableBranch (const Token *tok);
465465
466+ bool isEscapeKeyword (const Token *tok, const Settings &settings);
467+
466468#endif // astutilsH
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ namespace {
144144 // If we are in a loop then jump to the end
145145 if (out)
146146 *out = loopEnds.back ();
147- } else if (Token::Match (tok, " return|co_return|throw " )) {
147+ } else if (isEscapeKeyword (tok, settings )) {
148148 traverseRecursive (tok->astOperand2 (), f, traverseUnknown);
149149 traverseRecursive (tok->astOperand1 (), f, traverseUnknown);
150150 return Break (Analyzer::Terminate::Escape);
You can’t perform that action at this time.
0 commit comments