Author: Kazu Hirata
Date: 2026-10-12T00:55:14-07:00
New Revision: 444bd7d287924ed8bef59168be051ef860e41422

URL: 
https://github.com/llvm/llvm-project/commit/444bd7d287924ed8bef59168be051ef860e41422
DIFF: 
https://github.com/llvm/llvm-project/commit/444bd7d287924ed8bef59168be051ef860e41422.diff

LOG: [clang] Replace PointerUnion::dyn_cast with llvm::dyn_cast (NFC) (#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

Added: 
    

Modified: 
    clang/lib/AST/Decl.cpp

Removed: 
    


################################################################################
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)


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

Reply via email to