Files
codeql/cpp/ql/test/library-tests/dataflow/fields/B.cpp
Jonas Jensen ed1e3ed1ef 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.
2019-08-15 10:30:46 +02:00

50 lines
791 B
C++

class B
{
void f1()
{
Elem *e = new Elem();
Box1 *b1 = new Box1(e, nullptr);
Box2 *b2 = new Box2(b1);
sink(b2->box1->elem1); // flow
sink(b2->box1->elem2); // no flow [FALSE POSITIVE] (due to flow in f2 below)
}
void f2()
{
Elem *e = new B::Elem();
Box1 *b1 = new B::Box1(nullptr, e);
Box2 *b2 = new Box2(b1);
sink(b2->box1->elem1); // no flow [FALSE POSITIVE] (due to flow in f1 above)
sink(b2->box1->elem2); // flow
}
static void sink(void *o) {}
class Elem
{
};
class Box1
{
public:
Elem *elem1;
Elem *elem2;
Box1(Elem *e1, Elem *e2)
{
this->elem1 = e1;
this->elem2 = e2;
}
};
class Box2
{
public:
Box1 *box1;
Box2(Box1 *b1)
{
this->box1 = b1;
}
};
};