Skip to content

Commit 3a21f3c

Browse files
committed
C++: Make 'toString' on 'Ssa::Definition' more clear.
1 parent cac7262 commit 3a21f3c

2 files changed

Lines changed: 30 additions & 26 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ private module SourceVariables {
136136
NormalSourceVariable() { this = TNormalSourceVariable(base, ind) }
137137

138138
final override string toString() {
139-
result = repeatStars(this.getIndirection()) + base.toString()
139+
if ind = 0
140+
then result = "&" + base.toString()
141+
else result = repeatStars(this.getIndirection() - 1) + base.toString()
140142
}
141143
}
142144

@@ -157,7 +159,9 @@ private module SourceVariables {
157159
}
158160

159161
final override string toString() {
160-
result = repeatStars(this.getIndirection()) + base.toString() + " [before crement]"
162+
if ind = 0
163+
then result = "&" + base.toString() + " [before crement]"
164+
else result = repeatStars(this.getIndirection() - 1) + base.toString() + " [before crement]"
161165
}
162166

163167
/**

cpp/ql/test/library-tests/dataflow/dataflow-tests/localFlow-ir.expected

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,52 +65,52 @@
6565
| test.cpp:8:8:8:9 | t1 | test.cpp:9:8:9:9 | t1 |
6666
| test.cpp:9:8:9:9 | t1 | test.cpp:11:7:11:8 | t1 |
6767
| test.cpp:9:8:9:9 | t1 | test.cpp:11:7:11:8 | t1 |
68-
| test.cpp:10:8:10:9 | t2 | test.cpp:11:7:11:8 | [input] SSA phi read(t2) |
69-
| test.cpp:10:8:10:9 | t2 | test.cpp:11:7:11:8 | [input] SSA phi(*t2) |
68+
| test.cpp:10:8:10:9 | t2 | test.cpp:11:7:11:8 | [input] SSA phi read(&t2) |
69+
| test.cpp:10:8:10:9 | t2 | test.cpp:11:7:11:8 | [input] SSA phi(t2) |
7070
| test.cpp:10:8:10:9 | t2 | test.cpp:13:10:13:11 | t2 |
71-
| test.cpp:11:7:11:8 | [input] SSA phi read(t2) | test.cpp:15:8:15:9 | t2 |
72-
| test.cpp:11:7:11:8 | [input] SSA phi(*t2) | test.cpp:15:8:15:9 | t2 |
71+
| test.cpp:11:7:11:8 | [input] SSA phi read(&t2) | test.cpp:15:8:15:9 | t2 |
72+
| test.cpp:11:7:11:8 | [input] SSA phi(t2) | test.cpp:15:8:15:9 | t2 |
7373
| test.cpp:11:7:11:8 | t1 | test.cpp:21:8:21:9 | t1 |
7474
| test.cpp:12:5:12:10 | ... = ... | test.cpp:13:10:13:11 | t2 |
7575
| test.cpp:12:10:12:10 | 0 | test.cpp:12:5:12:10 | ... = ... |
7676
| test.cpp:13:10:13:11 | t2 | test.cpp:15:8:15:9 | t2 |
7777
| test.cpp:13:10:13:11 | t2 | test.cpp:15:8:15:9 | t2 |
78-
| test.cpp:15:8:15:9 | t2 | test.cpp:23:15:23:16 | [input] SSA phi read(*t2) |
78+
| test.cpp:15:8:15:9 | t2 | test.cpp:23:15:23:16 | [input] SSA phi read(&t2) |
7979
| test.cpp:15:8:15:9 | t2 | test.cpp:23:15:23:16 | [input] SSA phi read(t2) |
8080
| test.cpp:17:3:17:8 | ... = ... | test.cpp:21:8:21:9 | t1 |
8181
| test.cpp:17:8:17:8 | 0 | test.cpp:17:3:17:8 | ... = ... |
82-
| test.cpp:21:8:21:9 | t1 | test.cpp:23:19:23:19 | SSA phi read(t1) |
83-
| test.cpp:21:8:21:9 | t1 | test.cpp:23:19:23:19 | SSA phi(*t1) |
82+
| test.cpp:21:8:21:9 | t1 | test.cpp:23:19:23:19 | SSA phi read(&t1) |
83+
| test.cpp:21:8:21:9 | t1 | test.cpp:23:19:23:19 | SSA phi(t1) |
8484
| test.cpp:23:15:23:16 | 0 | test.cpp:23:15:23:16 | 0 |
85-
| test.cpp:23:15:23:16 | 0 | test.cpp:23:19:23:19 | SSA phi(*i) |
86-
| test.cpp:23:15:23:16 | [input] SSA phi read(*t2) | test.cpp:23:19:23:19 | SSA phi read(*t2) |
85+
| test.cpp:23:15:23:16 | 0 | test.cpp:23:19:23:19 | SSA phi(i) |
86+
| test.cpp:23:15:23:16 | [input] SSA phi read(&t2) | test.cpp:23:19:23:19 | SSA phi read(&t2) |
8787
| test.cpp:23:15:23:16 | [input] SSA phi read(t2) | test.cpp:23:19:23:19 | SSA phi read(t2) |
88-
| test.cpp:23:19:23:19 | SSA phi read(*t2) | test.cpp:24:10:24:11 | t2 |
89-
| test.cpp:23:19:23:19 | SSA phi read(i) | test.cpp:23:19:23:19 | i |
90-
| test.cpp:23:19:23:19 | SSA phi read(t1) | test.cpp:23:23:23:24 | t1 |
88+
| test.cpp:23:19:23:19 | SSA phi read(&i) | test.cpp:23:19:23:19 | i |
89+
| test.cpp:23:19:23:19 | SSA phi read(&t1) | test.cpp:23:23:23:24 | t1 |
90+
| test.cpp:23:19:23:19 | SSA phi read(&t2) | test.cpp:24:10:24:11 | t2 |
9191
| test.cpp:23:19:23:19 | SSA phi read(t2) | test.cpp:24:10:24:11 | t2 |
92-
| test.cpp:23:19:23:19 | SSA phi(*i) | test.cpp:23:19:23:19 | i |
93-
| test.cpp:23:19:23:19 | SSA phi(*t1) | test.cpp:23:23:23:24 | t1 |
92+
| test.cpp:23:19:23:19 | SSA phi(i) | test.cpp:23:19:23:19 | i |
93+
| test.cpp:23:19:23:19 | SSA phi(t1) | test.cpp:23:23:23:24 | t1 |
9494
| test.cpp:23:19:23:19 | i | test.cpp:23:27:23:27 | i |
9595
| test.cpp:23:19:23:19 | i | test.cpp:23:27:23:27 | i |
96-
| test.cpp:23:23:23:24 | t1 | test.cpp:23:27:23:29 | [input] SSA phi read(t1) |
96+
| test.cpp:23:23:23:24 | t1 | test.cpp:23:27:23:29 | [input] SSA phi read(&t1) |
9797
| test.cpp:23:23:23:24 | t1 | test.cpp:26:8:26:9 | t1 |
9898
| test.cpp:23:23:23:24 | t1 | test.cpp:26:8:26:9 | t1 |
9999
| test.cpp:23:27:23:27 | *i | test.cpp:23:27:23:27 | *i |
100100
| test.cpp:23:27:23:27 | *i | test.cpp:23:27:23:27 | i |
101101
| test.cpp:23:27:23:27 | i | test.cpp:23:27:23:27 | i |
102102
| test.cpp:23:27:23:27 | i | test.cpp:23:27:23:27 | i |
103-
| test.cpp:23:27:23:27 | i | test.cpp:23:27:23:29 | [input] SSA phi read(i) |
103+
| test.cpp:23:27:23:27 | i | test.cpp:23:27:23:29 | [input] SSA phi read(&i) |
104104
| test.cpp:23:27:23:29 | ... ++ | test.cpp:23:27:23:29 | ... ++ |
105-
| test.cpp:23:27:23:29 | ... ++ | test.cpp:23:27:23:29 | [input] SSA phi(*i) |
106-
| test.cpp:23:27:23:29 | [input] SSA phi read(*t2) | test.cpp:23:19:23:19 | SSA phi read(*t2) |
107-
| test.cpp:23:27:23:29 | [input] SSA phi read(i) | test.cpp:23:19:23:19 | SSA phi read(i) |
108-
| test.cpp:23:27:23:29 | [input] SSA phi read(t1) | test.cpp:23:19:23:19 | SSA phi read(t1) |
105+
| test.cpp:23:27:23:29 | ... ++ | test.cpp:23:27:23:29 | [input] SSA phi(i) |
106+
| test.cpp:23:27:23:29 | [input] SSA phi read(&i) | test.cpp:23:19:23:19 | SSA phi read(&i) |
107+
| test.cpp:23:27:23:29 | [input] SSA phi read(&t1) | test.cpp:23:19:23:19 | SSA phi read(&t1) |
108+
| test.cpp:23:27:23:29 | [input] SSA phi read(&t2) | test.cpp:23:19:23:19 | SSA phi read(&t2) |
109109
| test.cpp:23:27:23:29 | [input] SSA phi read(t2) | test.cpp:23:19:23:19 | SSA phi read(t2) |
110-
| test.cpp:23:27:23:29 | [input] SSA phi(*i) | test.cpp:23:19:23:19 | SSA phi(*i) |
111-
| test.cpp:23:27:23:29 | [input] SSA phi(*t1) | test.cpp:23:19:23:19 | SSA phi(*t1) |
112-
| test.cpp:24:5:24:11 | ... = ... | test.cpp:23:27:23:29 | [input] SSA phi(*t1) |
113-
| test.cpp:24:10:24:11 | t2 | test.cpp:23:27:23:29 | [input] SSA phi read(*t2) |
110+
| test.cpp:23:27:23:29 | [input] SSA phi(i) | test.cpp:23:19:23:19 | SSA phi(i) |
111+
| test.cpp:23:27:23:29 | [input] SSA phi(t1) | test.cpp:23:19:23:19 | SSA phi(t1) |
112+
| test.cpp:24:5:24:11 | ... = ... | test.cpp:23:27:23:29 | [input] SSA phi(t1) |
113+
| test.cpp:24:10:24:11 | t2 | test.cpp:23:27:23:29 | [input] SSA phi read(&t2) |
114114
| test.cpp:24:10:24:11 | t2 | test.cpp:23:27:23:29 | [input] SSA phi read(t2) |
115115
| test.cpp:24:10:24:11 | t2 | test.cpp:24:5:24:11 | ... = ... |
116116
| test.cpp:382:48:382:54 | source1 | test.cpp:384:16:384:23 | *& ... |

0 commit comments

Comments
 (0)