Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c7a019

Browse files
committed
C++: Improve the changes to Iterator.
1 parent c635166 commit 2c7a019

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

  • cpp/ql/src/semmle/code/cpp/models/implementations

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private class IteratorTraits extends Class {
2929
/**
3030
* A type which has the typedefs expected for an iterator.
3131
*/
32-
private class IteratorByTypedefs extends Class {
32+
private class IteratorByTypedefs extends Iterator, Class {
3333
IteratorByTypedefs() {
3434
this.getAMember().(TypedefType).hasName("difference_type") and
3535
this.getAMember().(TypedefType).hasName("value_type") and
@@ -43,18 +43,17 @@ private class IteratorByTypedefs extends Class {
4343
/**
4444
* The `std::iterator` class.
4545
*/
46-
private class StdIterator extends Class {
46+
private class StdIterator extends Iterator, Class {
4747
StdIterator() { this.hasQualifiedName("std", "iterator") }
4848
}
4949

5050
/**
51-
* Implements `Iterator`.
51+
* A type that is deduced to be an iterator because there is a corresponding
52+
* `std::iterator_traits` instantiation for it.
5253
*/
53-
private class IteratorImpl extends Iterator {
54-
IteratorImpl() {
55-
this instanceof IteratorByTypedefs or
56-
exists(IteratorTraits it | it.getIteratorType() = this) or
57-
this instanceof StdIterator
54+
private class IteratorByTraits extends Iterator {
55+
IteratorByTraits() {
56+
exists(IteratorTraits it | it.getIteratorType() = this)
5857
}
5958
}
6059

0 commit comments

Comments
 (0)