[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #123012)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 14 21:46:27 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 P to be nonnull.
---
Full diff: https://github.com/llvm/llvm-project/pull/123012.diff
1 Files Affected:
- (modified) clang/lib/AST/ASTImporter.cpp (+1-1)
``````````diff
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index dec4c7221bc776..0669aa1b809c34 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -6376,7 +6376,7 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl(
D2->setTemplateSpecializationKind(D->getTemplateSpecializationKind());
if (auto P = D->getInstantiatedFrom()) {
- if (auto *CTD = P.dyn_cast<ClassTemplateDecl *>()) {
+ if (auto *CTD = dyn_cast<ClassTemplateDecl *>(P)) {
if (auto CTDorErr = import(CTD))
D2->setInstantiationOf(*CTDorErr);
} else {
``````````
</details>
https://github.com/llvm/llvm-project/pull/123012
More information about the cfe-commits
mailing list