[clang] 09e7b40 - [libclang] Migrate away from PointerUnion::dyn_cast (NFC) (#125381)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 2 09:31:42 PST 2025
Author: Kazu Hirata
Date: 2025-02-02T09:31:39-08:00
New Revision: 09e7b40bd3d7a1a2d9153912224bcf612954ead5
URL: https://github.com/llvm/llvm-project/commit/09e7b40bd3d7a1a2d9153912224bcf612954ead5
DIFF: https://github.com/llvm/llvm-project/commit/09e7b40bd3d7a1a2d9153912224bcf612954ead5.diff
LOG: [libclang] Migrate away from PointerUnion::dyn_cast (NFC) (#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.
Added:
Modified:
clang/tools/libclang/CIndex.cpp
Removed:
################################################################################
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