Skip to content

Commit fade75b

Browse files
author
Robert Marsh
committed
C++: add operator-- tests for insert iterators
1 parent 126615a commit fade75b

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,6 +3147,28 @@
31473147
| standalone_iterators.cpp:51:37:51:43 | source1 | standalone_iterators.cpp:53:12:53:18 | source1 | |
31483148
| standalone_iterators.cpp:51:37:51:43 | source1 | standalone_iterators.cpp:54:14:54:20 | source1 | |
31493149
| standalone_iterators.cpp:53:12:53:18 | ref arg source1 | standalone_iterators.cpp:54:14:54:20 | source1 | |
3150+
| standalone_iterators.cpp:83:15:83:16 | call to container | standalone_iterators.cpp:85:35:85:36 | c1 | |
3151+
| standalone_iterators.cpp:83:15:83:16 | call to container | standalone_iterators.cpp:87:10:87:11 | c1 | |
3152+
| standalone_iterators.cpp:83:19:83:20 | call to container | standalone_iterators.cpp:89:35:89:36 | c2 | |
3153+
| standalone_iterators.cpp:83:19:83:20 | call to container | standalone_iterators.cpp:91:10:91:11 | c2 | |
3154+
| standalone_iterators.cpp:85:35:85:36 | c1 | standalone_iterators.cpp:85:38:85:42 | call to begin | TAINT |
3155+
| standalone_iterators.cpp:85:35:85:36 | ref arg c1 | standalone_iterators.cpp:87:10:87:11 | c1 | |
3156+
| standalone_iterators.cpp:85:38:85:42 | call to begin | standalone_iterators.cpp:86:6:86:7 | i1 | |
3157+
| standalone_iterators.cpp:86:5:86:5 | ref arg call to operator* | standalone_iterators.cpp:86:8:86:8 | ref arg call to operator-- | TAINT |
3158+
| standalone_iterators.cpp:86:5:86:5 | ref arg call to operator* | standalone_iterators.cpp:87:10:87:11 | c1 | |
3159+
| standalone_iterators.cpp:86:6:86:7 | i1 | standalone_iterators.cpp:86:8:86:8 | call to operator-- | |
3160+
| standalone_iterators.cpp:86:8:86:8 | call to operator-- | standalone_iterators.cpp:86:5:86:5 | call to operator* | TAINT |
3161+
| standalone_iterators.cpp:86:8:86:8 | ref arg call to operator-- | standalone_iterators.cpp:86:6:86:7 | ref arg i1 | |
3162+
| standalone_iterators.cpp:86:13:86:18 | call to source | standalone_iterators.cpp:86:5:86:5 | ref arg call to operator* | TAINT |
3163+
| standalone_iterators.cpp:89:35:89:36 | c2 | standalone_iterators.cpp:89:38:89:42 | call to begin | TAINT |
3164+
| standalone_iterators.cpp:89:35:89:36 | ref arg c2 | standalone_iterators.cpp:91:10:91:11 | c2 | |
3165+
| standalone_iterators.cpp:89:38:89:42 | call to begin | standalone_iterators.cpp:90:6:90:7 | i2 | |
3166+
| standalone_iterators.cpp:90:5:90:5 | ref arg call to operator* | standalone_iterators.cpp:90:8:90:8 | ref arg call to operator-- | TAINT |
3167+
| standalone_iterators.cpp:90:5:90:5 | ref arg call to operator* | standalone_iterators.cpp:91:10:91:11 | c2 | |
3168+
| standalone_iterators.cpp:90:6:90:7 | i2 | standalone_iterators.cpp:90:8:90:8 | call to operator-- | |
3169+
| standalone_iterators.cpp:90:8:90:8 | call to operator-- | standalone_iterators.cpp:90:5:90:5 | call to operator* | TAINT |
3170+
| standalone_iterators.cpp:90:8:90:8 | ref arg call to operator-- | standalone_iterators.cpp:90:6:90:7 | ref arg i2 | |
3171+
| standalone_iterators.cpp:90:13:90:13 | 0 | standalone_iterators.cpp:90:5:90:5 | ref arg call to operator* | TAINT |
31503172
| stl.h:75:8:75:8 | Unknown literal | stl.h:75:8:75:8 | constructor init of field container | TAINT |
31513173
| stl.h:75:8:75:8 | Unknown literal | stl.h:75:8:75:8 | constructor init of field container | TAINT |
31523174
| stl.h:75:8:75:8 | this | stl.h:75:8:75:8 | constructor init of field container [pre-this] | |

cpp/ql/test/library-tests/dataflow/taint-tests/standalone_iterators.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,40 @@ void test_non_iterator(non_iterator source1) {
5353
sink(*(source1++));
5454
sink(*(++source1));
5555
}
56+
57+
int source();
58+
59+
class insert_iterator_by_trait {
60+
public:
61+
insert_iterator_by_trait &operator++();
62+
insert_iterator_by_trait operator++(int);
63+
insert_iterator_by_trait &operator--();
64+
insert_iterator_by_trait operator--(int);
65+
insert_iterator_by_trait operator*();
66+
insert_iterator_by_trait operator=(int x);
67+
};
68+
69+
template<>
70+
struct std::iterator_traits<insert_iterator_by_trait> {
71+
typedef output_iterator_tag iterator_category;
72+
};
73+
74+
class container {
75+
public:
76+
container();
77+
insert_iterator_by_trait begin();
78+
};
79+
80+
void sink(container);
81+
82+
void test_insert_iterator() {
83+
container c1, c2;
84+
85+
insert_iterator_by_trait i1 = c1.begin();
86+
*i1-- = source();
87+
sink(c1);
88+
89+
insert_iterator_by_trait i2 = c2.begin();
90+
*i2-- = 0;
91+
sink(c2);
92+
}

cpp/ql/test/library-tests/dataflow/taint-tests/taint.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@
258258
| standalone_iterators.cpp:46:10:46:10 | call to operator* | standalone_iterators.cpp:45:39:45:45 | source1 |
259259
| standalone_iterators.cpp:47:10:47:10 | call to operator* | standalone_iterators.cpp:45:39:45:45 | source1 |
260260
| standalone_iterators.cpp:48:10:48:10 | call to operator* | standalone_iterators.cpp:45:39:45:45 | source1 |
261+
| standalone_iterators.cpp:87:10:87:11 | c1 | standalone_iterators.cpp:86:13:86:18 | call to source |
261262
| string.cpp:29:7:29:7 | a | string.cpp:25:12:25:17 | call to source |
262263
| string.cpp:31:7:31:7 | c | string.cpp:27:16:27:21 | call to source |
263264
| string.cpp:33:9:33:13 | call to c_str | string.cpp:27:16:27:21 | call to source |

cpp/ql/test/library-tests/dataflow/taint-tests/test_diff.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
| standalone_iterators.cpp:42:10:42:10 | standalone_iterators.cpp:39:45:39:51 | AST only |
205205
| standalone_iterators.cpp:47:10:47:10 | standalone_iterators.cpp:45:39:45:45 | AST only |
206206
| standalone_iterators.cpp:48:10:48:10 | standalone_iterators.cpp:45:39:45:45 | AST only |
207+
| standalone_iterators.cpp:87:10:87:11 | standalone_iterators.cpp:86:13:86:18 | AST only |
207208
| string.cpp:33:9:33:13 | string.cpp:27:16:27:21 | AST only |
208209
| string.cpp:39:13:39:17 | string.cpp:14:10:14:15 | AST only |
209210
| string.cpp:43:13:43:17 | string.cpp:14:10:14:15 | AST only |

0 commit comments

Comments
 (0)