[clang] f13850a - [AST] Migrate away from PointerUnion::dyn_cast (NFC) (#123499)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 19 10:57:02 PST 2025
Author: Kazu Hirata
Date: 2025-01-19T10:56:57-08:00
New Revision: f13850a92c13d41ee377b8ebb2c226895fddbb57
URL: https://github.com/llvm/llvm-project/commit/f13850a92c13d41ee377b8ebb2c226895fddbb57
DIFF: https://github.com/llvm/llvm-project/commit/f13850a92c13d41ee377b8ebb2c226895fddbb57.diff
LOG: [AST] Migrate away from PointerUnion::dyn_cast (NFC) (#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.
Added:
Modified:
clang/lib/AST/Decl.cpp
Removed:
################################################################################
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();
More information about the cfe-commits
mailing list