[clang] [clang] Replace PointerUnion::dyn_cast with llvm::dyn_cast_if_present (NFC) (PR #233191)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 17 23:02:55 PDT 2026
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/233191
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_if_present in
FriendTemplateDecl::getFriendDecl.
This is the only place under clang/ where migrating to llvm::dyn_cast
would trigger an assertion failure during check-clang.
Assisted-by: Antigravity
>From 928dadfb0e2325e16eb63306f35c58397496396d Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 17 Oct 2026 22:09:55 -0700
Subject: [PATCH] [clang] Replace PointerUnion::dyn_cast with
llvm::dyn_cast_if_present (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_if_present in
FriendTemplateDecl::getFriendDecl.
This is the only place under clang/ where migrating to llvm::dyn_cast
would trigger an assertion failure during check-clang.
Assisted-by: Antigravity
---
clang/include/clang/AST/DeclTemplate.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h
index 575ca86155742e..5724645602d9b3 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -2529,7 +2529,7 @@ class FriendTemplateDecl final
}
NamedDecl *getFriendDecl() const override {
- if (NamedDecl *ND = Friend.dyn_cast<NamedDecl *>())
+ if (NamedDecl *ND = dyn_cast_if_present<NamedDecl *>(Friend))
return ND;
return Template.getAsTemplateDecl();
}
More information about the cfe-commits
mailing list