Skip to content

Commit 5951ae7

Browse files
committed
Dataflow: Add language specific predicates.
1 parent 00df679 commit 5951ae7

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ private import DataFlowUtil
33
private import DataFlowDispatch
44
private import FlowVar
55

6+
/** Gets the callable in which this node occurs. */
7+
DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() }
8+
9+
/** Holds if `p` is a `ParameterNode` of `c` with position `pos`. */
10+
predicate isParameterNode(ParameterNode p, DataFlowCallable c, int pos) { p.isParameterOf(c, pos) }
11+
612
/** Gets the instance argument of a non-static call. */
713
private Node getInstanceArgument(Call call) {
814
result.asExpr() = call.getQualifier()

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ private import DataFlowUtil
33
private import semmle.code.cpp.ir.IR
44
private import DataFlowDispatch
55

6+
/** Gets the callable in which this node occurs. */
7+
DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() }
8+
9+
/** Holds if `p` is a `ParameterNode` of `c` with position `pos`. */
10+
predicate isParameterNode(ParameterNode p, DataFlowCallable c, int pos) { p.isParameterOf(c, pos) }
11+
612
/**
713
* A data flow node that occurs as the argument of a call and is passed as-is
814
* to the callable. Instance arguments (`this` pointer) and read side effects

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ private import semmle.code.csharp.frameworks.NHibernate
1818
private import semmle.code.csharp.frameworks.system.Collections
1919
private import semmle.code.csharp.frameworks.system.threading.Tasks
2020

21+
/** Gets the callable in which this node occurs. */
22+
DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() }
23+
24+
/** Holds if `p` is a `ParameterNode` of `c` with position `pos`. */
25+
predicate isParameterNode(ParameterNode p, DataFlowCallable c, int pos) { p.isParameterOf(c, pos) }
26+
2127
abstract class NodeImpl extends Node {
2228
/** Do not call: use `getEnclosingCallable()` instead. */
2329
abstract DataFlowCallable getEnclosingCallableImpl();

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ private import DataFlowPublic
33
import semmle.python.SpecialMethods
44
private import semmle.python.essa.SsaCompute
55

6+
/** Gets the callable in which this node occurs. */
7+
DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() }
8+
9+
/** Holds if `p` is a `ParameterNode` of `c` with position `pos`. */
10+
predicate isParameterNode(ParameterNode p, DataFlowCallable c, int pos) { p.isParameterOf(c, pos) }
11+
612
//--------
713
// Data flow graph
814
//--------

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ private import DataFlowDispatch
66
private import SsaImpl as SsaImpl
77
private import FlowSummaryImpl as FlowSummaryImpl
88

9+
/** Gets the callable in which this node occurs. */
10+
DataFlowCallable nodeGetEnclosingCallable(Node n) { result = n.getEnclosingCallable() }
11+
12+
/** Holds if `p` is a `ParameterNode` of `c` with position `pos`. */
13+
predicate isParameterNode(ParameterNode p, DataFlowCallable c, int pos) { p.isParameterOf(c, pos) }
14+
915
abstract class NodeImpl extends Node {
1016
/** Do not call: use `getEnclosingCallable()` instead. */
1117
abstract CfgScope getCfgScope();

0 commit comments

Comments
 (0)