Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

snarang181
Copy link
Contributor

Addressing #150003 (comment)

Copy link

github-actions bot commented Aug 2, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@snarang181 snarang181 force-pushed the inherit-noreturn-cleanup branch from c19d6a3 to 5dbdca1 Compare August 2, 2025 12:40
@snarang181 snarang181 marked this pull request as ready for review August 2, 2025 13:21
@snarang181 snarang181 requested a review from cor3ntin August 2, 2025 13:21
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 2, 2025

@llvm/pr-subscribers-clang

Author: Samarth Narang (snarang181)

Changes

Addressing #150003 (comment)


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

1 Files Affected:

  • (modified) clang/lib/Sema/SemaDecl.cpp (+4-5)
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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants