[clang] [Sema] Migrate away from PointerUnion::dyn_cast (NFC) (PR #125457)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 2 21:37:59 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/125457
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 typeDecl to be nonnull. Note that
getObjCInterfaceType starts out dereferencing Decl.
>From 605c32f531a4879de975350d47fc1015e7b45dbe Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 2 Feb 2025 12:44:34 -0800
Subject: [PATCH] [Sema] 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 typeDecl to be nonnull. Note that
getObjCInterfaceType starts out dereferencing Decl.
---
clang/lib/Sema/SemaDeclObjC.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index f97f17e8c96588..e665d0293dc84d 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -1584,7 +1584,7 @@ void SemaObjC::actOnObjCTypeArgsOrProtocolQualifiers(
const char* prevSpec; // unused
unsigned diagID; // unused
QualType type;
- if (auto *actualTypeDecl = typeDecl.dyn_cast<TypeDecl *>())
+ if (auto *actualTypeDecl = dyn_cast<TypeDecl *>(typeDecl))
type = Context.getTypeDeclType(actualTypeDecl);
else
type = Context.getObjCInterfaceType(cast<ObjCInterfaceDecl *>(typeDecl));
More information about the cfe-commits
mailing list