Skip to content

Commit 3efe60f

Browse files
committed
C++: Accept test changes.
1 parent 5dbaea8 commit 3efe60f

31 files changed

+3665
-884
lines changed

cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/annotate_sinks_only/defaulttainttracking.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ void test_pointers2()
210210

211211
sink(buffer); // $ MISSING: ast,ir
212212
sink(ptr1); // $ ast MISSING: ir
213-
sink(ptr2); // $ SPURIOUS: ast
214-
sink(*ptr2); // $ ast MISSING: ir
213+
sink(ptr2); // $ SPURIOUS: ast,ir
214+
sink(*ptr2); // $ ast,ir
215215
sink(ptr3); // $ MISSING: ast,ir
216216
sink(ptr4); // clean
217217
sink(*ptr4); // $ MISSING: ast,ir
@@ -254,8 +254,8 @@ int test_readv_and_writev(iovec* iovs) {
254254
sink(*iovs); // $ast,ir
255255

256256
char* p = (char*)iovs[1].iov_base;
257-
sink(p); // $ ir MISSING: ast
258-
sink(*p); // $ ir MISSING: ast
257+
sink(p); // $ MISSING: ast,ir
258+
sink(*p); // $ MISSING: ast,ir
259259

260260
writev(0, iovs, 16); // $ remote
261261
}

cpp/ql/test/library-tests/dataflow/DefaultTaintTracking/annotate_sinks_only/stl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ void test_stringstream()
8989

9090
sink(ss1);
9191
sink(ss2); // $ ir MISSING: ast
92-
sink(ss3); // $ MISSING: ast,ir
92+
sink(ss3); // $ ir MISSING: ast
9393
sink(ss4); // $ ir MISSING: ast
9494
sink(ss5); // $ ir MISSING: ast
9595
sink(ss1.str());
9696
sink(ss2.str()); // $ ir MISSING: ast
97-
sink(ss3.str()); // $ MISSING: ast,ir
97+
sink(ss3.str()); // $ ir MISSING: ast
9898
sink(ss4.str()); // $ ir MISSING: ast
9999
sink(ss5.str()); // $ ir MISSING: ast
100100
}

cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-ir-consistency.expected

Lines changed: 581 additions & 54 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void test_lambdas()
1818
sink(a()); // $ ast,ir
1919

2020
auto b = [&] {
21-
sink(t); // $ ast MISSING: ir
21+
sink(t); // $ ast,ir
2222
sink(u);
2323
v = source(); // (v is reference captured)
2424
};

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ void local_references(int &source1, int clean1) {
100100
int t = source();
101101
int &ref = t;
102102
t = clean1;
103-
sink(ref); // $ SPURIOUS: ast
103+
sink(ref); // $ SPURIOUS: ast,ir
104104
}
105105

106106
{
107107
int t = clean1;
108108
int &ref = t;
109109
t = source();
110-
sink(ref); // $ ir MISSING: ast
110+
sink(ref); // $ MISSING: ast,ir
111111
}
112112
}
113113

@@ -346,7 +346,7 @@ namespace FlowThroughGlobals {
346346
int taintAndCall() {
347347
globalVar = source();
348348
calledAfterTaint();
349-
sink(globalVar); // $ ast MISSING: ir
349+
sink(globalVar); // $ ast,ir
350350
}
351351
}
352352

@@ -355,21 +355,21 @@ namespace FlowThroughGlobals {
355355
class FlowThroughFields {
356356
int field = 0;
357357

358-
int taintField() {
358+
void taintField() {
359359
field = source();
360360
}
361361

362-
int f() {
362+
void f() {
363363
sink(field); // tainted or clean? Not sure.
364364
taintField();
365-
sink(field); // $ ast MISSING: ir
365+
sink(field); // $ ast,ir
366366
}
367367

368-
int calledAfterTaint() {
368+
void calledAfterTaint() {
369369
sink(field); // $ ast,ir
370370
}
371371

372-
int taintAndCall() {
372+
void taintAndCall() {
373373
field = source();
374374
calledAfterTaint();
375375
sink(field); // $ ast,ir

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class A
5454
B *b = new B();
5555
b->set(new C1());
5656
sink(b->get()); // $ ast ir=55:12
57-
sink((new B(new C()))->get()); // $ ast ir
57+
sink((new B(new C()))->get()); // $ ast MISSING: 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 MISSING: ir
66+
sink(b2->c); // $ ast ir=64:21
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 MISSING: ir
75+
sink(b2->c); // $ ast ir=73:25
7676
}
7777

7878
B *setOnBWrap(B *b1, C *c)
@@ -117,7 +117,7 @@ class A
117117
}
118118
if (C1 *c1 = dynamic_cast<C1 *>(cc))
119119
{
120-
sink(c1->a); // $ SPURIOUS: ast
120+
sink(c1->a); // $ SPURIOUS: ast,ir
121121
}
122122
}
123123

@@ -149,7 +149,7 @@ 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
152+
sink(d->b); // $ ast MISSING: ir
153153
sink(d->b->c); // $ ast MISSING: ir
154154
sink(b->c); // $ ast,ir
155155
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

2+
void sink(...);
23
class C
34
{
45
class Elem
56
{
67
};
7-
88
private:
99
Elem *s1 = new Elem();
1010
const Elem *s2 = new Elem();
@@ -26,12 +26,10 @@ class C
2626

2727
void func()
2828
{
29-
sink(s1); // $ast ir
29+
sink(s1); // $ast MISSING: ir
3030
sink(s2); // $ MISSING: ast,ir
31-
sink(s3); // $ast ir
31+
sink(s3); // $ast MISSING: ir
3232
sink(s4); // $ MISSING: ast,ir
3333
}
34-
35-
static void sink(const void *o) {}
3634
};
3735
const C::Elem *C::s4 = new Elem();

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 MISSING: ir
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;
@@ -61,6 +61,6 @@ class D {
6161

6262
private:
6363
void f5b() {
64-
sink(boxfield->box->elem); // $ ast MISSING: ir
64+
sink(boxfield->box->elem); // $ ast,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 MISSING: ir
21+
sink(p->data.buffer); // $ ast,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 MISSING: ir
32-
sink(b->buffer); // $ ast MISSING: ir
31+
sink(raw); // $ ast,ir
32+
sink(b->buffer); // $ ast,ir
3333
handlePacket(&p);
3434
}

cpp/ql/test/library-tests/dataflow/fields/IRConfiguration.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class IRConf extends Configuration {
1818
override predicate isSink(Node sink) {
1919
exists(Call c |
2020
c.getTarget().hasName("sink") and
21-
c.getAnArgument() = sink.asConvertedExpr()
21+
c.getAnArgument() = [sink.asExpr(), sink.asConvertedExpr()]
2222
)
2323
}
2424

0 commit comments

Comments
 (0)