@@ -31,7 +31,17 @@ private class IteratorTraits extends Class {
31
31
* `std::iterator_traits` instantiation for it.
32
32
*/
33
33
private 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
+ }
35
45
}
36
46
37
47
/**
@@ -42,27 +52,36 @@ private class IteratorByTraits extends Iterator {
42
52
*/
43
53
private class IteratorByPointer extends Iterator instanceof PointerType {
44
54
IteratorByPointer ( ) { not this instanceof IteratorByTraits }
55
+
56
+ override Type getValueType ( ) { result = super .getBaseType ( ) }
45
57
}
46
58
47
59
/**
48
60
* A type which has the typedefs expected for an iterator.
49
61
*/
50
62
private class IteratorByTypedefs extends Iterator , Class {
63
+ TypedefType valueType ;
64
+
51
65
IteratorByTypedefs ( ) {
52
66
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
54
69
this .getAMember ( ) .( TypedefType ) .hasName ( "pointer" ) and
55
70
this .getAMember ( ) .( TypedefType ) .hasName ( "reference" ) and
56
71
this .getAMember ( ) .( TypedefType ) .hasName ( "iterator_category" ) and
57
72
not this .hasQualifiedName ( [ "std" , "bsl" ] , "iterator_traits" )
58
73
}
74
+
75
+ override Type getValueType ( ) { result = valueType .getUnderlyingType ( ) }
59
76
}
60
77
61
78
/**
62
79
* The `std::iterator` class.
63
80
*/
64
81
private class StdIterator extends Iterator , Class {
65
82
StdIterator ( ) { this .hasQualifiedName ( [ "std" , "bsl" ] , "iterator" ) }
83
+
84
+ override Type getValueType ( ) { result = this .getTemplateArgument ( 1 ) .( Type ) .getUnderlyingType ( ) }
66
85
}
67
86
68
87
/**
@@ -166,12 +185,15 @@ private class IteratorSubOperator extends Operator, TaintFunction {
166
185
/**
167
186
* A non-member `operator+=` or `operator-=` function for an iterator type.
168
187
*/
169
- private class IteratorAssignArithmeticOperator extends Operator , DataFlowFunction , TaintFunction {
188
+ class IteratorAssignArithmeticOperator extends Operator {
170
189
IteratorAssignArithmeticOperator ( ) {
171
190
this .hasName ( [ "operator+=" , "operator-=" ] ) and
172
191
exists ( getIteratorArgumentInput ( this , 0 ) )
173
192
}
193
+ }
174
194
195
+ private class IteratorAssignArithmeticOperatorModel extends IteratorAssignArithmeticOperator ,
196
+ DataFlowFunction , TaintFunction {
175
197
override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
176
198
input .isParameter ( 0 ) and
177
199
output .isReturnValue ( )
@@ -210,11 +232,14 @@ class IteratorPointerDereferenceMemberOperator extends MemberFunction, TaintFunc
210
232
/**
211
233
* An `operator++` or `operator--` member function for an iterator type.
212
234
*/
213
- private class IteratorCrementMemberOperator extends MemberFunction , DataFlowFunction , TaintFunction {
235
+ class IteratorCrementMemberOperator extends MemberFunction {
214
236
IteratorCrementMemberOperator ( ) {
215
237
this .getClassAndName ( [ "operator++" , "operator--" ] ) instanceof Iterator
216
238
}
239
+ }
217
240
241
+ private class IteratorCrementMemberOperatorModel extends IteratorCrementMemberOperator ,
242
+ DataFlowFunction , TaintFunction {
218
243
override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
219
244
input .isQualifierAddress ( ) and
220
245
output .isReturnValue ( )
0 commit comments