diff --git a/cpp/ql/lib/semmle/code/cpp/models/implementations/Iterator.qll b/cpp/ql/lib/semmle/code/cpp/models/implementations/Iterator.qll index 8e527c7e694..89658000c8a 100644 --- a/cpp/ql/lib/semmle/code/cpp/models/implementations/Iterator.qll +++ b/cpp/ql/lib/semmle/code/cpp/models/implementations/Iterator.qll @@ -579,17 +579,34 @@ private class IteratorAssignmentMemberOperatorModel extends IteratorAssignmentMe override predicate parameterEscapesOnlyViaReturn(int index) { index = -1 } } +/** + * A `begin` member function, or a related function, that returns an iterator. + */ +class BeginFunction extends MemberFunction { + BeginFunction() { + this.hasName(["begin", "cbegin", "rbegin", "crbegin", "before_begin", "cbefore_begin"]) and + this.getType().getUnspecifiedType() instanceof Iterator + } +} + +/** + * An `end` member function, or a related function, that returns an iterator. + */ +class EndFunction extends MemberFunction { + EndFunction() { + this.hasName(["end", "cend", "rend", "crend"]) and + this.getType().getUnspecifiedType() instanceof Iterator + } +} + /** * A `begin` or `end` member function, or a related member function, that * returns an iterator. */ class BeginOrEndFunction extends MemberFunction { BeginOrEndFunction() { - this.hasName([ - "begin", "cbegin", "rbegin", "crbegin", "end", "cend", "rend", "crend", "before_begin", - "cbefore_begin" - ]) and - this.getType().getUnspecifiedType() instanceof Iterator + this instanceof BeginFunction or + this instanceof EndFunction } }