[clang] [clang] Migrate away from PointerUnion::dyn_cast (NFC) (PR #124425)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 25 12:38:58 PST 2025
================
@@ -2009,7 +2009,8 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
/// Retrieve the template argument list as written in the sources,
/// if any.
const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten() const {
- if (auto *Info = ExplicitInfo.dyn_cast<ExplicitInstantiationInfo *>())
+ if (auto *Info =
+ dyn_cast_if_present<ExplicitInstantiationInfo *>(ExplicitInfo))
----------------
kazutakahirata wrote:
I also thought so, but surprisingly, `cast<T *>(PU)`, where `PU` satisfies `PU.isNull()`, seems to work. I don't know if being "non-first" matters here.
For this reason, I'm migrating `PU.dyn_cast<T *>()` to `dyn_cast<T *>(PU)` if the if-then-else chain ends with some sort of dereference like `*cast<U *>(PU)` or `cast<U *>(PU)->foo()`.
https://github.com/llvm/llvm-project/pull/124425
More information about the cfe-commits
mailing list