================ @@ -4780,42 +4781,38 @@ struct FunctionEffectWithCondition { /// Return a textual description of the effect, and its condition, if any. std::string description() const; - - friend bool operator<(const FunctionEffectWithCondition &LHS, - const FunctionEffectWithCondition &RHS) { - if (LHS.Effect < RHS.Effect) - return true; - if (RHS.Effect < LHS.Effect) - return false; - return LHS.Cond.expr() < RHS.Cond.expr(); - } }; /// Support iteration in parallel through a pair of FunctionEffect and /// FunctionEffectCondition containers. template <typename Container> class FunctionEffectIterator { - const Container &Outer; - size_t Idx; + friend Container; + + const Container *Outer = nullptr; + size_t Idx = 0; public: - FunctionEffectIterator(const Container &O, size_t I) : Outer(O), Idx(I) {} + FunctionEffectIterator(); + FunctionEffectIterator(const Container &O, size_t I) : Outer(&O), Idx(I) {} bool operator==(const FunctionEffectIterator &Other) const { return Idx == Other.Idx; } bool operator!=(const FunctionEffectIterator &Other) const { return Idx != Other.Idx; } - // prefix increment FunctionEffectIterator operator++() { ++Idx; return *this; } - FunctionEffectWithCondition operator*() const { - const bool HasConds = !Outer.Conditions.empty(); - return FunctionEffectWithCondition{Outer.Effects[Idx], - HasConds ? Outer.Conditions[Idx] + const FunctionEffectWithCondition operator*() const { + // Returns a const struct because storing into it would not accomplish + // anything. ---------------- Sirraide wrote:
That may be true, but I don’t think we return a `const` object by value pretty much ever; imo just returning by value is enough to clarify that. https://github.com/llvm/llvm-project/pull/84983 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits