Skip to content

Commit 3c256ba

Browse files
committed
refactor(cfg): Simplify ExprChildMapping usage in control flow node classes
1 parent f94e594 commit 3c256ba

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

ql/lib/codeql/bicep/controlflow/CfgNodes.qll

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,6 @@ class VariableWriteAccessCfgNode extends VariableAccessCfgNode {
147147

148148
/** Provides classes for control-flow nodes that wrap AST expressions. */
149149
module ExprNodes {
150-
/** A mapping from a child of an expression to an expression. */
151-
abstract class ExprChildMapping extends Expr {
152-
/** Holds if `n` is a relevant child of this expression. */
153-
abstract predicate relevantChild(AstNode n);
154-
}
155-
156150
/** A mapping from a child of a literal to a literal. */
157151
abstract class LiteralChildMapping extends AstNode {
158152
/** Holds if `n` is a relevant child of this literal. */
@@ -241,7 +235,7 @@ module ExprNodes {
241235
}
242236

243237
/** A mapping from a child of an Arguments expression to the expression. */
244-
abstract class ArgumentsChildMapping extends ExprNodes::ExprChildMapping, Arguments {
238+
abstract class ArgumentsChildMapping extends ExprChildMapping, Arguments {
245239
override predicate relevantChild(AstNode n) { n = this.getArgument(_) }
246240
}
247241

@@ -255,7 +249,7 @@ module ExprNodes {
255249
}
256250

257251
/** A mapping from a child of an AssignmentExpression to the expression. */
258-
abstract class AssignmentExpressionChildMapping extends ExprNodes::ExprChildMapping,
252+
abstract class AssignmentExpressionChildMapping extends ExprChildMapping,
259253
AssignmentExpression
260254
{
261255
override predicate relevantChild(AstNode n) { n = this.getLeft() or n = this.getRight() }
@@ -271,7 +265,7 @@ module ExprNodes {
271265
}
272266

273267
/** A mapping from a child of a BinaryExpression to the expression. */
274-
abstract class BinaryExpressionChildMapping extends ExprNodes::ExprChildMapping, BinaryExpression {
268+
abstract class BinaryExpressionChildMapping extends ExprChildMapping, BinaryExpression {
275269
override predicate relevantChild(AstNode n) { n = this.getLeft() or n = this.getRight() }
276270
}
277271

@@ -297,7 +291,7 @@ module ExprNodes {
297291
}
298292

299293
/** A mapping from a child of an Interpolation to the expression. */
300-
abstract class InterpolationChildMapping extends ExprNodes::ExprChildMapping, Interpolation {
294+
abstract class InterpolationChildMapping extends ExprChildMapping, Interpolation {
301295
override predicate relevantChild(AstNode n) { n = this.getExpression() }
302296
}
303297

@@ -411,7 +405,7 @@ module ExprNodes {
411405
}
412406

413407
/** A mapping from a child of a Parameter to the expression. */
414-
abstract class ParameterChildMapping extends ExprNodes::ExprChildMapping, Parameter {
408+
abstract class ParameterChildMapping extends ExprChildMapping, Parameter {
415409
override predicate relevantChild(AstNode n) { n = this.getIdentifier() or n = this.getType() }
416410
}
417411

@@ -425,7 +419,7 @@ module ExprNodes {
425419
}
426420

427421
/** A mapping from a child of Parameters to the expression. */
428-
abstract class ParametersChildMaping extends ExprNodes::ExprChildMapping, Parameters {
422+
abstract class ParametersChildMaping extends ExprChildMapping, Parameters {
429423
override predicate relevantChild(AstNode n) { n = this.getParameter(_) }
430424
}
431425

@@ -546,7 +540,7 @@ module StmtNodes {
546540
abstract class UserDefinedFunctionChildMapping extends StmtChildMapping, UserDefinedFunction {
547541
override predicate relevantChild(AstNode n) {
548542
n = this.getIdentifier() or
549-
n = this.getDeclaredParameters() or
543+
n = this.getParameters() or
550544
n = this.getReturnType() or
551545
n = this.getBody()
552546
}

0 commit comments

Comments
 (0)