[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #124228)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 23 21:34:52 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/124228
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 Source to be nonnull.
>From a989ce3641c80eaabca06d4e5069c1460a3367ce Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 23 Jan 2025 09:08:22 -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 Source to be nonnull.
---
clang/lib/AST/ByteCode/Descriptor.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Descriptor.cpp b/clang/lib/AST/ByteCode/Descriptor.cpp
index 437b9f1bab2d6a..1c16c2022dd028 100644
--- a/clang/lib/AST/ByteCode/Descriptor.cpp
+++ b/clang/lib/AST/ByteCode/Descriptor.cpp
@@ -428,17 +428,17 @@ QualType Descriptor::getElemQualType() const {
}
SourceLocation Descriptor::getLocation() const {
- if (auto *D = Source.dyn_cast<const Decl *>())
+ if (auto *D = dyn_cast<const Decl *>(Source))
return D->getLocation();
- if (auto *E = Source.dyn_cast<const Expr *>())
+ if (auto *E = dyn_cast<const Expr *>(Source))
return E->getExprLoc();
llvm_unreachable("Invalid descriptor type");
}
SourceInfo Descriptor::getLoc() const {
- if (const auto *D = Source.dyn_cast<const Decl *>())
+ if (const auto *D = dyn_cast<const Decl *>(Source))
return SourceInfo(D);
- if (const auto *E = Source.dyn_cast<const Expr *>())
+ if (const auto *E = dyn_cast<const Expr *>(Source))
return SourceInfo(E);
llvm_unreachable("Invalid descriptor type");
}
More information about the cfe-commits
mailing list