[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #123499)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 18 22:19:49 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/123499.diff
1 Files Affected:
- (modified) clang/lib/AST/Decl.cpp (+1-1)
``````````diff
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();
``````````
</details>
https://github.com/llvm/llvm-project/pull/123499
More information about the cfe-commits
mailing list