@@ -137,12 +137,14 @@ class Stmt extends StmtParent, @stmt {
137137 predicate isCompilerGenerated ( ) { compgenerated ( underlyingElement ( this ) ) }
138138}
139139
140+ private class TStmtParent = @stmt or @expr;
141+
140142/**
141143 * An element that is the parent of a statement in the C/C++ AST.
142144 *
143145 * This is normally a statement, but may be a `StmtExpr`.
144146 */
145- abstract class StmtParent extends ControlFlowNode { }
147+ class StmtParent extends ControlFlowNode , TStmtParent { }
146148
147149/**
148150 * A C/C++ 'expression' statement.
@@ -179,28 +181,32 @@ class ExprStmt extends Stmt, @stmt_expr {
179181 }
180182}
181183
184+ private class TControlStructure = TConditionalStmt or TLoop ;
185+
182186/**
183187 * A C/C++ control structure, that is, either a conditional statement or
184188 * a loop.
185189 */
186- abstract class ControlStructure extends Stmt {
190+ class ControlStructure extends Stmt , TControlStructure {
187191 /**
188192 * Gets the controlling expression of this control structure.
189193 *
190194 * This is the condition of 'if' statements and loops, and the
191195 * switched expression for 'switch' statements.
192196 */
193- abstract Expr getControllingExpr ( ) ;
197+ Expr getControllingExpr ( ) { none ( ) } // overridden by subclasses
194198
195199 /** Gets a child declaration of this scope. */
196200 Declaration getADeclaration ( ) { none ( ) }
197201}
198202
203+ private class TConditionalStmt = @stmt_if or @stmt_constexpr_if or @stmt_switch;
204+
199205/**
200206 * A C/C++ conditional statement, that is, either an 'if' statement or a
201207 * 'switch' statement.
202208 */
203- abstract class ConditionalStmt extends ControlStructure { }
209+ class ConditionalStmt extends ControlStructure , TConditionalStmt { }
204210
205211/**
206212 * A C/C++ 'if' statement. For example, the `if` statement in the following
@@ -374,16 +380,18 @@ class ConstexprIfStmt extends ConditionalStmt, @stmt_constexpr_if {
374380 }
375381}
376382
383+ private class TLoop = @stmt_while or @stmt_end_test_while or @stmt_range_based_for or @stmt_for;
384+
377385/**
378386 * A C/C++ loop, that is, either a 'while' loop, a 'for' loop, or a
379387 * 'do' loop.
380388 */
381- abstract class Loop extends ControlStructure {
389+ class Loop extends ControlStructure , TLoop {
382390 /** Gets the condition expression of this loop. */
383- abstract Expr getCondition ( ) ;
391+ Expr getCondition ( ) { none ( ) } // overridden in subclasses
384392
385393 /** Gets the body statement of this loop. */
386- abstract Stmt getStmt ( ) ;
394+ Stmt getStmt ( ) { none ( ) } // overridden in subclasses
387395}
388396
389397/**
@@ -461,7 +469,7 @@ class WhileStmt extends Loop, @stmt_while {
461469/**
462470 * A C/C++ jump statement.
463471 */
464- abstract class JumpStmt extends Stmt , @jump {
472+ class JumpStmt extends Stmt , @jump {
465473 override string getAPrimaryQlClass ( ) { result = "JumpStmt" }
466474
467475 /** Gets the target of this jump statement. */
0 commit comments