Skip to content

Commit 7a10d88

Browse files
authored
Merge pull request #15185 from MathiasVP/show-indirections-in-ssainternals
2 parents 55f15d2 + 1007c4f commit 7a10d88

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ private module SourceVariables {
1616
ind = [0 .. countIndirectionsForCppType(base.getLanguageType()) + 1]
1717
}
1818

19+
private int maxNumberOfIndirections() { result = max(SourceVariable sv | | sv.getIndirection()) }
20+
21+
private string repeatStars(int n) {
22+
n = 0 and result = ""
23+
or
24+
n = [1 .. maxNumberOfIndirections()] and
25+
result = "*" + repeatStars(n - 1)
26+
}
27+
1928
class SourceVariable extends TSourceVariable {
2029
SsaInternals0::SourceVariable base;
2130
int ind;
@@ -32,13 +41,7 @@ private module SourceVariables {
3241
SsaInternals0::SourceVariable getBaseVariable() { result = base }
3342

3443
/** Gets a textual representation of this element. */
35-
string toString() {
36-
ind = 0 and
37-
result = this.getBaseVariable().toString()
38-
or
39-
ind > 0 and
40-
result = this.getBaseVariable().toString() + " indirection"
41-
}
44+
string toString() { result = repeatStars(this.getIndirection()) }
4245

4346
/**
4447
* Gets the number of loads performed on the base source variable

0 commit comments

Comments
 (0)