File tree 1 file changed +10
-7
lines changed
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,15 @@ private module SourceVariables {
16
16
ind = [ 0 .. countIndirectionsForCppType ( base .getLanguageType ( ) ) + 1 ]
17
17
}
18
18
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
+
19
28
class SourceVariable extends TSourceVariable {
20
29
SsaInternals0:: SourceVariable base ;
21
30
int ind ;
@@ -32,13 +41,7 @@ private module SourceVariables {
32
41
SsaInternals0:: SourceVariable getBaseVariable ( ) { result = base }
33
42
34
43
/** 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 ( ) ) }
42
45
43
46
/**
44
47
* Gets the number of loads performed on the base source variable
You can’t perform that action at this time.
0 commit comments