@@ -37,6 +37,19 @@ class AllocaCall extends FunctionCall {
37
37
}
38
38
}
39
39
40
+ /**
41
+ * Gets an expression associated with a dataflow node.
42
+ */
43
+ private Expr getExpr ( DataFlow:: Node node ) {
44
+ result = node .asInstruction ( ) .getAst ( )
45
+ or
46
+ result = node .asOperand ( ) .getUse ( ) .getAst ( )
47
+ or
48
+ result = node .( DataFlow:: RawIndirectInstruction ) .getInstruction ( ) .getAst ( )
49
+ or
50
+ result = node .( DataFlow:: RawIndirectOperand ) .getOperand ( ) .getUse ( ) .getAst ( )
51
+ }
52
+
40
53
/**
41
54
* A loop that contains an `alloca` call.
42
55
*/
@@ -185,19 +198,6 @@ class LoopWithAlloca extends Stmt {
185
198
not this .conditionReachesWithoutUpdate ( var , this .( Loop ) .getCondition ( ) )
186
199
}
187
200
188
- /**
189
- * Gets an expression associated with a dataflow node.
190
- */
191
- private Expr getExpr ( DataFlow:: Node node ) {
192
- result = node .asInstruction ( ) .getAst ( )
193
- or
194
- result = node .asOperand ( ) .getUse ( ) .getAst ( )
195
- or
196
- result = node .( DataFlow:: RawIndirectInstruction ) .getInstruction ( ) .getAst ( )
197
- or
198
- result = node .( DataFlow:: RawIndirectOperand ) .getOperand ( ) .getUse ( ) .getAst ( )
199
- }
200
-
201
201
/**
202
202
* Gets a definition that may be the most recent definition of the
203
203
* controlling variable `var` before this loop.
@@ -210,7 +210,7 @@ class LoopWithAlloca extends Stmt {
210
210
// Phi nodes will be preceded by nodes that represent actual definitions
211
211
not result instanceof DataFlow:: SsaPhiNode and
212
212
// A source is outside the loop if it's not inside the loop
213
- not exists ( Expr e | e = this . getExpr ( result ) | this = getAnEnclosingLoopOfExpr ( e ) )
213
+ not exists ( Expr e | e = getExpr ( result ) | this = getAnEnclosingLoopOfExpr ( e ) )
214
214
)
215
215
}
216
216
@@ -221,9 +221,9 @@ class LoopWithAlloca extends Stmt {
221
221
private int getAControllingVarInitialValue ( Variable var , DataFlow:: Node source ) {
222
222
source = this .getAPrecedingDef ( var ) and
223
223
(
224
- result = this . getExpr ( source ) .getValue ( ) .toInt ( )
224
+ result = getExpr ( source ) .getValue ( ) .toInt ( )
225
225
or
226
- result = this . getExpr ( source ) .( Assignment ) .getRValue ( ) .getValue ( ) .toInt ( )
226
+ result = getExpr ( source ) .( Assignment ) .getRValue ( ) .getValue ( ) .toInt ( )
227
227
)
228
228
}
229
229
0 commit comments