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

Skip to content

Commit 4be02a9

Browse files
committed
C++: Use new syntax in field-flow tests
1 parent 176522d commit 4be02a9

14 files changed

Lines changed: 92 additions & 92 deletions

File tree

cpp/ql/test/library-tests/dataflow/fields/A.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ class A
4040
cc.insert(nullptr);
4141
ct.insert(new C());
4242
sink(&cc); // no flow
43-
sink(&ct); // $ast $f-:ir
43+
sink(&ct); // $ ast MISSING: ir
4444
}
4545
void f1()
4646
{
4747
C *c = new C();
4848
B *b = B::make(c);
49-
sink(b->c); // $ast $f-:ir
49+
sink(b->c); // $ast MISSING: ir
5050
}
5151

5252
void f2()
5353
{
5454
B *b = new B();
5555
b->set(new C1());
56-
sink(b->get()); // $ast $ir=55:12
57-
sink((new B(new C()))->get()); // $ast $ir
56+
sink(b->get()); // $ ast ir=55:12
57+
sink((new B(new C()))->get()); // $ ast ir
5858
}
5959

6060
void f3()
@@ -63,7 +63,7 @@ class A
6363
B *b2;
6464
b2 = setOnB(b1, new C2());
6565
sink(b1->c); // no flow
66-
sink(b2->c); // $ast $f-:ir
66+
sink(b2->c); // $ ast MISSING: ir
6767
}
6868

6969
void f4()
@@ -72,7 +72,7 @@ class A
7272
B *b2;
7373
b2 = setOnBWrap(b1, new C2());
7474
sink(b1->c); // no flow
75-
sink(b2->c); // $ast $f-:ir
75+
sink(b2->c); // $ ast MISSING: ir
7676
}
7777

7878
B *setOnBWrap(B *b1, C *c)
@@ -104,7 +104,7 @@ class A
104104
{
105105
if (C1 *c1 = dynamic_cast<C1 *>(c))
106106
{
107-
sink(c1->a); // $ast,ir
107+
sink(c1->a); // $ ast,ir
108108
}
109109
C *cc;
110110
if (C2 *c2 = dynamic_cast<C2 *>(c))
@@ -117,7 +117,7 @@ class A
117117
}
118118
if (C1 *c1 = dynamic_cast<C1 *>(cc))
119119
{
120-
sink(c1->a); //$f+:ast
120+
sink(c1->a); // $ SPURIOUS: ast
121121
}
122122
}
123123

@@ -129,7 +129,7 @@ class A
129129
{
130130
B *b = new B();
131131
f7(b);
132-
sink(b->c); // $ast,ir
132+
sink(b->c); // $ ast,ir
133133
}
134134

135135
class D
@@ -149,9 +149,9 @@ class A
149149
{
150150
B *b = new B();
151151
D *d = new D(b, r());
152-
sink(d->b); // $ast,ir=143:25 $ast,ir=150:12
153-
sink(d->b->c); // $ast $f-:ir
154-
sink(b->c); // $ast,ir
152+
sink(d->b); // $ ast,ir=143:25 ast,ir=150:12
153+
sink(d->b->c); // $ ast MISSING: ir
154+
sink(b->c); // $ ast,ir
155155
}
156156

157157
void f10()
@@ -162,11 +162,11 @@ class A
162162
MyList *l3 = new MyList(nullptr, l2);
163163
sink(l3->head); // no flow, b is nested beneath at least one ->next
164164
sink(l3->next->head); // no flow
165-
sink(l3->next->next->head); // $ast $f-:ir
165+
sink(l3->next->next->head); // $ ast MISSING: ir
166166
sink(l3->next->next->next->head); // no flow
167167
for (MyList *l = l3; l != nullptr; l = l->next)
168168
{
169-
sink(l->head); // $ast $f-:ir
169+
sink(l->head); // $ ast MISSING: ir
170170
}
171171
}
172172

cpp/ql/test/library-tests/dataflow/fields/B.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class B
66
Elem *e = new Elem();
77
Box1 *b1 = new Box1(e, nullptr);
88
Box2 *b2 = new Box2(b1);
9-
sink(b2->box1->elem1); // $ast $f-:ir
9+
sink(b2->box1->elem1); // $ ast MISSING: ir
1010
sink(b2->box1->elem2); // no flow
1111
}
1212

@@ -16,7 +16,7 @@ class B
1616
Box1 *b1 = new B::Box1(nullptr, e);
1717
Box2 *b2 = new Box2(b1);
1818
sink(b2->box1->elem1); // no flow
19-
sink(b2->box1->elem2); // $ast $f-:ir
19+
sink(b2->box1->elem2); // $ ast MISSING: ir
2020
}
2121

2222
static void sink(void *o) {}

cpp/ql/test/library-tests/dataflow/fields/C.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class C
2626

2727
void func()
2828
{
29-
sink(s1); // $ast $ir
30-
sink(s2); // $f-:ast $f-:ir
31-
sink(s3); // $ast $ir
32-
sink(s4); // $f-:ast $f-:ir
29+
sink(s1); // $ast ir
30+
sink(s2); // $ MISSING: ast,ir
31+
sink(s3); // $ast ir
32+
sink(s4); // $ MISSING: ast,ir
3333
}
3434

3535
static void sink(const void *o) {}

cpp/ql/test/library-tests/dataflow/fields/D.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class D {
1919
};
2020

2121
static void sinkWrap(Box2* b2) {
22-
sink(b2->getBox1()->getElem()); // $ast=28:15 $ast=35:15 $ast=42:15 $ast=49:15 $f-:ir
22+
sink(b2->getBox1()->getElem()); // $ast=28:15 ast=35:15 ast=42:15 ast=49:15 MISSING: ir
2323
}
2424

2525
Box2* boxfield;
@@ -61,6 +61,6 @@ class D {
6161

6262
private:
6363
void f5b() {
64-
sink(boxfield->box->elem); // $ast $f-:ir
64+
sink(boxfield->box->elem); // $ ast MISSING: ir
6565
}
6666
};

cpp/ql/test/library-tests/dataflow/fields/E.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void sink(char *b);
1818

1919
void handlePacket(packet *p)
2020
{
21-
sink(p->data.buffer); // $ast $f-:ir
21+
sink(p->data.buffer); // $ ast MISSING: ir
2222
}
2323

2424
void f(buf* b)
@@ -28,7 +28,7 @@ void f(buf* b)
2828
argument_source(raw);
2929
argument_source(b->buffer);
3030
argument_source(p.data.buffer);
31-
sink(raw); // $ast $f-:ir
32-
sink(b->buffer); // $ast $f-:ir
31+
sink(raw); // $ ast MISSING: ir
32+
sink(b->buffer); // $ ast MISSING: ir
3333
handlePacket(&p);
3434
}

cpp/ql/test/library-tests/dataflow/fields/aliasing.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ void callSetters() {
2626
referenceSetter(s2);
2727
copySetter(s3);
2828

29-
sink(s1.m1); // $ast,ir
30-
sink(s2.m1); // $ast,ir
29+
sink(s1.m1); // $ ast,ir
30+
sink(s2.m1); // $ ast,ir
3131
sink(s3.m1); // no flow
3232
}
3333

3434
void assignAfterAlias() {
3535
S s1 = { 0, 0 };
3636
S &ref1 = s1;
3737
ref1.m1 = user_input();
38-
sink(s1.m1); // $f-:ast $ir
38+
sink(s1.m1); // $ ir MISSING: ast
3939

4040
S s2 = { 0, 0 };
4141
S &ref2 = s2;
4242
s2.m1 = user_input();
43-
sink(ref2.m1); // $f-:ast $ir
43+
sink(ref2.m1); // $ ir MISSING: ast
4444
}
4545

4646
void assignAfterCopy() {
@@ -59,7 +59,7 @@ void assignBeforeCopy() {
5959
S s2 = { 0, 0 };
6060
s2.m1 = user_input();
6161
S copy2 = s2;
62-
sink(copy2.m1); // $ast,ir
62+
sink(copy2.m1); // $ ast,ir
6363
}
6464

6565
struct Wrapper {
@@ -77,20 +77,20 @@ void pointerIntermediate() {
7777
Wrapper w = { { 0, 0 } };
7878
S *s = &w.s;
7979
s->m1 = user_input();
80-
sink(w.s.m1); // $f-:ast $ir
80+
sink(w.s.m1); // $ ir MISSING: ast
8181
}
8282

8383
void referenceIntermediate() {
8484
Wrapper w = { { 0, 0 } };
8585
S &s = w.s;
8686
s.m1 = user_input();
87-
sink(w.s.m1); // $f-:ast $ir
87+
sink(w.s.m1); // $ ir MISSING: ast
8888
}
8989

9090
void nestedAssign() {
9191
Wrapper w = { { 0, 0 } };
9292
w.s.m1 = user_input();
93-
sink(w.s.m1); // $ast,ir
93+
sink(w.s.m1); // $ ast,ir
9494
}
9595

9696
void addressOfField() {
@@ -99,7 +99,7 @@ void addressOfField() {
9999

100100
S s_copy = s;
101101
int* px = &s_copy.m1;
102-
sink(*px); // $f-:ast $ir
102+
sink(*px); // $ ir MISSING: ast
103103
}
104104

105105
void taint_a_ptr(int* pa) {
@@ -119,28 +119,28 @@ struct S_with_pointer {
119119

120120
void pointer_deref(int* xs) {
121121
taint_a_ptr(xs);
122-
sink(xs[0]); // $f-:ast $ir
122+
sink(xs[0]); // $ ir MISSING: ast
123123
}
124124

125125
void pointer_deref_sub(int* xs) {
126126
taint_a_ptr(xs - 2);
127-
sink(*(xs - 2)); // $f-:ast $ir
127+
sink(*(xs - 2)); // $ ir MISSING: ast
128128
}
129129

130130
void pointer_many_addrof_and_deref(int* xs) {
131131
taint_a_ptr(xs);
132-
sink(*&*&*xs); // $f-:ast $ir
132+
sink(*&*&*xs); // $ ir MISSING: ast
133133
}
134134

135135
void pointer_unary_plus(int* xs) {
136136
taint_a_ptr(+xs);
137-
sink(*+xs); // $f-:ast $ir
137+
sink(*+xs); // $ ir MISSING: ast
138138
}
139139

140140
void pointer_member_index(S_with_pointer s) {
141141
taint_a_ptr(s.data);
142142
// `s.data` is points to all-aliased-memory
143-
sink(s.data[0]); // $f-:ast,ir
143+
sink(s.data[0]); // $ MISSING: ir,ast
144144
}
145145

146146
void member_array_different_field(S_with_pointer* s) {
@@ -156,13 +156,13 @@ struct S_with_array {
156156
void pointer_member_deref() {
157157
S_with_array s;
158158
taint_a_ptr(s.data);
159-
sink(*s.data); // $ir,ast
159+
sink(*s.data); // $ ir,ast
160160
}
161161

162162
void array_member_deref() {
163163
S_with_array s;
164164
taint_a_ptr(s.data);
165-
sink(s.data[0]); // $ir,ast
165+
sink(s.data[0]); // $ ir,ast
166166
}
167167

168168
struct S2 {
@@ -173,7 +173,7 @@ struct S2 {
173173
void deep_member_field_dot() {
174174
S2 s2;
175175
taint_a_ptr(&s2.s.m1);
176-
sink(s2.s.m1); // $ir,ast
176+
sink(s2.s.m1); // $ ir,ast
177177
}
178178

179179
void deep_member_field_dot_different_fields() {
@@ -186,7 +186,7 @@ void deep_member_field_dot_2() {
186186
S2 s2;
187187
taint_a_ptr(&s2.s.m1);
188188
S2 s2_2 = s2;
189-
sink(s2_2.s.m1); // $ir,ast
189+
sink(s2_2.s.m1); // $ ir,ast
190190
}
191191

192192
void deep_member_field_dot_different_fields_2() {
@@ -198,7 +198,7 @@ void deep_member_field_dot_different_fields_2() {
198198

199199
void deep_member_field_arrow(S2 *ps2) {
200200
taint_a_ptr(&ps2->s.m1);
201-
sink(ps2->s.m1); // $ir,ast
201+
sink(ps2->s.m1); // $ ir,ast
202202
}
203203

204204
void deep_member_field_arrow_different_fields(S2 *ps2) {

cpp/ql/test/library-tests/dataflow/fields/arrays.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ void *user_input(void);
44
void local_array() {
55
void *arr[10] = { 0 };
66
arr[0] = user_input();
7-
sink(arr[0]); // $ast,ir
8-
sink(arr[1]); // $f+:ast
9-
sink(*arr); // $ast,ir
10-
sink(*&arr[0]); // $ast,ir
7+
sink(arr[0]); // $ ast,ir
8+
sink(arr[1]); // $ SPURIOUS: ast
9+
sink(*arr); // $ ast,ir
10+
sink(*&arr[0]); // $ ast,ir
1111
}
1212

1313
void local_array_convoluted_assign() {
1414
void *arr[10] = { 0 };
1515
*&arr[0] = user_input();
16-
sink(arr[0]); // $ast,ir
17-
sink(arr[1]); // $f+:ast
16+
sink(arr[0]); // $ ast,ir
17+
sink(arr[1]); // $ SPURIOUS: ast
1818
}
1919

2020
struct inner {
@@ -34,18 +34,18 @@ struct outer {
3434

3535
void nested_array_1(outer o) {
3636
o.nested.arr[1].data = user_input();
37-
sink(o.nested.arr[1].data); // $ast,ir
38-
sink(o.nested.arr[0].data); // $f+:ast
37+
sink(o.nested.arr[1].data); // $ ast,ir
38+
sink(o.nested.arr[0].data); // $ SPURIOUS: ast
3939
}
4040

4141
void nested_array_2(outer o) {
4242
o.indirect->arr[1].data = user_input();
43-
sink(o.indirect->arr[1].data); // $ast $f-:ir
44-
sink(o.indirect->arr[0].data); // $f+:ast
43+
sink(o.indirect->arr[1].data); // $ ast MISSING: ir
44+
sink(o.indirect->arr[0].data); // $ SPURIOUS: ast
4545
}
4646

4747
void nested_array_3(outer o) {
4848
o.indirect->ptr[1].data = user_input();
49-
sink(o.indirect->ptr[1].data); // $f-:ast,ir
49+
sink(o.indirect->ptr[1].data); // $ MISSING: ir,ast
5050
sink(o.indirect->ptr[0].data);
5151
}

0 commit comments

Comments
 (0)