[clang] [libclang] Migrate away from PointerUnion::dyn_cast (NFC) (PR #125381)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 1 21:12:35 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/125381
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 Storage to be nonnull.
>From 3e29632322b575eae8302d931a3dcc4d5bad9d08 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 1 Feb 2025 14:00:00 -0800
Subject: [PATCH] [libclang] 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 Storage to be nonnull.
---
clang/tools/libclang/CIndex.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 42f095fea2db26..bf7fdeec0cc51b 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -7415,11 +7415,11 @@ unsigned clang_getNumOverloadedDecls(CXCursor C) {
return 0;
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(C).first;
- if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>())
+ if (const OverloadExpr *E = dyn_cast<const OverloadExpr *>(Storage))
return E->getNumDecls();
if (OverloadedTemplateStorage *S =
- Storage.dyn_cast<OverloadedTemplateStorage *>())
+ dyn_cast<OverloadedTemplateStorage *>(Storage))
return S->size();
const Decl *D = cast<const Decl *>(Storage);
@@ -7438,11 +7438,11 @@ CXCursor clang_getOverloadedDecl(CXCursor cursor, unsigned index) {
CXTranslationUnit TU = getCursorTU(cursor);
OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(cursor).first;
- if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>())
+ if (const OverloadExpr *E = dyn_cast<const OverloadExpr *>(Storage))
return MakeCXCursor(E->decls_begin()[index], TU);
if (OverloadedTemplateStorage *S =
- Storage.dyn_cast<OverloadedTemplateStorage *>())
+ dyn_cast<OverloadedTemplateStorage *>(Storage))
return MakeCXCursor(S->begin()[index], TU);
const Decl *D = cast<const Decl *>(Storage);
More information about the cfe-commits
mailing list