forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhas-parameter-flow-out.ql
More file actions
50 lines (42 loc) · 1.53 KB
/
has-parameter-flow-out.ql
File metadata and controls
50 lines (42 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import utils.test.InlineExpectationsTest
import cpp
module AstTest {
private import semmle.code.cpp.dataflow.DataFlow::DataFlow
private import semmle.code.cpp.dataflow.internal.DataFlowPrivate
module AstParameterDefTest implements TestSig {
string getARelevantTag() { result = "ast-def" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(Function f, Parameter p, RefParameterFinalValueNode n |
p.isNamed() and
n.getParameter() = p and
n.getFunction() = f and
location = f.getLocation() and
element = p.toString() and
tag = "ast-def" and
value = p.getName()
)
}
}
}
module IRTest {
private import semmle.code.cpp.ir.dataflow.DataFlow
private string stars(int k) {
k = [0 .. max(DataFlow::Node n, int i | n.isFinalValueOfParameter(_, i) | i)] and
(if k = 0 then result = "" else result = "*" + stars(k - 1))
}
module IRParameterDefTest implements TestSig {
string getARelevantTag() { result = "ir-def" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(Function f, Parameter p, DataFlow::Node n, int i |
p.isNamed() and
n.isFinalValueOfParameter(p, i) and
n.getFunction() = f and
location = f.getLocation() and
element = p.toString() and
tag = "ir-def" and
value = stars(i) + p.getName()
)
}
}
}
import MakeTest<MergeTests<AstTest::AstParameterDefTest, IRTest::IRParameterDefTest>>