[clang] [Analysis] Avoid some warnings about exit from noreturn function (PR #144408)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 24 09:20:53 PDT 2025


================
@@ -399,6 +401,145 @@ static bool isNoexcept(const FunctionDecl *FD) {
   return false;
 }
 
+/// Checks if the given variable, which is assumed to be a function pointer, is
+/// initialized with a function having 'noreturn' attribute.
+static bool isInitializedWithNoReturn(const VarDecl *VD) {
+  if (const Expr *Init = VD->getInit()) {
+    if (auto *ListInit = dyn_cast<InitListExpr>(Init);
+        ListInit && ListInit->getNumInits() > 0)
+      Init = ListInit->getInit(0);
+    if (auto *DeclRef = dyn_cast<DeclRefExpr>(Init->IgnoreParenCasts()))
----------------
erichkeane wrote:

Can we change this to:

`return isReferenceToNoReturn(Init)`? 

https://github.com/llvm/llvm-project/pull/144408


More information about the cfe-commits mailing list