https://github.com/ipopov created 
https://github.com/llvm/llvm-project/pull/206298

`needsAnonymousDeclarationNumber()` takes a `const NamedDecl *`. Both 
`BlockDecl` and `NamedDecl` derive from `Decl`, in other words they're siblings.

* https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
* https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html

Thus `isa<BlockDecl>(D)` is statically false.

>From 8810a232daf9776943937e1a0b1835339be31441 Mon Sep 17 00:00:00 2001
From: Ivo Popov <[email protected]>
Date: Sat, 27 Jun 2026 19:49:46 -0400
Subject: [PATCH] [Serialization] Delete an unreachable BlockDecl check (NFC)

`needsAnonymousDeclarationNumber()` takes a `const NamedDecl *`. Both
`BlockDecl` and `NamedDecl` derive from `Decl`, in other words they're
siblings.

* https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
* https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html

Thus `isa<BlockDecl>(D)` is statically false. No functional change.
---
 clang/lib/Serialization/ASTCommon.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Serialization/ASTCommon.cpp 
b/clang/lib/Serialization/ASTCommon.cpp
index 49e6fe8004cec..cedba86e3267d 100644
--- a/clang/lib/Serialization/ASTCommon.cpp
+++ b/clang/lib/Serialization/ASTCommon.cpp
@@ -499,7 +499,7 @@ bool serialization::needsAnonymousDeclarationNumber(const 
NamedDecl *D) {
     if (auto *VD = dyn_cast<VarDecl>(D))
       return VD->isStaticLocal();
     // FIXME: What about CapturedDecls (and declarations nested within them)?
-    return isa<TagDecl, BlockDecl>(D);
+    return isa<TagDecl>(D);
   }
 
   // Otherwise, we only care about anonymous class members / block-scope decls.

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to