Skip to content

Commit 926725a

Browse files
authored
Merge pull request #21405 from owen-mc/java/consistent-inline-expectation-tests
Inline expectation tests should always have space before and after `$`
2 parents b5bf1c5 + c82f756 commit 926725a

File tree

297 files changed

+5493
-5461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

297 files changed

+5493
-5461
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Inline expectations test comments, which are of the form `// $ tag` or `// $ tag=value`, are now parsed more strictly and will not be recognized if there isn't a space after the `$` symbol.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class A
4646
{
4747
C *c = new C();
4848
B *b = B::make(c);
49-
sink(b->c); // $ast,ir
49+
sink(b->c); // $ ast,ir
5050
}
5151

5252
void f2()

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

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

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

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

Lines changed: 1 addition & 1 deletion
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,ir=28:15 ast,ir=35:15 ast,ir=42:15 ast,ir=49:15
22+
sink(b2->getBox1()->getElem()); // $ ast,ir=28:15 ast,ir=35:15 ast,ir=42:15 ast,ir=49:15
2323
}
2424

2525
Box2* boxfield;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,25 @@ struct S {
4848
void test_setDirectly() {
4949
S s;
5050
s.setDirectly(user_input());
51-
sink(s.getDirectly()); // $ast ir
51+
sink(s.getDirectly()); // $ ast ir
5252
}
5353

5454
void test_setIndirectly() {
5555
S s;
5656
s.setIndirectly(user_input());
57-
sink(s.getIndirectly()); // $ast ir
57+
sink(s.getIndirectly()); // $ ast ir
5858
}
5959

6060
void test_setThroughNonMember() {
6161
S s;
6262
s.setThroughNonMember(user_input());
63-
sink(s.getThroughNonMember()); // $ast ir
63+
sink(s.getThroughNonMember()); // $ ast ir
6464
}
6565

6666
void test_nonMemberSetA() {
6767
S s;
6868
nonMemberSetA(&s, user_input());
69-
sink(nonMemberGetA(&s)); // $ast,ir
69+
sink(nonMemberGetA(&s)); // $ ast,ir
7070
}
7171

7272
////////////////////
@@ -112,7 +112,7 @@ void test_outer_with_ptr(Outer *pouter) {
112112
sink(outer.a); // $ ast,ir
113113

114114
sink(pouter->inner_nested.a); // $ ast,ir
115-
sink(pouter->inner_ptr->a); // $ast,ir
115+
sink(pouter->inner_ptr->a); // $ ast,ir
116116
sink(pouter->a); // $ ast,ir
117117
}
118118

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void single_field_test()
6464
A a;
6565
a.i = user_input();
6666
A a2 = a;
67-
sink(a2.i); //$ ast,ir
67+
sink(a2.i); // $ ast,ir
6868
}
6969

7070
struct C {
@@ -81,7 +81,7 @@ struct C2
8181

8282
void m() {
8383
f2.f1 = user_input();
84-
sink(getf2f1()); //$ ast,ir
84+
sink(getf2f1()); // $ ast,ir
8585
}
8686
};
8787

@@ -91,7 +91,7 @@ void single_field_test_typedef(A_typedef a)
9191
{
9292
a.i = user_input();
9393
A_typedef a2 = a;
94-
sink(a2.i); //$ ast,ir
94+
sink(a2.i); // $ ast,ir
9595
}
9696

9797
namespace TestAdditionalCallTargets {
@@ -168,4 +168,4 @@ void test_union_with_two_instantiations_of_different_sizes() {
168168
sink(u_int.y); // $ MISSING: ir
169169
}
170170

171-
} // namespace Simple
171+
} // namespace Simple

cpp/ql/test/library-tests/dataflow/fields/struct_init.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ struct Outer {
1212
};
1313

1414
void absink(struct AB *ab) {
15-
sink(ab->a); //$ ast,ir=20:20 ast,ir=27:7 ast,ir=40:20
15+
sink(ab->a); // $ ast,ir=20:20 ast,ir=27:7 ast,ir=40:20
1616
sink(ab->b); // no flow
1717
}
1818

1919
int struct_init(void) {
2020
struct AB ab = { user_input(), 0 };
2121

22-
sink(ab.a); //$ ast,ir
22+
sink(ab.a); // $ ast,ir
2323
sink(ab.b); // no flow
2424
absink(&ab);
2525

@@ -28,9 +28,9 @@ int struct_init(void) {
2828
&ab,
2929
};
3030

31-
sink(outer.nestedAB.a); //$ ast,ir
31+
sink(outer.nestedAB.a); // $ ast,ir
3232
sink(outer.nestedAB.b); // no flow
33-
sink(outer.pointerAB->a); //$ ast,ir
33+
sink(outer.pointerAB->a); // $ ast,ir
3434
sink(outer.pointerAB->b); // no flow
3535

3636
absink(&outer.nestedAB);

cpp/ql/test/library-tests/dataflow/models-as-data/tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void test_sources() {
7575
int e = localMadSource();
7676
sink(e); // $ ir
7777

78-
sink(MyNamespace::namespaceLocalMadSource()); // $: ir
78+
sink(MyNamespace::namespaceLocalMadSource()); // $ ir
7979
sink(MyNamespace::namespaceLocalMadSourceVar); // $ ir
8080
sink(MyNamespace::MyNamespace2::namespace2LocalMadSource()); // $ ir
8181
sink(MyNamespace::localMadSource()); // $ (the MyNamespace version of this function is not a source)
@@ -475,4 +475,4 @@ void test_receive_array() {
475475
int array[10] = {x};
476476
int y = receive_array(array);
477477
sink(y); // $ ir
478-
}
478+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ void test_qualifiers()
450450
b.member = source();
451451
sink(b); // $ ir MISSING: ast
452452
sink(b.member); // $ ast,ir
453-
sink(b.getMember()); // $ MISSING: ir ast
453+
sink(b.getMember()); // $ MISSING: ir ast
454454

455455
c = new MyClass2(0);
456456

@@ -865,4 +865,4 @@ void test_iconv(size_t size) {
865865
size_t size_out;
866866
iconv(0, &s, &size, &p, &size_out);
867867
sink(*p); // $ ast,ir
868-
}
868+
}

cpp/ql/test/library-tests/ir/points_to/points_to.cpp

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -24,64 +24,64 @@ struct DerivedVI : virtual Base1 {
2424
};
2525

2626
void Locals() {
27-
Point pt = { //$ussa=pt
28-
1, //$ussa=pt[0..4)<int>
29-
2 //$ussa=pt[4..8)<int>
27+
Point pt = { // $ ussa=pt
28+
1, // $ ussa=pt[0..4)<int>
29+
2 // $ ussa=pt[4..8)<int>
3030
};
31-
int i = pt.x; //$ussa=pt[0..4)<int>
32-
i = pt.y; //$ussa=pt[4..8)<int>
31+
int i = pt.x; // $ ussa=pt[0..4)<int>
32+
i = pt.y; // $ ussa=pt[4..8)<int>
3333
int* p = &pt.x;
34-
i = *p; //$ussa=pt[0..4)<int>
34+
i = *p; // $ ussa=pt[0..4)<int>
3535
p = &pt.y;
36-
i = *p; //$ussa=pt[4..8)<int>
36+
i = *p; // $ ussa=pt[4..8)<int>
3737
}
3838

3939
void PointsTo(
40-
int a, //$raw=a
41-
Point& b, //$raw=b ussa=*b
42-
Point* c, //$raw=c ussa=*c
43-
int* d, //$raw=d ussa=*d
44-
DerivedSI* e, //$raw=e ussa=*e
45-
DerivedMI* f, //$raw=f ussa=*f
46-
DerivedVI* g //$raw=g ussa=*g
40+
int a, // $ raw=a
41+
Point& b, // $ raw=b ussa=*b
42+
Point* c, // $ raw=c ussa=*c
43+
int* d, // $ raw=d ussa=*d
44+
DerivedSI* e, // $ raw=e ussa=*e
45+
DerivedMI* f, // $ raw=f ussa=*f
46+
DerivedVI* g // $ raw=g ussa=*g
4747
) {
4848

49-
int i = a; //$raw=a
50-
i = *&a; //$raw=a
51-
i = *(&a + 0); //$raw=a
52-
i = b.x; //$raw=b ussa=*b[0..4)<int>
53-
i = b.y; //$raw=b ussa=*b[4..8)<int>
54-
i = c->x; //$raw=c ussa=*c[0..4)<int>
55-
i = c->y; //$raw=c ussa=*c[4..8)<int>
56-
i = *d; //$raw=d ussa=*d[0..4)<int>
57-
i = *(d + 0); //$raw=d ussa=*d[0..4)<int>
58-
i = d[5]; //$raw=d ussa=*d[20..24)<int>
59-
i = 5[d]; //$raw=d ussa=*d[20..24)<int>
60-
i = d[a]; //$raw=d raw=a ussa=*d[?..?)<int>
61-
i = a[d]; //$raw=d raw=a ussa=*d[?..?)<int>
49+
int i = a; // $ raw=a
50+
i = *&a; // $ raw=a
51+
i = *(&a + 0); // $ raw=a
52+
i = b.x; // $ raw=b ussa=*b[0..4)<int>
53+
i = b.y; // $ raw=b ussa=*b[4..8)<int>
54+
i = c->x; // $ raw=c ussa=*c[0..4)<int>
55+
i = c->y; // $ raw=c ussa=*c[4..8)<int>
56+
i = *d; // $ raw=d ussa=*d[0..4)<int>
57+
i = *(d + 0); // $ raw=d ussa=*d[0..4)<int>
58+
i = d[5]; // $ raw=d ussa=*d[20..24)<int>
59+
i = 5[d]; // $ raw=d ussa=*d[20..24)<int>
60+
i = d[a]; // $ raw=d raw=a ussa=*d[?..?)<int>
61+
i = a[d]; // $ raw=d raw=a ussa=*d[?..?)<int>
6262

63-
int* p = &b.x; //$raw=b
64-
i = *p; //$ussa=*b[0..4)<int>
65-
p = &b.y; //$raw=b
66-
i = *p; //$ussa=*b[4..8)<int>
67-
p = &c->x; //$raw=c
68-
i = *p; //$ussa=*c[0..4)<int>
69-
p = &c->y; //$raw=c
70-
i = *p; //$ussa=*c[4..8)<int>
71-
p = &d[5]; //$raw=d
72-
i = *p; //$ussa=*d[20..24)<int>
73-
p = &d[a]; //$raw=d raw=a
74-
i = *p; //$ussa=*d[?..?)<int>
63+
int* p = &b.x; // $ raw=b
64+
i = *p; // $ ussa=*b[0..4)<int>
65+
p = &b.y; // $ raw=b
66+
i = *p; // $ ussa=*b[4..8)<int>
67+
p = &c->x; // $ raw=c
68+
i = *p; // $ ussa=*c[0..4)<int>
69+
p = &c->y; // $ raw=c
70+
i = *p; // $ ussa=*c[4..8)<int>
71+
p = &d[5]; // $ raw=d
72+
i = *p; // $ ussa=*d[20..24)<int>
73+
p = &d[a]; // $ raw=d raw=a
74+
i = *p; // $ ussa=*d[?..?)<int>
7575

76-
Point* q = &c[a]; //$raw=c raw=a
77-
i = q->x; //$ussa=*c[?..?)<int>
78-
i = q->y; //$ussa=*c[?..?)<int>
76+
Point* q = &c[a]; // $ raw=c raw=a
77+
i = q->x; // $ ussa=*c[?..?)<int>
78+
i = q->y; // $ ussa=*c[?..?)<int>
7979

80-
i = e->b1; //$raw=e ussa=*e[0..4)<int>
81-
i = e->dsi; //$raw=e ussa=*e[4..8)<int>
82-
i = f->b1; //$raw=f ussa=*f[0..4)<int>
83-
i = f->b2; //$raw=f ussa=*f[4..8)<int>
84-
i = f->dmi; //$raw=f ussa=*f[8..12)<int>
85-
i = g->b1; //$raw=g ussa=*g[?..?)<int>
86-
i = g->dvi; //$raw=g ussa=*g[8..12)<int>
87-
}
80+
i = e->b1; // $ raw=e ussa=*e[0..4)<int>
81+
i = e->dsi; // $ raw=e ussa=*e[4..8)<int>
82+
i = f->b1; // $ raw=f ussa=*f[0..4)<int>
83+
i = f->b2; // $ raw=f ussa=*f[4..8)<int>
84+
i = f->dmi; // $ raw=f ussa=*f[8..12)<int>
85+
i = g->b1; // $ raw=g ussa=*g[?..?)<int>
86+
i = g->dvi; // $ raw=g ussa=*g[8..12)<int>
87+
}

0 commit comments

Comments
 (0)