[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #123444)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 17 20:57:57 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/123444
Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:
// FIXME: Replace the uses of is(), get() and dyn_cast() with
// isa<T>, cast<T> and the llvm::dyn_cast<T>
Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect ValueOrInherited to be nonnull. Note that isSet
checks to see if ValueOrInherited is nonnull.
>From 217e63888adcc9f6bf917707943a9437152eb027 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 17 Jan 2025 09:18:21 -0800
Subject: [PATCH] [AST] Migrate away from PointerUnion::dyn_cast (NFC)
Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:
// FIXME: Replace the uses of is(), get() and dyn_cast() with
// isa<T>, cast<T> and the llvm::dyn_cast<T>
Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect ValueOrInherited to be nonnull. Note that isSet
checks to see if ValueOrInherited is nonnull.
---
clang/include/clang/AST/DeclTemplate.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h
index d3a466a8617bb1..8c2da97c07a3bf 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -367,12 +367,11 @@ class DefaultArgStorage {
if (!isSet())
ValueOrInherited = InheritedFrom;
else if ([[maybe_unused]] auto *D =
- ValueOrInherited.template dyn_cast<ParmDecl *>()) {
+ dyn_cast<ParmDecl *>(ValueOrInherited)) {
assert(C.isSameDefaultTemplateArgument(D, InheritedFrom));
ValueOrInherited =
new (allocateDefaultArgStorageChain(C)) Chain{InheritedFrom, get()};
- } else if (auto *Inherited =
- ValueOrInherited.template dyn_cast<Chain *>()) {
+ } else if (auto *Inherited = dyn_cast<Chain *>(ValueOrInherited)) {
assert(C.isSameDefaultTemplateArgument(Inherited->PrevDeclWithDefaultArg,
InheritedFrom));
Inherited->PrevDeclWithDefaultArg = InheritedFrom;
More information about the cfe-commits
mailing list