Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 1e146df

Browse files
[Sema] Migrate away from PointerUnion::{is,get} (NFC) (llvm#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>;
1 parent bb86c5d commit 1e146df

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

clang/include/clang/Sema/SemaConcept.h

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,31 +135,20 @@ struct NormalizedConstraint {
135135
return *this;
136136
}
137137

138-
bool isAtomic() const { return Constraint.is<AtomicConstraint *>(); }
138+
bool isAtomic() const { return llvm::isa<AtomicConstraint *>(Constraint); }
139139
bool isFoldExpanded() const {
140-
return Constraint.is<FoldExpandedConstraint *>();
140+
return llvm::isa<FoldExpandedConstraint *>(Constraint);
141141
}
142-
bool isCompound() const { return Constraint.is<CompoundConstraint>(); }
142+
bool isCompound() const { return llvm::isa<CompoundConstraint>(Constraint); }
143143

144-
CompoundConstraintKind getCompoundKind() const {
145-
assert(isCompound() && "getCompoundKind on a non-compound constraint..");
146-
return Constraint.get<CompoundConstraint>().getInt();
147-
}
144+
CompoundConstraintKind getCompoundKind() const;
148145

149146
NormalizedConstraint &getLHS() const;
150147
NormalizedConstraint &getRHS() const;
151148

152-
AtomicConstraint *getAtomicConstraint() const {
153-
assert(isAtomic() &&
154-
"getAtomicConstraint called on non-atomic constraint.");
155-
return Constraint.get<AtomicConstraint *>();
156-
}
149+
AtomicConstraint *getAtomicConstraint() const;
157150

158-
FoldExpandedConstraint *getFoldExpandedConstraint() const {
159-
assert(isFoldExpanded() &&
160-
"getFoldExpandedConstraint called on non-fold-expanded constraint.");
161-
return Constraint.get<FoldExpandedConstraint *>();
162-
}
151+
FoldExpandedConstraint *getFoldExpandedConstraint() const;
163152

164153
private:
165154
static std::optional<NormalizedConstraint>

clang/lib/Sema/SemaConcept.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,3 +1958,21 @@ concepts::TypeRequirement::TypeRequirement(TypeSourceInfo *T) :
19581958
Value(T),
19591959
Status(T->getType()->isInstantiationDependentType() ? SS_Dependent
19601960
: SS_Satisfied) {}
1961+
1962+
NormalizedConstraint::CompoundConstraintKind
1963+
NormalizedConstraint::getCompoundKind() const {
1964+
assert(isCompound() && "getCompoundKind on a non-compound constraint..");
1965+
return cast<CompoundConstraint>(Constraint).getInt();
1966+
}
1967+
1968+
AtomicConstraint *NormalizedConstraint::getAtomicConstraint() const {
1969+
assert(isAtomic() && "getAtomicConstraint called on non-atomic constraint.");
1970+
return cast<AtomicConstraint *>(Constraint);
1971+
}
1972+
1973+
FoldExpandedConstraint *
1974+
NormalizedConstraint::getFoldExpandedConstraint() const {
1975+
assert(isFoldExpanded() &&
1976+
"getFoldExpandedConstraint called on non-fold-expanded constraint.");
1977+
return cast<FoldExpandedConstraint *>(Constraint);
1978+
}

0 commit comments

Comments
 (0)