@@ -14,29 +14,27 @@ private module SourceVariables {
14
14
abstract class SourceVariable extends TSourceVariable {
15
15
IRVariable var ;
16
16
17
- IRVariable getIRVariable ( ) { result = var }
18
-
19
17
abstract string toString ( ) ;
20
-
21
- predicate isIndirection ( ) { none ( ) }
22
18
}
23
19
24
- private class SourceIRVariable extends SourceVariable , TSourceIRVariable {
20
+ class SourceIRVariable extends SourceVariable , TSourceIRVariable {
25
21
SourceIRVariable ( ) { this = TSourceIRVariable ( var ) }
26
22
23
+ IRVariable getIRVariable ( ) { result = var }
24
+
27
25
override string toString ( ) { result = this .getIRVariable ( ) .toString ( ) }
28
26
}
29
27
30
- private class SourceIRVariableIndirection extends SourceVariable , TSourceIRVariableIndirection {
28
+ class SourceIRVariableIndirection extends SourceVariable , TSourceIRVariableIndirection {
31
29
InitializeIndirectionInstruction init ;
32
30
33
31
SourceIRVariableIndirection ( ) {
34
32
this = TSourceIRVariableIndirection ( init ) and var = init .getIRVariable ( )
35
33
}
36
34
37
- override string toString ( ) { result = "*" + this . getIRVariable ( ) . toString ( ) }
35
+ IRVariable getUnderlyingIRVariable ( ) { result = var }
38
36
39
- override predicate isIndirection ( ) { any ( ) }
37
+ override string toString ( ) { result = "*" + this . getUnderlyingIRVariable ( ) . toString ( ) }
40
38
}
41
39
}
42
40
@@ -120,8 +118,7 @@ private class ExplicitDef extends Def, TExplicitDef {
120
118
override SourceVariable getSourceVariable ( ) {
121
119
exists ( VariableInstruction var |
122
120
explicitWrite ( _, this .getInstruction ( ) , var ) and
123
- result .getIRVariable ( ) = var .getIRVariable ( ) and
124
- not result .isIndirection ( )
121
+ result .( SourceIRVariable ) .getIRVariable ( ) = var .getIRVariable ( )
125
122
)
126
123
}
127
124
@@ -132,11 +129,11 @@ private class ParameterDef extends Def, TInitializeParam {
132
129
ParameterDef ( ) { this = TInitializeParam ( store ) }
133
130
134
131
override SourceVariable getSourceVariable ( ) {
135
- result .getIRVariable ( ) = store . ( InitializeParameterInstruction ) . getIRVariable ( ) and
136
- not result . isIndirection ( )
132
+ result .( SourceIRVariable ) . getIRVariable ( ) =
133
+ store . ( InitializeParameterInstruction ) . getIRVariable ( )
137
134
or
138
- result .getIRVariable ( ) = store . ( InitializeIndirectionInstruction ) . getIRVariable ( ) and
139
- result . isIndirection ( )
135
+ result .( SourceIRVariableIndirection ) . getUnderlyingIRVariable ( ) =
136
+ store . ( InitializeIndirectionInstruction ) . getIRVariable ( )
140
137
}
141
138
142
139
override predicate isCertain ( ) { any ( ) }
@@ -166,12 +163,9 @@ private class ExplicitUse extends Use, TExplicitUse {
166
163
override SourceVariable getSourceVariable ( ) {
167
164
exists ( VariableInstruction var |
168
165
use .getDef ( ) = var and
169
- result .getIRVariable ( ) = var .getIRVariable ( ) and
170
- (
171
- if use .getUse ( ) instanceof ReadSideEffectInstruction
172
- then result .isIndirection ( )
173
- else not result .isIndirection ( )
174
- )
166
+ if use .getUse ( ) instanceof ReadSideEffectInstruction
167
+ then result .( SourceIRVariableIndirection ) .getUnderlyingIRVariable ( ) = var .getIRVariable ( )
168
+ else result .( SourceIRVariable ) .getIRVariable ( ) = var .getIRVariable ( )
175
169
)
176
170
}
177
171
}
@@ -182,8 +176,7 @@ private class ReturnParameterIndirection extends Use, TReturnParamIndirection {
182
176
override SourceVariable getSourceVariable ( ) {
183
177
exists ( ReturnIndirectionInstruction ret |
184
178
returnParameterIndirection ( use , ret ) and
185
- result .getIRVariable ( ) = ret .getIRVariable ( ) and
186
- result .isIndirection ( )
179
+ result .( SourceIRVariableIndirection ) .getUnderlyingIRVariable ( ) = ret .getIRVariable ( )
187
180
)
188
181
}
189
182
}
0 commit comments