https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/226653
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 on UnsatisfiedConstraintRecord because it is always nonnull. Specifically, ConstraintSatisfaction::Details only receives nonnull pointers in the following places: - ASTNodeImporter::ImportConstraintSatisfaction - ConstraintSatisfactionChecker::consumeSFINAEFailure - ConstraintSatisfactionChecker::EvaluateSlow - ConstraintSatisfactionChecker::Evaluate - readConstraintSatisfaction Assisted-by: Antigravity >From f9605409ad1bc74eb9023bedb96b4869f99e3663 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <[email protected]> Date: Fri, 25 Sep 2026 08:15:19 -0700 Subject: [PATCH] [clang] Migrate away from PointerUnion::dyn_cast (NFC) 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 on UnsatisfiedConstraintRecord because it is always nonnull. Specifically, ConstraintSatisfaction::Details only receives nonnull pointers in the following places: - ASTNodeImporter::ImportConstraintSatisfaction - ConstraintSatisfactionChecker::consumeSFINAEFailure - ConstraintSatisfactionChecker::EvaluateSlow - ConstraintSatisfactionChecker::Evaluate - readConstraintSatisfaction Assisted-by: Antigravity --- clang/include/clang/AST/ASTConcept.h | 2 +- clang/lib/Sema/SemaConcept.cpp | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/AST/ASTConcept.h b/clang/include/clang/AST/ASTConcept.h index 62fe2c0f653d57..839146f40445b2 100644 --- a/clang/include/clang/AST/ASTConcept.h +++ b/clang/include/clang/AST/ASTConcept.h @@ -76,7 +76,7 @@ class ConstraintSatisfaction : public llvm::FoldingSetNode { bool HasSubstitutionFailure() { for (const auto &Detail : Details) - if (Detail.dyn_cast<const ConstraintSubstitutionDiagnostic *>()) + if (dyn_cast<const ConstraintSubstitutionDiagnostic *>(Detail)) return true; return false; } diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 27c61586020ba1..d31d86919588ae 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -2009,9 +2009,7 @@ static void diagnoseWellFormedUnsatisfiedConstraintExpr(Sema &S, static void diagnoseUnsatisfiedConstraintExpr( Sema &S, const UnsatisfiedConstraintRecord &Record, SourceLocation Loc, bool First, concepts::NestedRequirement *Req) { - if (auto *Diag = - Record - .template dyn_cast<const ConstraintSubstitutionDiagnostic *>()) { + if (auto *Diag = dyn_cast<const ConstraintSubstitutionDiagnostic *>(Record)) { if (Req) S.Diag(Diag->first, diag::note_nested_requirement_substitution_error) << (int)First << Req->getInvalidConstraintEntity() << Diag->second; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
