File tree Expand file tree Collapse file tree 3 files changed +64
-0
lines changed
cpp/ql/test/library-tests/dataflow/calls-as-ssa-variables Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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 | |
Original file line number Diff line number Diff line change
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 , ""
You can’t perform that action at this time.
0 commit comments