Skip to content

Commit 8230a90

Browse files
committed
C++: No need for another 'stars' predicate in 'PrintIRUtilities'.
1 parent 9b25834 commit 8230a90

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
private import cpp
22
private import semmle.code.cpp.ir.IR
33
private import semmle.code.cpp.ir.dataflow.internal.DataFlowUtil
4+
private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate
45
private import SsaInternals as Ssa
56
private import PrintIRUtilities
67

@@ -33,9 +34,9 @@ private string getNodeProperty(Node node, string key) {
3334
key = "flow" and
3435
result =
3536
strictconcat(string flow, boolean to, int order1, int order2 |
36-
flow = getFromFlow(node, order1, order2) + "->" + starsForNode(node) + "@" and to = false
37+
flow = getFromFlow(node, order1, order2) + "->" + stars(node) + "@" and to = false
3738
or
38-
flow = starsForNode(node) + "@->" + getToFlow(node, order1, order2) and to = true
39+
flow = stars(node) + "@->" + getToFlow(node, order1, order2) and to = true
3940
|
4041
flow, ", " order by to, order1, order2, flow
4142
)

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

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,14 @@ private import semmle.code.cpp.ir.IR
77
private import semmle.code.cpp.ir.dataflow.internal.DataFlowUtil
88
private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate
99

10-
private string stars(int k) {
11-
k =
12-
[0 .. max([
13-
any(RawIndirectInstruction n).getIndirectionIndex(),
14-
any(RawIndirectOperand n).getIndirectionIndex()
15-
]
16-
)] and
17-
(if k = 0 then result = "" else result = "*" + stars(k - 1))
18-
}
19-
20-
string starsForNode(Node node) {
21-
exists(int indirectionIndex |
22-
node.(IndirectInstruction).hasInstructionAndIndirectionIndex(_, indirectionIndex) or
23-
node.(IndirectOperand).hasOperandAndIndirectionIndex(_, indirectionIndex)
24-
|
25-
result = stars(indirectionIndex)
26-
)
27-
or
28-
not node instanceof IndirectInstruction and
29-
not node instanceof IndirectOperand and
30-
result = ""
31-
}
32-
3310
private Instruction getInstruction(Node n, string stars) {
3411
result = [n.asInstruction(), n.(RawIndirectInstruction).getInstruction()] and
35-
stars = starsForNode(n)
12+
stars = stars(n)
3613
}
3714

3815
private Operand getOperand(Node n, string stars) {
3916
result = [n.asOperand(), n.(RawIndirectOperand).getOperand()] and
40-
stars = starsForNode(n)
17+
stars = stars(n)
4118
}
4219

4320
/**

0 commit comments

Comments
 (0)