[clang] [Serialization] Migrate away from PointerUnion::dyn_cast (NFC) (#124884) (PR #125024)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 29 20:18:09 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/125024
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 Subject to be nonnull.
>From f1ce01a3b1064ed0488f6c96a4e3016d71445c0f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 29 Jan 2025 09:02:57 -0800
Subject: [PATCH] [Serialization] Migrate away from PointerUnion::dyn_cast
(NFC) (#124884)
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 Subject to be nonnull.
---
clang/lib/Serialization/ASTWriter.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index e81a441d753b5dc..ef8ee5bc94d0ec6 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -5359,7 +5359,7 @@ ASTWriter::WriteAST(llvm::PointerUnion<Sema *, Preprocessor *> Subject,
llvm::TimeTraceScope scope("WriteAST", OutputFile);
WritingAST = true;
- Sema *SemaPtr = Subject.dyn_cast<Sema *>();
+ Sema *SemaPtr = dyn_cast<Sema *>(Subject);
Preprocessor &PPRef =
SemaPtr ? SemaPtr->getPreprocessor() : *cast<Preprocessor *>(Subject);
More information about the cfe-commits
mailing list