https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/125631
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. Note that if Storage were null, dereferencing Ovl would trigger a segfault. >From d1f18339591a14da97a6300959f5b0284c19acfe Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Mon, 3 Feb 2025 17:37:21 -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. Note that if Storage were null, dereferencing Ovl would trigger a segfault. --- clang/tools/libclang/CIndex.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 697cc4776839dc..6f0e9f2a9688c6 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -5370,12 +5370,12 @@ CXString clang_getCursorSpelling(CXCursor C) { case CXCursor_OverloadedDeclRef: { OverloadedDeclRefStorage Storage = getCursorOverloadedDeclRef(C).first; - if (const Decl *D = Storage.dyn_cast<const Decl *>()) { + if (const Decl *D = dyn_cast<const Decl *>(Storage)) { if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) return cxstring::createDup(ND->getNameAsString()); return cxstring::createEmpty(); } - if (const OverloadExpr *E = Storage.dyn_cast<const OverloadExpr *>()) + if (const OverloadExpr *E = dyn_cast<const OverloadExpr *>(Storage)) return cxstring::createDup(E->getName().getAsString()); OverloadedTemplateStorage *Ovl = cast<OverloadedTemplateStorage *>(Storage); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits