[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #122651)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 12 15:16:37 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 Ptr to be nonnull.
---
Full diff: https://github.com/llvm/llvm-project/pull/122651.diff
1 Files Affected:
- (modified) clang/include/clang/AST/DeclBase.h (+2-2)
``````````diff
diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h
index 82932e098c86f0..77abd8b657a616 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1334,7 +1334,7 @@ class DeclListNode {
reference operator*() const {
assert(Ptr && "dereferencing end() iterator");
- if (DeclListNode *CurNode = Ptr.dyn_cast<DeclListNode*>())
+ if (DeclListNode *CurNode = dyn_cast<DeclListNode *>(Ptr))
return CurNode->D;
return cast<NamedDecl *>(Ptr);
}
@@ -1344,7 +1344,7 @@ class DeclListNode {
inline iterator &operator++() { // ++It
assert(!Ptr.isNull() && "Advancing empty iterator");
- if (DeclListNode *CurNode = Ptr.dyn_cast<DeclListNode*>())
+ if (DeclListNode *CurNode = dyn_cast<DeclListNode *>(Ptr))
Ptr = CurNode->Rest;
else
Ptr = nullptr;
``````````
</details>
https://github.com/llvm/llvm-project/pull/122651
More information about the cfe-commits
mailing list