Skip to content

Commit 56e44f9

Browse files
authored
Merge pull request #15458 from MathiasVP/dataflow-node-deduplication
C++: Fix more `asExpr` duplication
2 parents 436a9ce + 3200920 commit 56e44f9

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,10 @@ private class InstructionExprNode extends ExprNodeBase, InstructionNode {
14081408
InstructionExprNode() {
14091409
exists(Expr e, int n |
14101410
exprNodeShouldBeInstruction(this, e, n) and
1411-
not exprNodeShouldBe(e, n + 1)
1411+
not exists(Expr conv |
1412+
exprNodeShouldBe(conv, n + 1) and
1413+
conv.getUnconverted() = e.getUnconverted()
1414+
)
14121415
)
14131416
}
14141417

@@ -1419,7 +1422,10 @@ private class OperandExprNode extends ExprNodeBase, OperandNode {
14191422
OperandExprNode() {
14201423
exists(Expr e, int n |
14211424
exprNodeShouldBeOperand(this, e, n) and
1422-
not exprNodeShouldBe(e, n + 1)
1425+
not exists(Expr conv |
1426+
exprNodeShouldBe(conv, n + 1) and
1427+
conv.getUnconverted() = e.getUnconverted()
1428+
)
14231429
)
14241430
}
14251431

cpp/ql/test/library-tests/dataflow/asExpr/test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ void take_const_ref_int(const int &);
22

33
void test_materialize_temp_int()
44
{
5-
take_const_ref_int(42); // $ asExpr=42 numberOfNodes="42: 2" asIndirectExpr=42
5+
take_const_ref_int(42); // $ asExpr=42 asIndirectExpr=42
66
}
77

88
struct A {};
@@ -11,7 +11,7 @@ A get();
1111
void take_const_ref(const A &);
1212

1313
void test1(){
14-
take_const_ref(get()); // $ asExpr="call to get" numberOfNodes="call to get: 2" asIndirectExpr="call to get"
14+
take_const_ref(get()); // $ asExpr="call to get" asIndirectExpr="call to get"
1515
}
1616

1717
void take_ref(A &);

cpp/ql/test/library-tests/string_concat/strconcat.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
| concat.cpp:23:27:23:27 | call to operator+ | concat.cpp:23:22:23:25 | str1 | concat.cpp:23:22:23:31 | call to operator+ |
2-
| concat.cpp:23:27:23:27 | call to operator+ | concat.cpp:23:22:23:25 | str1 | concat.cpp:23:27:23:27 | call to operator+ |
32
| concat.cpp:23:27:23:27 | call to operator+ | concat.cpp:23:29:23:31 | | concat.cpp:23:22:23:31 | call to operator+ |
4-
| concat.cpp:23:27:23:27 | call to operator+ | concat.cpp:23:29:23:31 | | concat.cpp:23:27:23:27 | call to operator+ |
53
| concat.cpp:23:33:23:33 | call to operator+ | concat.cpp:23:35:23:38 | str2 | concat.cpp:23:22:23:38 | call to operator+ |
6-
| concat.cpp:23:33:23:33 | call to operator+ | concat.cpp:23:35:23:38 | str2 | concat.cpp:23:33:23:33 | call to operator+ |
74
| concat.cpp:23:40:23:40 | call to operator+ | concat.cpp:23:42:23:45 | str3 | concat.cpp:23:40:23:40 | call to operator+ |
85
| concat.cpp:47:8:47:8 | call to operator<< | concat.cpp:47:11:47:14 | str1 | concat.cpp:47:8:47:17 | call to operator<< |
96
| concat.cpp:47:16:47:16 | call to operator<< | concat.cpp:47:19:47:21 | | concat.cpp:47:16:47:24 | call to operator<< |

0 commit comments

Comments
 (0)