[clang] [clang] Replace PointerUnion::dyn_cast with llvm::dyn_cast (NFC) (PR #231074)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 11 23:19:10 PDT 2026
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/231074
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.
Note that VDTemplSpec->getInstantiatedFrom() here returns
getSpecializedTemplateOrPartial() because the enclosing if statement
checks isTemplateInstantiation(...). In turn,
getSpecializedTemplateOrPartial() always returns a nonnull pointer by
construction.
Assisted-by: Antigravity
>From 395391bf4c916cb01e54d14fa54e3f3490a1fdac Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 11 Oct 2026 02:43:34 -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.
Note that VDTemplSpec->getInstantiatedFrom() here returns
getSpecializedTemplateOrPartial() because the enclosing if statement
checks isTemplateInstantiation(...). In turn,
getSpecializedTemplateOrPartial() always returns a nonnull pointer by
construction.
Assisted-by: Antigravity
---
clang/lib/AST/Decl.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 0c79fe07f8d0c..969339a00d1a6 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2717,7 +2717,7 @@ VarDecl *VarDecl::getTemplateInstantiationPattern() const {
if (auto *VDTemplSpec = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
if (isTemplateInstantiation(VDTemplSpec->getTemplateSpecializationKind())) {
auto From = VDTemplSpec->getInstantiatedFrom();
- if (auto *VTD = From.dyn_cast<VarTemplateDecl *>()) {
+ if (auto *VTD = dyn_cast<VarTemplateDecl *>(From)) {
while (!VTD->isMemberSpecialization()) {
auto *NewVTD = VTD->getInstantiatedFromMemberTemplate();
if (!NewVTD)
@@ -2727,7 +2727,7 @@ VarDecl *VarDecl::getTemplateInstantiationPattern() const {
return VTD->getTemplatedDecl();
}
if (auto *VTPSD =
- From.dyn_cast<VarTemplatePartialSpecializationDecl *>()) {
+ dyn_cast<VarTemplatePartialSpecializationDecl *>(From)) {
while (!VTPSD->isMemberSpecialization()) {
auto *NewVTPSD = VTPSD->getInstantiatedFromMember();
if (!NewVTPSD)
More information about the cfe-commits
mailing list