[clang] [Sema] Migrate away from PointerUnion::{is, get} (NFC) (PR #120829)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 21 00:26:09 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
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>;
---
Full diff: https://github.com/llvm/llvm-project/pull/120829.diff
2 Files Affected:
- (modified) clang/include/clang/Sema/SemaConcept.h (+6-17)
- (modified) clang/lib/Sema/SemaConcept.cpp (+18)
``````````diff
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);
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/120829
More information about the cfe-commits
mailing list