@@ -403,29 +403,27 @@ static bool isNoexcept(const FunctionDecl *FD) {
403403 return false ;
404404}
405405
406+ // / Checks if the given expression is a reference to a function with
407+ // / 'noreturn' attribute.
408+ static bool isReferenceToNoReturn (const Expr *E) {
409+ if (auto *DRef = dyn_cast<DeclRefExpr>(E->IgnoreParenCasts ()))
410+ if (auto *FD = dyn_cast<FunctionDecl>(DRef->getDecl ()))
411+ return FD->isNoReturn ();
412+ return false ;
413+ }
414+
406415// / Checks if the given variable, which is assumed to be a function pointer, is
407416// / initialized with a function having 'noreturn' attribute.
408417static bool isInitializedWithNoReturn (const VarDecl *VD) {
409418 if (const Expr *Init = VD->getInit ()) {
410419 if (auto *ListInit = dyn_cast<InitListExpr>(Init);
411420 ListInit && ListInit->getNumInits () > 0 )
412421 Init = ListInit->getInit (0 );
413- if (auto *DeclRef = dyn_cast<DeclRefExpr>(Init->IgnoreParenCasts ()))
414- if (auto *FD = dyn_cast<FunctionDecl>(DeclRef->getDecl ()))
415- return FD->isNoReturn ();
422+ return isReferenceToNoReturn (Init);
416423 }
417424 return false ;
418425}
419426
420- // / Checks if the given expression is a reference to a function with
421- // / 'noreturn' attribute.
422- static bool isReferenceToNoReturn (const Expr *E) {
423- if (auto *DRef = dyn_cast<DeclRefExpr>(E->IgnoreParenCasts ()))
424- if (auto *FD = dyn_cast<FunctionDecl>(DRef->getDecl ()))
425- return FD->isNoReturn ();
426- return false ;
427- }
428-
429427namespace {
430428
431429// / Looks for statements, that can define value of the given variable.
0 commit comments