Skip to content

Commit df882a9

Browse files
C++: Avoid creating ExprNodes for Conversions
1 parent ebbd701 commit df882a9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ class Node extends Instruction {
2525
}
2626

2727
/** Gets the expression corresponding to this node, if any. */
28-
Expr asExpr() { result = this.getConvertedResultExpression() }
28+
Expr asExpr() {
29+
result = this.getConvertedResultExpression() and
30+
// Ignore conversions. The AST-based library does have an `ExprNode` for each `Conversion`, but
31+
// there is no flow involving those nodes.
32+
not result instanceof Conversion
33+
}
2934

3035
/** Gets the parameter corresponding to this node, if any. */
3136
Parameter asParameter() { result = this.(InitializeParameterInstruction).getParameter() }
@@ -100,7 +105,9 @@ abstract class PostUpdateNode extends Node {
100105
/**
101106
* Gets the `Node` corresponding to `e`.
102107
*/
103-
ExprNode exprNode(Expr e) { result.getExpr() = e }
108+
ExprNode exprNode(Expr e) {
109+
result.getExpr() = e
110+
}
104111

105112
/**
106113
* Gets the `Node` corresponding to the value of `p` at function entry.

0 commit comments

Comments
 (0)