Skip to content

Commit 141af7c

Browse files
committed
C++: Subclasses for both 'begin' and 'end'.
1 parent 6e3ddde commit 141af7c

File tree

1 file changed

+22
-5
lines changed
  • cpp/ql/lib/semmle/code/cpp/models/implementations

1 file changed

+22
-5
lines changed

cpp/ql/lib/semmle/code/cpp/models/implementations/Iterator.qll

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,17 +579,34 @@ private class IteratorAssignmentMemberOperatorModel extends IteratorAssignmentMe
579579
override predicate parameterEscapesOnlyViaReturn(int index) { index = -1 }
580580
}
581581

582+
/**
583+
* A `begin` member function, or a related function, that returns an iterator.
584+
*/
585+
class BeginFunction extends MemberFunction {
586+
BeginFunction() {
587+
this.hasName(["begin", "cbegin", "rbegin", "crbegin", "before_begin", "cbefore_begin"]) and
588+
this.getType().getUnspecifiedType() instanceof Iterator
589+
}
590+
}
591+
592+
/**
593+
* An `end` member function, or a related function, that returns an iterator.
594+
*/
595+
class EndFunction extends MemberFunction {
596+
EndFunction() {
597+
this.hasName(["end", "cend", "rend", "crend"]) and
598+
this.getType().getUnspecifiedType() instanceof Iterator
599+
}
600+
}
601+
582602
/**
583603
* A `begin` or `end` member function, or a related member function, that
584604
* returns an iterator.
585605
*/
586606
class BeginOrEndFunction extends MemberFunction {
587607
BeginOrEndFunction() {
588-
this.hasName([
589-
"begin", "cbegin", "rbegin", "crbegin", "end", "cend", "rend", "crend", "before_begin",
590-
"cbefore_begin"
591-
]) and
592-
this.getType().getUnspecifiedType() instanceof Iterator
608+
this instanceof BeginFunction or
609+
this instanceof EndFunction
593610
}
594611
}
595612

0 commit comments

Comments
 (0)