mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C++: The next commit is going to track flow out of both direct and indirect sources. This means we'll get a lot of duplication since there'll be flow from indirect source -> indirect sink and direct source -> direct sink (which both map to the same expressions). This commit changes the testing so that we only report a duplication when they're at different locations.
This commit is contained in:
@@ -25,7 +25,12 @@ class IRFlowTest extends InlineExpectationsTest {
|
||||
exists(IRDataFlow::Node source, IRDataFlow::Node sink, IRDataFlow::Configuration conf, int n |
|
||||
tag = "ir" and
|
||||
conf.hasFlow(source, sink) and
|
||||
n = strictcount(IRDataFlow::Node otherSource | conf.hasFlow(otherSource, sink)) and
|
||||
n =
|
||||
strictcount(int line, int column |
|
||||
conf.hasFlow(any(IRDataFlow::Node otherSource |
|
||||
otherSource.hasLocationInfo(_, line, column, _, _)
|
||||
), sink)
|
||||
) and
|
||||
(
|
||||
n = 1 and value = ""
|
||||
or
|
||||
@@ -53,7 +58,12 @@ class AstFlowTest extends InlineExpectationsTest {
|
||||
|
|
||||
tag = "ast" and
|
||||
conf.hasFlow(source, sink) and
|
||||
n = strictcount(AstDataFlow::Node otherSource | conf.hasFlow(otherSource, sink)) and
|
||||
n =
|
||||
strictcount(int line, int column |
|
||||
conf.hasFlow(any(AstDataFlow::Node otherSource |
|
||||
otherSource.hasLocationInfo(_, line, column, _, _)
|
||||
), sink)
|
||||
) and
|
||||
(
|
||||
n = 1 and value = ""
|
||||
or
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
cc.insert(nullptr);
|
||||
ct.insert(new C());
|
||||
sink(&cc); // no flow
|
||||
sink(&ct); // $ ast ir=41:15
|
||||
sink(&ct); // $ ast ir
|
||||
}
|
||||
void f1()
|
||||
{
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
{
|
||||
B *b = new B();
|
||||
b->set(new C1());
|
||||
sink(b->get()); // $ ast ir=55:12
|
||||
sink(b->get()); // $ ast ir
|
||||
sink((new B(new C()))->get()); // $ ast ir
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
B *b2;
|
||||
b2 = setOnB(b1, new C2());
|
||||
sink(b1->c); // no flow
|
||||
sink(b2->c); // $ ast ir=64:21
|
||||
sink(b2->c); // $ ast ir
|
||||
}
|
||||
|
||||
void f4()
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
B *b2;
|
||||
b2 = setOnBWrap(b1, new C2());
|
||||
sink(b1->c); // no flow
|
||||
sink(b2->c); // $ ast ir=73:25
|
||||
sink(b2->c); // $ ast ir
|
||||
}
|
||||
|
||||
B *setOnBWrap(B *b1, C *c)
|
||||
|
||||
@@ -8,7 +8,7 @@ void test_unique_ptr_int() {
|
||||
std::unique_ptr<int> p2 = std::make_unique<int>(source());
|
||||
|
||||
sink(*p1); // $ ir MISSING: ast
|
||||
sink(*p2); // $ ast ir=8:50
|
||||
sink(*p2); // $ ast ir
|
||||
}
|
||||
|
||||
struct A {
|
||||
@@ -23,7 +23,7 @@ void test_unique_ptr_struct() {
|
||||
|
||||
sink(p1->x); // $ ir MISSING: ast
|
||||
sink(p1->y);
|
||||
sink(p2->x); // $ ir=22:46 MISSING: ast
|
||||
sink(p2->x); // $ ir MISSING: ast
|
||||
sink(p2->y);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ void test_shared_ptr_int() {
|
||||
std::shared_ptr<int> p2 = std::make_shared<int>(source());
|
||||
|
||||
sink(*p1); // $ ast,ir
|
||||
sink(*p2); // $ ast ir=32:50
|
||||
sink(*p2); // $ ast ir
|
||||
}
|
||||
|
||||
void test_shared_ptr_struct() {
|
||||
|
||||
Reference in New Issue
Block a user