[clang] [clang][NFC] Code Cleanup of inferred noreturn attributes in explicit specializations. (PR #151815)

via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 2 06:22:28 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Samarth Narang (snarang181)

<details>
<summary>Changes</summary>

Addressing https://github.com/llvm/llvm-project/pull/150003#discussion_r2249169463

---
Full diff: https://github.com/llvm/llvm-project/pull/151815.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaDecl.cpp (+4-5) 


``````````diff
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 20fdf2de59cb1..e56799deafa5c 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3269,11 +3269,10 @@ void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old,
       continue;
 
     if (isa<InferredNoReturnAttr>(I)) {
-      if (auto *FD = dyn_cast<FunctionDecl>(New)) {
-        if (FD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
-          continue; // Don't propagate inferred noreturn attributes to explicit
-                    // specializations.
-      }
+      if (auto *FD = dyn_cast<FunctionDecl>(New);
+          FD &&
+          FD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
+        continue; // Don't propagate inferred noreturn attributes to explicit
     }
 
     if (mergeDeclAttribute(*this, New, I, LocalAMK))

``````````

</details>


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


More information about the cfe-commits mailing list