@@ -132,7 +132,7 @@ class StringComponentCfgNode extends AstCfgNode {
132
132
string getValueText ( ) { result = this .getNode ( ) .( StringComponent ) .getValueText ( ) }
133
133
}
134
134
135
- private Expr desugar ( Expr n ) {
135
+ private AstNode desugar ( AstNode n ) {
136
136
result = n .getDesugared ( )
137
137
or
138
138
not exists ( n .getDesugared ( ) ) and
@@ -147,10 +147,10 @@ abstract private class ExprChildMapping extends Expr {
147
147
* Holds if `child` is a (possibly nested) child of this expression
148
148
* for which we would like to find a matching CFG child.
149
149
*/
150
- abstract predicate relevantChild ( Expr child ) ;
150
+ abstract predicate relevantChild ( AstNode child ) ;
151
151
152
152
pragma [ nomagic]
153
- private predicate reachesBasicBlock ( Expr child , CfgNode cfn , BasicBlock bb ) {
153
+ private predicate reachesBasicBlock ( AstNode child , CfgNode cfn , BasicBlock bb ) {
154
154
this .relevantChild ( child ) and
155
155
cfn = this .getAControlFlowNode ( ) and
156
156
bb .getANode ( ) = cfn
@@ -170,16 +170,16 @@ abstract private class ExprChildMapping extends Expr {
170
170
* The path never escapes the syntactic scope of this expression.
171
171
*/
172
172
cached
173
- predicate hasCfgChild ( Expr child , CfgNode cfn , CfgNode cfnChild ) {
173
+ predicate hasCfgChild ( AstNode child , CfgNode cfn , CfgNode cfnChild ) {
174
174
this .reachesBasicBlock ( child , cfn , cfnChild .getBasicBlock ( ) ) and
175
- cfnChild = desugar ( child ) . getAControlFlowNode ( )
175
+ cfnChild . getNode ( ) = desugar ( child )
176
176
}
177
177
}
178
178
179
179
/** Provides classes for control-flow nodes that wrap AST expressions. */
180
180
module ExprNodes {
181
181
private class LiteralChildMapping extends ExprChildMapping , Literal {
182
- override predicate relevantChild ( Expr e ) { none ( ) }
182
+ override predicate relevantChild ( AstNode n ) { none ( ) }
183
183
}
184
184
185
185
/** A control-flow node that wraps an `ArrayLiteral` AST expression. */
@@ -192,7 +192,7 @@ module ExprNodes {
192
192
}
193
193
194
194
private class AssignExprChildMapping extends ExprChildMapping , AssignExpr {
195
- override predicate relevantChild ( Expr e ) { e = this .getAnOperand ( ) }
195
+ override predicate relevantChild ( AstNode n ) { n = this .getAnOperand ( ) }
196
196
}
197
197
198
198
/** A control-flow node that wraps an `AssignExpr` AST expression. */
@@ -209,7 +209,7 @@ module ExprNodes {
209
209
}
210
210
211
211
private class OperationExprChildMapping extends ExprChildMapping , Operation {
212
- override predicate relevantChild ( Expr e ) { e = this .getAnOperand ( ) }
212
+ override predicate relevantChild ( AstNode n ) { n = this .getAnOperand ( ) }
213
213
}
214
214
215
215
/** A control-flow node that wraps an `Operation` AST expression. */
@@ -292,7 +292,7 @@ module ExprNodes {
292
292
}
293
293
294
294
private class BlockArgumentChildMapping extends ExprChildMapping , BlockArgument {
295
- override predicate relevantChild ( Expr e ) { e = this .getValue ( ) }
295
+ override predicate relevantChild ( AstNode n ) { n = this .getValue ( ) }
296
296
}
297
297
298
298
/** A control-flow node that wraps a `BlockArgument` AST expression. */
@@ -306,8 +306,8 @@ module ExprNodes {
306
306
}
307
307
308
308
private class CallExprChildMapping extends ExprChildMapping , Call {
309
- override predicate relevantChild ( Expr e ) {
310
- e = [ this .getAnArgument ( ) , this .( MethodCall ) .getReceiver ( ) , this .( MethodCall ) .getBlock ( ) ]
309
+ override predicate relevantChild ( AstNode n ) {
310
+ n = [ this .getAnArgument ( ) , this .( MethodCall ) .getReceiver ( ) , this .( MethodCall ) .getBlock ( ) ]
311
311
}
312
312
}
313
313
@@ -340,7 +340,7 @@ module ExprNodes {
340
340
}
341
341
342
342
private class CaseExprChildMapping extends ExprChildMapping , CaseExpr {
343
- override predicate relevantChild ( Expr e ) { e = this .getValue ( ) }
343
+ override predicate relevantChild ( AstNode e ) { e = this .getValue ( ) }
344
344
}
345
345
346
346
/** A control-flow node that wraps a `MethodCall` AST expression. */
@@ -361,7 +361,7 @@ module ExprNodes {
361
361
}
362
362
363
363
private class ConditionalExprChildMapping extends ExprChildMapping , ConditionalExpr {
364
- override predicate relevantChild ( Expr e ) { e = this .getCondition ( ) or e = this .getBranch ( _) }
364
+ override predicate relevantChild ( AstNode n ) { n = [ this .getCondition ( ) , this .getBranch ( _) ] }
365
365
}
366
366
367
367
/** A control-flow node that wraps a `ConditionalExpr` AST expression. */
@@ -381,7 +381,7 @@ module ExprNodes {
381
381
}
382
382
383
383
private class ConstantAccessChildMapping extends ExprChildMapping , ConstantAccess {
384
- override predicate relevantChild ( Expr e ) { e = this .getScopeExpr ( ) }
384
+ override predicate relevantChild ( AstNode n ) { n = this .getScopeExpr ( ) }
385
385
}
386
386
387
387
/** A control-flow node that wraps a `ConditionalExpr` AST expression. */
@@ -397,7 +397,7 @@ module ExprNodes {
397
397
}
398
398
399
399
private class StmtSequenceChildMapping extends ExprChildMapping , StmtSequence {
400
- override predicate relevantChild ( Expr e ) { e = this .getLastStmt ( ) }
400
+ override predicate relevantChild ( AstNode n ) { n = this .getLastStmt ( ) }
401
401
}
402
402
403
403
/** A control-flow node that wraps a `StmtSequence` AST expression. */
@@ -411,7 +411,7 @@ module ExprNodes {
411
411
}
412
412
413
413
private class ForExprChildMapping extends ExprChildMapping , ForExpr {
414
- override predicate relevantChild ( Expr e ) { e = this .getValue ( ) }
414
+ override predicate relevantChild ( AstNode n ) { n = this .getValue ( ) }
415
415
}
416
416
417
417
/** A control-flow node that wraps a `ForExpr` AST expression. */
@@ -430,7 +430,7 @@ module ExprNodes {
430
430
}
431
431
432
432
private class PairChildMapping extends ExprChildMapping , Pair {
433
- override predicate relevantChild ( Expr e ) { e = this .getKey ( ) or e = this .getValue ( ) }
433
+ override predicate relevantChild ( AstNode n ) { n = [ this .getKey ( ) , this .getValue ( ) ] }
434
434
}
435
435
436
436
/** A control-flow node that wraps a `Pair` AST expression. */
@@ -475,7 +475,7 @@ module ExprNodes {
475
475
}
476
476
477
477
private class StringlikeLiteralChildMapping extends ExprChildMapping , StringlikeLiteral {
478
- override predicate relevantChild ( Expr e ) { e = this .getComponent ( _) }
478
+ override predicate relevantChild ( AstNode n ) { n = this .getComponent ( _) }
479
479
}
480
480
481
481
/** A control-flow node that wraps a `StringlikeLiteral` AST expression. */
0 commit comments