@@ -31,7 +31,17 @@ private class IteratorTraits extends Class {
3131 * `std::iterator_traits` instantiation for it.
3232 */
3333private class IteratorByTraits extends Iterator {
34- IteratorByTraits ( ) { exists ( IteratorTraits it | it .getIteratorType ( ) = this ) }
34+ IteratorTraits trait ;
35+
36+ IteratorByTraits ( ) { trait .getIteratorType ( ) = this }
37+
38+ override Type getValueType ( ) {
39+ exists ( TypedefType t |
40+ trait .getAMember ( ) = t and
41+ t .getName ( ) = "value_type" and
42+ result = t .getUnderlyingType ( )
43+ )
44+ }
3545}
3646
3747/**
@@ -42,27 +52,36 @@ private class IteratorByTraits extends Iterator {
4252 */
4353private class IteratorByPointer extends Iterator instanceof PointerType {
4454 IteratorByPointer ( ) { not this instanceof IteratorByTraits }
55+
56+ override Type getValueType ( ) { result = super .getBaseType ( ) }
4557}
4658
4759/**
4860 * A type which has the typedefs expected for an iterator.
4961 */
5062private class IteratorByTypedefs extends Iterator , Class {
63+ TypedefType valueType ;
64+
5165 IteratorByTypedefs ( ) {
5266 this .getAMember ( ) .( TypedefType ) .hasName ( "difference_type" ) and
53- this .getAMember ( ) .( TypedefType ) .hasName ( "value_type" ) and
67+ valueType = this .getAMember ( ) and
68+ valueType .hasName ( "value_type" ) and
5469 this .getAMember ( ) .( TypedefType ) .hasName ( "pointer" ) and
5570 this .getAMember ( ) .( TypedefType ) .hasName ( "reference" ) and
5671 this .getAMember ( ) .( TypedefType ) .hasName ( "iterator_category" ) and
5772 not this .hasQualifiedName ( [ "std" , "bsl" ] , "iterator_traits" )
5873 }
74+
75+ override Type getValueType ( ) { result = valueType .getUnderlyingType ( ) }
5976}
6077
6178/**
6279 * The `std::iterator` class.
6380 */
6481private class StdIterator extends Iterator , Class {
6582 StdIterator ( ) { this .hasQualifiedName ( [ "std" , "bsl" ] , "iterator" ) }
83+
84+ override Type getValueType ( ) { result = this .getTemplateArgument ( 1 ) .( Type ) .getUnderlyingType ( ) }
6685}
6786
6887/**
@@ -166,12 +185,15 @@ private class IteratorSubOperator extends Operator, TaintFunction {
166185/**
167186 * A non-member `operator+=` or `operator-=` function for an iterator type.
168187 */
169- private class IteratorAssignArithmeticOperator extends Operator , DataFlowFunction , TaintFunction {
188+ class IteratorAssignArithmeticOperator extends Operator {
170189 IteratorAssignArithmeticOperator ( ) {
171190 this .hasName ( [ "operator+=" , "operator-=" ] ) and
172191 exists ( getIteratorArgumentInput ( this , 0 ) )
173192 }
193+ }
174194
195+ private class IteratorAssignArithmeticOperatorModel extends IteratorAssignArithmeticOperator ,
196+ DataFlowFunction , TaintFunction {
175197 override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
176198 input .isParameter ( 0 ) and
177199 output .isReturnValue ( )
@@ -210,11 +232,14 @@ class IteratorPointerDereferenceMemberOperator extends MemberFunction, TaintFunc
210232/**
211233 * An `operator++` or `operator--` member function for an iterator type.
212234 */
213- private class IteratorCrementMemberOperator extends MemberFunction , DataFlowFunction , TaintFunction {
235+ class IteratorCrementMemberOperator extends MemberFunction {
214236 IteratorCrementMemberOperator ( ) {
215237 this .getClassAndName ( [ "operator++" , "operator--" ] ) instanceof Iterator
216238 }
239+ }
217240
241+ private class IteratorCrementMemberOperatorModel extends IteratorCrementMemberOperator ,
242+ DataFlowFunction , TaintFunction {
218243 override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
219244 input .isQualifierAddress ( ) and
220245 output .isReturnValue ( )
0 commit comments