@@ -37,6 +37,19 @@ class AllocaCall extends FunctionCall {
3737 }
3838}
3939
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+
4053/**
4154 * A loop that contains an `alloca` call.
4255 */
@@ -185,19 +198,6 @@ class LoopWithAlloca extends Stmt {
185198 not this .conditionReachesWithoutUpdate ( var , this .( Loop ) .getCondition ( ) )
186199 }
187200
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-
201201 /**
202202 * Gets a definition that may be the most recent definition of the
203203 * controlling variable `var` before this loop.
@@ -210,7 +210,7 @@ class LoopWithAlloca extends Stmt {
210210 // Phi nodes will be preceded by nodes that represent actual definitions
211211 not result instanceof DataFlow:: SsaPhiNode and
212212 // 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 ) )
214214 )
215215 }
216216
@@ -221,9 +221,9 @@ class LoopWithAlloca extends Stmt {
221221 private int getAControllingVarInitialValue ( Variable var , DataFlow:: Node source ) {
222222 source = this .getAPrecedingDef ( var ) and
223223 (
224- result = this . getExpr ( source ) .getValue ( ) .toInt ( )
224+ result = getExpr ( source ) .getValue ( ) .toInt ( )
225225 or
226- result = this . getExpr ( source ) .( Assignment ) .getRValue ( ) .getValue ( ) .toInt ( )
226+ result = getExpr ( source ) .( Assignment ) .getRValue ( ) .getValue ( ) .toInt ( )
227227 )
228228 }
229229
0 commit comments