Skip to content

Commit 7f61082

Browse files
author
Robert Marsh
authored
Merge pull request #1927 from jbj/instructionNode
C++: Add DataFlow::instructionNode
2 parents f503e04 + c7e6081 commit 7f61082

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)