[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #123283)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 16 21:29:47 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/123283
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 a2dd67c227e151c613cf5d7143a01a46865e65ff Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 16 Jan 2025 09:26:55 -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/EvaluationResult.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/AST/ByteCode/EvaluationResult.cpp b/clang/lib/AST/ByteCode/EvaluationResult.cpp
index 0ce8f15ea9127c..d603e08c7bb4d4 100644
--- a/clang/lib/AST/ByteCode/EvaluationResult.cpp
+++ b/clang/lib/AST/ByteCode/EvaluationResult.cpp
@@ -160,9 +160,9 @@ bool EvaluationResult::checkFullyInitialized(InterpState &S,
return true;
SourceLocation InitLoc;
- if (const auto *D = Source.dyn_cast<const Decl *>())
+ if (const auto *D = dyn_cast<const Decl *>(Source))
InitLoc = cast<VarDecl>(D)->getAnyInitializer()->getExprLoc();
- else if (const auto *E = Source.dyn_cast<const Expr *>())
+ else if (const auto *E = dyn_cast<const Expr *>(Source))
InitLoc = E->getExprLoc();
if (const Record *R = Ptr.getRecord())
More information about the cfe-commits
mailing list