[llvm] [PatternMatch] Add matchers for `m_{I,F,}Cmp` and `m_{I,F,}SpecificCmp`; NFC (PR #98282)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 10 01:47:40 PDT 2024
================
@@ -1548,25 +1548,38 @@ template <typename T> inline Exact_match<T> m_Exact(const T &SubPattern) {
//
template <typename LHS_t, typename RHS_t, typename Class, typename PredicateTy,
- bool Commutable = false>
+ bool Commutable = false, bool MatchExistingPred = false>
struct CmpClass_match {
- PredicateTy &Predicate;
+ static_assert(!Commutable || !MatchExistingPred,
+ "Can't match predicate when using commutable matcher");
+
+ // Make predicate ty const ref if we are matching. Not strictly necessary but
+ // will cause a compilation warning if we accidentally try to set it with
+ // MatchExistingPred enabled.
+ using InternalPredTy =
+ std::conditional_t<MatchExistingPred, const PredicateTy &, PredicateTy &>;
----------------
dtcxzyw wrote:
```suggestion
std::conditional_t<MatchExistingPred, const PredicateTy, PredicateTy &>;
```
Would be better to pass by value?
https://github.com/llvm/llvm-project/pull/98282
More information about the llvm-commits
mailing list