Skip to content

Commit 79919d3

Browse files
committed
C++: Add FP dataflow test.
1 parent 31a5a7a commit 79919d3

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace std
2+
{
3+
struct ptrdiff_t;
4+
struct input_iterator_tag
5+
{
6+
};
7+
struct forward_iterator_tag : public input_iterator_tag
8+
{
9+
};
10+
}
11+
12+
struct A
13+
{
14+
using value_type = int;
15+
using difference_type = std::ptrdiff_t;
16+
using pointer = int*;
17+
using reference = int&;
18+
using iterator_category = std::forward_iterator_tag;
19+
};
20+
21+
A get();
22+
23+
void test()
24+
{
25+
while (true)
26+
{
27+
auto &&x = get();
28+
}
29+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
edges
2+
| test.cpp:27:16:27:18 | call to get | test.cpp:27:16:27:18 | call to get | provenance | |
3+
| test.cpp:27:16:27:18 | call to get | test.cpp:27:16:27:18 | call to get | provenance | |
4+
| test.cpp:27:16:27:20 | call to get | test.cpp:27:16:27:18 | call to get | provenance | |
5+
| test.cpp:27:16:27:20 | call to get | test.cpp:27:16:27:18 | call to get | provenance | |
6+
nodes
7+
| test.cpp:27:16:27:18 | call to get | semmle.label | call to get |
8+
| test.cpp:27:16:27:18 | call to get | semmle.label | call to get |
9+
| test.cpp:27:16:27:20 | call to get | semmle.label | call to get |
10+
subpaths
11+
#select
12+
| test.cpp:27:16:27:18 | call to get | test.cpp:27:16:27:20 | call to get | test.cpp:27:16:27:18 | call to get | |
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @kind path-problem
3+
*/
4+
5+
import semmle.code.cpp.ir.IR
6+
import semmle.code.cpp.dataflow.new.DataFlow
7+
import Flow::PathGraph
8+
9+
module Config implements DataFlow::ConfigSig {
10+
predicate isSource(DataFlow::Node source) {
11+
source.asInstruction().(VariableAddressInstruction).getIRVariable() instanceof IRTempVariable
12+
}
13+
14+
predicate isSink(DataFlow::Node sink) {
15+
sink.asInstruction().(CallInstruction).getStaticCallTarget().hasName("get")
16+
}
17+
}
18+
19+
module Flow = DataFlow::Global<Config>;
20+
21+
from Flow::PathNode source, Flow::PathNode sink
22+
where Flow::flowPath(source, sink)
23+
select sink.getNode(), source, sink, ""

0 commit comments

Comments
 (0)