From ed1e3ed1ef1f1a677897fd4a50a8d03798ddeecf Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Thu, 15 Aug 2019 10:30:46 +0200 Subject: [PATCH] C++: Annotate field-flow tests in [ABC].cpp This brings the annotation style in sync with how we annotate new tests these days. I also changed a few annotations to have different expected outcome based on my understanding of the code. --- cpp/ql/test/library-tests/dataflow/fields/A.cpp | 10 +++++----- cpp/ql/test/library-tests/dataflow/fields/B.cpp | 4 ++-- cpp/ql/test/library-tests/dataflow/fields/C.cpp | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cpp/ql/test/library-tests/dataflow/fields/A.cpp b/cpp/ql/test/library-tests/dataflow/fields/A.cpp index 703d1b9a73f..7668db1fbbc 100644 --- a/cpp/ql/test/library-tests/dataflow/fields/A.cpp +++ b/cpp/ql/test/library-tests/dataflow/fields/A.cpp @@ -117,7 +117,7 @@ public: } if (C1 *c1 = dynamic_cast(cc)) { - sink(c1->a); // no flow, stopped by cast to C2 + sink(c1->a); // no flow, stopped by cast to C2 [FALSE POSITIVE] } } @@ -129,7 +129,7 @@ public: { B *b = new B(); f7(b); - sink(b->c); // flow + sink(b->c); // flow [NOT DETECTED] } class D @@ -151,7 +151,7 @@ public: D *d = new D(b, r()); sink(d->b); // flow x2 sink(d->b->c); // flow - sink(b->c); // flow + sink(b->c); // flow [NOT DETECTED] } void f10() @@ -161,9 +161,9 @@ public: MyList *l2 = new MyList(nullptr, l1); MyList *l3 = new MyList(nullptr, l2); sink(l3->head); // no flow, b is nested beneath at least one ->next - sink(l3->next->head); // flow, the precise nesting depth isn't tracked + sink(l3->next->head); // no flow sink(l3->next->next->head); // flow - sink(l3->next->next->next->head); // flow + sink(l3->next->next->next->head); // no flow for (MyList *l = l3; l != nullptr; l = l->next) { sink(l->head); // flow diff --git a/cpp/ql/test/library-tests/dataflow/fields/B.cpp b/cpp/ql/test/library-tests/dataflow/fields/B.cpp index 13581ce3e60..a482c10aead 100644 --- a/cpp/ql/test/library-tests/dataflow/fields/B.cpp +++ b/cpp/ql/test/library-tests/dataflow/fields/B.cpp @@ -7,7 +7,7 @@ class B Box1 *b1 = new Box1(e, nullptr); Box2 *b2 = new Box2(b1); sink(b2->box1->elem1); // flow - sink(b2->box1->elem2); // FP due to flow in f2 below + sink(b2->box1->elem2); // no flow [FALSE POSITIVE] (due to flow in f2 below) } void f2() @@ -15,7 +15,7 @@ class B Elem *e = new B::Elem(); Box1 *b1 = new B::Box1(nullptr, e); Box2 *b2 = new Box2(b1); - sink(b2->box1->elem1); // FP due to flow in f1 above + sink(b2->box1->elem1); // no flow [FALSE POSITIVE] (due to flow in f1 above) sink(b2->box1->elem2); // flow } diff --git a/cpp/ql/test/library-tests/dataflow/fields/C.cpp b/cpp/ql/test/library-tests/dataflow/fields/C.cpp index ac87f48204b..02a6c4f95b6 100644 --- a/cpp/ql/test/library-tests/dataflow/fields/C.cpp +++ b/cpp/ql/test/library-tests/dataflow/fields/C.cpp @@ -26,12 +26,12 @@ public: void func() { - sink(s1); - sink(s2); - sink(s3); - sink(s4); + sink(s1); // flow [NOT DETECTED] (in either place) + sink(s2); // flow [NOT DETECTED] + sink(s3); // flow + sink(s4); // flow [NOT DETECTED] } static void sink(const void *o) {} }; -const C::Elem *C::s4 = new Elem(); \ No newline at end of file +const C::Elem *C::s4 = new Elem();