https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/123499
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 Init to be nonnull. Note that hasInit returns true only if Init is nonnull among other conditions. >From 51fb3aa62de7baf336de8872a1b8552156419d30 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Sat, 18 Jan 2025 10:01: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 Init to be nonnull. Note that hasInit returns true only if Init is nonnull among other conditions. --- clang/lib/AST/Decl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 30341b046f95e3..f641a72ed26448 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -2399,7 +2399,7 @@ Expr *VarDecl::getInit() { if (!hasInit()) return nullptr; - if (auto *S = Init.dyn_cast<Stmt *>()) + if (auto *S = dyn_cast<Stmt *>(Init)) return cast<Expr>(S); auto *Eval = getEvaluatedStmt(); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits