Author: Kazu Hirata Date: 2024-12-21T08:17:41-08:00 New Revision: 1e146dfb4fc82229c17ba5a7da847d87de214351
URL: https://github.com/llvm/llvm-project/commit/1e146dfb4fc82229c17ba5a7da847d87de214351 DIFF: https://github.com/llvm/llvm-project/commit/1e146dfb4fc82229c17ba5a7da847d87de214351.diff LOG: [Sema] Migrate away from PointerUnion::{is,get} (NFC) (#120829) Note that PointerUnion::{is,get} have 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> I'm moving the definitions of several functions to SemaConcept.cpp because llvm::cast requires the full definitions of NormalizedConstraintPair, which is used like so: using CompoundConstraint = llvm::PointerIntPair<NormalizedConstraintPair *, 1, CompoundConstraintKind>; Added: Modified: clang/include/clang/Sema/SemaConcept.h clang/lib/Sema/SemaConcept.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Sema/SemaConcept.h b/clang/include/clang/Sema/SemaConcept.h index fa5309a597b3a5..5c599a70532f63 100644 --- a/clang/include/clang/Sema/SemaConcept.h +++ b/clang/include/clang/Sema/SemaConcept.h @@ -135,31 +135,20 @@ struct NormalizedConstraint { return *this; } - bool isAtomic() const { return Constraint.is<AtomicConstraint *>(); } + bool isAtomic() const { return llvm::isa<AtomicConstraint *>(Constraint); } bool isFoldExpanded() const { - return Constraint.is<FoldExpandedConstraint *>(); + return llvm::isa<FoldExpandedConstraint *>(Constraint); } - bool isCompound() const { return Constraint.is<CompoundConstraint>(); } + bool isCompound() const { return llvm::isa<CompoundConstraint>(Constraint); } - CompoundConstraintKind getCompoundKind() const { - assert(isCompound() && "getCompoundKind on a non-compound constraint.."); - return Constraint.get<CompoundConstraint>().getInt(); - } + CompoundConstraintKind getCompoundKind() const; NormalizedConstraint &getLHS() const; NormalizedConstraint &getRHS() const; - AtomicConstraint *getAtomicConstraint() const { - assert(isAtomic() && - "getAtomicConstraint called on non-atomic constraint."); - return Constraint.get<AtomicConstraint *>(); - } + AtomicConstraint *getAtomicConstraint() const; - FoldExpandedConstraint *getFoldExpandedConstraint() const { - assert(isFoldExpanded() && - "getFoldExpandedConstraint called on non-fold-expanded constraint."); - return Constraint.get<FoldExpandedConstraint *>(); - } + FoldExpandedConstraint *getFoldExpandedConstraint() const; private: static std::optional<NormalizedConstraint> diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index ff1df7b71b1a4f..539de00bd104f5 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -1958,3 +1958,21 @@ concepts::TypeRequirement::TypeRequirement(TypeSourceInfo *T) : Value(T), Status(T->getType()->isInstantiationDependentType() ? SS_Dependent : SS_Satisfied) {} + +NormalizedConstraint::CompoundConstraintKind +NormalizedConstraint::getCompoundKind() const { + assert(isCompound() && "getCompoundKind on a non-compound constraint.."); + return cast<CompoundConstraint>(Constraint).getInt(); +} + +AtomicConstraint *NormalizedConstraint::getAtomicConstraint() const { + assert(isAtomic() && "getAtomicConstraint called on non-atomic constraint."); + return cast<AtomicConstraint *>(Constraint); +} + +FoldExpandedConstraint * +NormalizedConstraint::getFoldExpandedConstraint() const { + assert(isFoldExpanded() && + "getFoldExpandedConstraint called on non-fold-expanded constraint."); + return cast<FoldExpandedConstraint *>(Constraint); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits