[AST] Migrate away from PointerUnion::dyn_cast (NFC) (#124430)

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.
This commit is contained in:
Kazu Hirata 2025-01-25 14:05:11 -08:00 committed by GitHub
parent 563c7c5539
commit 04d5608057
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1801,8 +1801,7 @@ TemplateParameterList *clang::getReplacedTemplateParameterList(Decl *D) {
case Decl::Kind::VarTemplateSpecialization: {
const auto *VTSD = cast<VarTemplateSpecializationDecl>(D);
auto P = VTSD->getSpecializedTemplateOrPartial();
if (const auto *VTPSD =
P.dyn_cast<VarTemplatePartialSpecializationDecl *>())
if (const auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl *>(P))
return VTPSD->getTemplateParameters();
return cast<VarTemplateDecl *>(P)->getTemplateParameters();
}