Skip to content

Commit c7e6081

Browse files
committed
C++: Add DataFlow::instructionNode
This is for symmetry with `exprNode` etc., and it should be handy for the same reasons. I found one caller of `asInstruction` that got simpler by using the new predicate instead.
1 parent 10076a6 commit c7e6081

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ private predicate predictable(Expr expr) {
2222

2323
// TODO: remove when `predictable` has an `Instruction` parameter instead of `Expr`.
2424
private predicate predictableInstruction(Instruction instr) {
25-
exists(DataFlow::Node node |
26-
node.asInstruction() = instr and
27-
predictable(node.asExpr())
28-
)
25+
predictable(DataFlow::instructionNode(instr).asExpr())
2926
}
3027

3128
private class DefaultTaintTrackingCfg extends DataFlow::Configuration {

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ abstract class PostUpdateNode extends Node {
156156
abstract Node getPreUpdateNode();
157157
}
158158

159+
/**
160+
* Gets the node corresponding to `instr`.
161+
*/
162+
Node instructionNode(Instruction instr) { result.asInstruction() = instr }
163+
159164
/**
160165
* Gets a `Node` corresponding to `e` or any of its conversions. There is no
161166
* result if `e` is a `Conversion`.

0 commit comments

Comments
 (0)