@@ -1276,6 +1276,11 @@ class TranslatedJumpStmt extends TranslatedStmt {
1276
1276
override JumpStmt stmt ;
1277
1277
1278
1278
override Instruction getFirstInstruction ( EdgeKind kind ) {
1279
+ // The first instruction is a destructor call, if any.
1280
+ result = this .getChildInternal ( 0 ) .getFirstInstruction ( kind )
1281
+ or
1282
+ // Otherwise, the first (and only) instruction is a `NoOp`
1283
+ not exists ( this .getChildInternal ( 0 ) ) and
1279
1284
result = this .getInstruction ( OnlyInstructionTag ( ) ) and
1280
1285
kind instanceof GotoEdge
1281
1286
}
@@ -1284,7 +1289,20 @@ class TranslatedJumpStmt extends TranslatedStmt {
1284
1289
result = this .getInstruction ( OnlyInstructionTag ( ) )
1285
1290
}
1286
1291
1287
- override TranslatedElement getChildInternal ( int id ) { none ( ) }
1292
+ private TranslatedCall getTranslatedImplicitDestructorCall ( int id ) {
1293
+ result .getExpr ( ) = stmt .getImplicitDestructorCall ( id )
1294
+ }
1295
+
1296
+ override TranslatedElement getLastChild ( ) {
1297
+ result =
1298
+ this .getTranslatedImplicitDestructorCall ( max ( int id |
1299
+ exists ( stmt .getImplicitDestructorCall ( id ) )
1300
+ ) )
1301
+ }
1302
+
1303
+ override TranslatedElement getChildInternal ( int id ) {
1304
+ result = this .getTranslatedImplicitDestructorCall ( id )
1305
+ }
1288
1306
1289
1307
override predicate hasInstruction ( Opcode opcode , InstructionTag tag , CppType resultType ) {
1290
1308
tag = OnlyInstructionTag ( ) and
@@ -1297,7 +1315,19 @@ class TranslatedJumpStmt extends TranslatedStmt {
1297
1315
result = getTranslatedStmt ( stmt .getTarget ( ) ) .getFirstInstruction ( kind )
1298
1316
}
1299
1317
1300
- override Instruction getChildSuccessorInternal ( TranslatedElement child , EdgeKind kind ) { none ( ) }
1318
+ final override predicate handlesDestructorsExplicitly ( ) { any ( ) }
1319
+
1320
+ override Instruction getChildSuccessorInternal ( TranslatedElement child , EdgeKind kind ) {
1321
+ exists ( int id | child = this .getChildInternal ( id ) |
1322
+ // Transition to the next destructor call, if any.
1323
+ result = this .getChildInternal ( id + 1 ) .getFirstInstruction ( kind )
1324
+ or
1325
+ // And otherwise, exit this element by flowing to the target of the jump.
1326
+ not exists ( this .getChildInternal ( id + 1 ) ) and
1327
+ kind instanceof GotoEdge and
1328
+ result = this .getInstruction ( OnlyInstructionTag ( ) )
1329
+ )
1330
+ }
1301
1331
}
1302
1332
1303
1333
private EdgeKind getCaseEdge ( SwitchCase switchCase ) {
0 commit comments