@@ -137,12 +137,14 @@ class Stmt extends StmtParent, @stmt {
137
137
predicate isCompilerGenerated ( ) { compgenerated ( underlyingElement ( this ) ) }
138
138
}
139
139
140
+ private class TStmtParent = @stmt or @expr;
141
+
140
142
/**
141
143
* An element that is the parent of a statement in the C/C++ AST.
142
144
*
143
145
* This is normally a statement, but may be a `StmtExpr`.
144
146
*/
145
- abstract class StmtParent extends ControlFlowNode { }
147
+ class StmtParent extends ControlFlowNode , TStmtParent { }
146
148
147
149
/**
148
150
* A C/C++ 'expression' statement.
@@ -179,28 +181,32 @@ class ExprStmt extends Stmt, @stmt_expr {
179
181
}
180
182
}
181
183
184
+ private class TControlStructure = TConditionalStmt or TLoop ;
185
+
182
186
/**
183
187
* A C/C++ control structure, that is, either a conditional statement or
184
188
* a loop.
185
189
*/
186
- abstract class ControlStructure extends Stmt {
190
+ class ControlStructure extends Stmt , TControlStructure {
187
191
/**
188
192
* Gets the controlling expression of this control structure.
189
193
*
190
194
* This is the condition of 'if' statements and loops, and the
191
195
* switched expression for 'switch' statements.
192
196
*/
193
- abstract Expr getControllingExpr ( ) ;
197
+ Expr getControllingExpr ( ) { none ( ) } // overridden by subclasses
194
198
195
199
/** Gets a child declaration of this scope. */
196
200
Declaration getADeclaration ( ) { none ( ) }
197
201
}
198
202
203
+ private class TConditionalStmt = @stmt_if or @stmt_constexpr_if or @stmt_switch;
204
+
199
205
/**
200
206
* A C/C++ conditional statement, that is, either an 'if' statement or a
201
207
* 'switch' statement.
202
208
*/
203
- abstract class ConditionalStmt extends ControlStructure { }
209
+ class ConditionalStmt extends ControlStructure , TConditionalStmt { }
204
210
205
211
/**
206
212
* A C/C++ 'if' statement. For example, the `if` statement in the following
@@ -374,16 +380,18 @@ class ConstexprIfStmt extends ConditionalStmt, @stmt_constexpr_if {
374
380
}
375
381
}
376
382
383
+ private class TLoop = @stmt_while or @stmt_end_test_while or @stmt_range_based_for or @stmt_for;
384
+
377
385
/**
378
386
* A C/C++ loop, that is, either a 'while' loop, a 'for' loop, or a
379
387
* 'do' loop.
380
388
*/
381
- abstract class Loop extends ControlStructure {
389
+ class Loop extends ControlStructure , TLoop {
382
390
/** Gets the condition expression of this loop. */
383
- abstract Expr getCondition ( ) ;
391
+ Expr getCondition ( ) { none ( ) } // overridden in subclasses
384
392
385
393
/** Gets the body statement of this loop. */
386
- abstract Stmt getStmt ( ) ;
394
+ Stmt getStmt ( ) { none ( ) } // overridden in subclasses
387
395
}
388
396
389
397
/**
@@ -461,7 +469,7 @@ class WhileStmt extends Loop, @stmt_while {
461
469
/**
462
470
* A C/C++ jump statement.
463
471
*/
464
- abstract class JumpStmt extends Stmt , @jump {
472
+ class JumpStmt extends Stmt , @jump {
465
473
override string getAPrimaryQlClass ( ) { result = "JumpStmt" }
466
474
467
475
/** Gets the target of this jump statement. */
0 commit comments