[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #124228)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 23 21:35:24 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 Source to be nonnull.
---
Full diff: https://github.com/llvm/llvm-project/pull/124228.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/Descriptor.cpp (+4-4)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Descriptor.cpp b/clang/lib/AST/ByteCode/Descriptor.cpp
index 437b9f1bab2d6a..1c16c2022dd028 100644
--- a/clang/lib/AST/ByteCode/Descriptor.cpp
+++ b/clang/lib/AST/ByteCode/Descriptor.cpp
@@ -428,17 +428,17 @@ QualType Descriptor::getElemQualType() const {
}
SourceLocation Descriptor::getLocation() const {
- if (auto *D = Source.dyn_cast<const Decl *>())
+ if (auto *D = dyn_cast<const Decl *>(Source))
return D->getLocation();
- if (auto *E = Source.dyn_cast<const Expr *>())
+ if (auto *E = dyn_cast<const Expr *>(Source))
return E->getExprLoc();
llvm_unreachable("Invalid descriptor type");
}
SourceInfo Descriptor::getLoc() const {
- if (const auto *D = Source.dyn_cast<const Decl *>())
+ if (const auto *D = dyn_cast<const Decl *>(Source))
return SourceInfo(D);
- if (const auto *E = Source.dyn_cast<const Expr *>())
+ if (const auto *E = dyn_cast<const Expr *>(Source))
return SourceInfo(E);
llvm_unreachable("Invalid descriptor type");
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/124228
More information about the cfe-commits
mailing list