[clang] Suppress noreturn warning if last statement in a function is a throw (PR #145166)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 27 06:37:11 PDT 2025


================
@@ -2434,9 +2434,12 @@ Sema::PopFunctionScopeInfo(const AnalysisBasedWarnings::Policy *WP,
     OpenMP().popOpenMPFunctionRegion(Scope.get());
 
   // Issue any analysis-based warnings.
-  if (WP && D)
+  if (WP && D) {
+    if (auto *FD = dyn_cast<FunctionDecl>(D)) {
----------------
erichkeane wrote:

Instead of doing the cast here, can we have `inferNoReturnAttr` just take `Decl`, and early-exist if the cast isn't valid?  Cleans this up a little.

Additionally, this is a case where you'd have to skip curley braces per coding standard.

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


More information about the cfe-commits mailing list