[clang] [clang] Replace PointerUnion::dyn_cast with llvm::dyn_cast (NFC) (PR #231373)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 12 23:22:56 PDT 2026
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/231373
PointerUnion::dyn_cast has been soft-deprecated in favor of
llvm::dyn_cast and llvm::dyn_cast_if_present. This patch replaces the
former with llvm::dyn_cast where the operand is guaranteed to be
nonnull.
ClassTemplateSpecializationDecl::getSpecializedTemplateOrPartial()
always returns a nonnull pointer by construction regardless of whether
the specialization is from a primary template or a partial
specialization.
Assisted-by: Antigravity
>From afca571227fd22361e5528a21ec647ccd909ef82 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 12 Oct 2026 12:50:53 -0700
Subject: [PATCH] [clang] Replace PointerUnion::dyn_cast with llvm::dyn_cast
(NFC)
PointerUnion::dyn_cast has been soft-deprecated in favor of
llvm::dyn_cast and llvm::dyn_cast_if_present. This patch replaces the
former with llvm::dyn_cast where the operand is guaranteed to be
nonnull.
ClassTemplateSpecializationDecl::getSpecializedTemplateOrPartial()
always returns a nonnull pointer by construction regardless of whether
the specialization is from a primary template or a partial
specialization.
Assisted-by: Antigravity
---
clang/lib/Index/IndexDecl.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp
index 311beb68a3daf..8bcad4739c788 100644
--- a/clang/lib/Index/IndexDecl.cpp
+++ b/clang/lib/Index/IndexDecl.cpp
@@ -213,7 +213,7 @@ class IndexingDeclVisitor : public ConstDeclVisitor<IndexingDeclVisitor, bool> {
llvm::PointerUnion<ClassTemplateDecl *,
ClassTemplatePartialSpecializationDecl *>
Template = CTSD->getSpecializedTemplateOrPartial();
- if (const auto *CTD = Template.dyn_cast<ClassTemplateDecl *>()) {
+ if (const auto *CTD = dyn_cast<ClassTemplateDecl *>(Template)) {
const CXXRecordDecl *Pattern = CTD->getTemplatedDecl();
bool TypeOverride = isa<TypeDecl>(D);
for (const NamedDecl *ND : Pattern->lookup(D->getDeclName())) {
More information about the cfe-commits
mailing list