Skip to content

Commit 0f6c56a

Browse files
committed
C++: Use names that better match the AST dataflow library.
1 parent d14b993 commit 0f6c56a

File tree

2 files changed

+200
-183
lines changed

2 files changed

+200
-183
lines changed

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,19 @@ private class PrimaryArgumentNode extends ArgumentNode {
3131
override predicate argumentOf(DataFlowCall call, int pos) { op = call.getArgumentOperand(pos) }
3232

3333
override string toString() {
34-
result = "Argument " + op.(PositionalArgumentOperand).getIndex()
34+
exists(Expr unconverted |
35+
unconverted = op.getDef().getUnconvertedResultExpression() and
36+
result = unconverted.toString()
37+
)
3538
or
36-
op instanceof ThisArgumentOperand and result = "This argument"
39+
// Certain instructions don't map to an unconverted result expression. For these cases
40+
// we fall back to a simpler naming scheme. This can happen in IR-generated constructors.
41+
not exists(op.getDef().getUnconvertedResultExpression()) and
42+
(
43+
result = "Argument " + op.(PositionalArgumentOperand).getIndex()
44+
or
45+
op instanceof ThisArgumentOperand and result = "Argument this"
46+
)
3747
}
3848
}
3949

@@ -53,9 +63,16 @@ private class SideEffectArgumentNode extends ArgumentNode {
5363
}
5464

5565
override string toString() {
56-
if read.getIndex() = -1
57-
then result = "This indirection"
58-
else result = "Argument " + read.getIndex() + " indirection"
66+
result = read.getArgumentDef().getUnconvertedResultExpression().toString() + " indirection"
67+
or
68+
// Some instructions don't map to an unconverted result expression. For these cases
69+
// we fall back to a simpler naming scheme. This can happen in IR-generated constructors.
70+
not exists(read.getArgumentDef().getUnconvertedResultExpression()) and
71+
(
72+
if read.getIndex() = -1
73+
then result = "Argument this indirection"
74+
else result = "Argument " + read.getIndex() + " indirection"
75+
)
5976
}
6077
}
6178

0 commit comments

Comments
 (0)