@@ -842,9 +842,7 @@ class TranslatedCatchAnyHandler extends TranslatedHandler {
842
842
}
843
843
}
844
844
845
- class TranslatedIfStmt extends TranslatedStmt , ConditionContext {
846
- override IfStmt stmt ;
847
-
845
+ abstract class TranslatedIfLikeStmt extends TranslatedStmt , ConditionContext {
848
846
override Instruction getFirstInstruction ( EdgeKind kind ) {
849
847
if this .hasInitialization ( )
850
848
then result = this .getInitialization ( ) .getFirstInstruction ( kind )
@@ -857,6 +855,8 @@ class TranslatedIfStmt extends TranslatedStmt, ConditionContext {
857
855
858
856
override TranslatedElement getLastChild ( ) { result = this .getElse ( ) or result = this .getThen ( ) }
859
857
858
+ override predicate handlesDestructorsExplicitly ( ) { any ( ) }
859
+
860
860
override TranslatedElement getChildInternal ( int id ) {
861
861
id = 0 and result = this .getInitialization ( )
862
862
or
@@ -867,25 +867,21 @@ class TranslatedIfStmt extends TranslatedStmt, ConditionContext {
867
867
id = 3 and result = this .getElse ( )
868
868
}
869
869
870
- private predicate hasInitialization ( ) { exists ( stmt . getInitialization ( ) ) }
870
+ abstract predicate hasInitialization ( ) ;
871
871
872
- private TranslatedStmt getInitialization ( ) {
873
- result = getTranslatedStmt ( stmt .getInitialization ( ) )
874
- }
872
+ abstract TranslatedStmt getInitialization ( ) ;
875
873
876
- private TranslatedCondition getCondition ( ) {
877
- result = getTranslatedCondition ( stmt .getCondition ( ) .getFullyConverted ( ) )
878
- }
874
+ abstract TranslatedCondition getCondition ( ) ;
879
875
880
876
private Instruction getFirstConditionInstruction ( EdgeKind kind ) {
881
877
result = this .getCondition ( ) .getFirstInstruction ( kind )
882
878
}
883
879
884
- private TranslatedStmt getThen ( ) { result = getTranslatedStmt ( stmt . getThen ( ) ) }
880
+ abstract TranslatedStmt getThen ( ) ;
885
881
886
- private TranslatedStmt getElse ( ) { result = getTranslatedStmt ( stmt . getElse ( ) ) }
882
+ abstract TranslatedStmt getElse ( ) ;
887
883
888
- private predicate hasElse ( ) { exists ( stmt . getElse ( ) ) }
884
+ abstract predicate hasElse ( ) ;
889
885
890
886
override Instruction getInstructionSuccessorInternal ( InstructionTag tag , EdgeKind kind ) { none ( ) }
891
887
@@ -898,92 +894,81 @@ class TranslatedIfStmt extends TranslatedStmt, ConditionContext {
898
894
child = this .getCondition ( ) and
899
895
if this .hasElse ( )
900
896
then result = this .getElse ( ) .getFirstInstruction ( kind )
901
- else result = this .getParent ( ) .getChildSuccessor ( this , kind )
897
+ else (
898
+ if this .hasAnImplicitDestructorCall ( )
899
+ then result = this .getChild ( this .getFirstDestructorCallIndex ( ) ) .getFirstInstruction ( kind )
900
+ else result = this .getParent ( ) .getChildSuccessor ( this , kind )
901
+ )
902
902
}
903
903
904
904
override Instruction getChildSuccessorInternal ( TranslatedElement child , EdgeKind kind ) {
905
905
child = this .getInitialization ( ) and
906
906
result = this .getFirstConditionInstruction ( kind )
907
907
or
908
908
( child = this .getThen ( ) or child = this .getElse ( ) ) and
909
- result = this .getParent ( ) .getChildSuccessor ( this , kind )
909
+ (
910
+ if this .hasAnImplicitDestructorCall ( )
911
+ then result = this .getChild ( this .getFirstDestructorCallIndex ( ) ) .getFirstInstruction ( kind )
912
+ else result = this .getParent ( ) .getChildSuccessor ( this , kind )
913
+ )
914
+ or
915
+ exists ( int destructorId |
916
+ destructorId >= this .getFirstDestructorCallIndex ( ) and
917
+ child = this .getChild ( destructorId ) and
918
+ result = this .getChild ( destructorId + 1 ) .getFirstInstruction ( kind )
919
+ )
920
+ or
921
+ exists ( int lastDestructorIndex |
922
+ lastDestructorIndex =
923
+ max ( int n | exists ( this .getChild ( n ) ) and n >= this .getFirstDestructorCallIndex ( ) ) and
924
+ child = this .getChild ( lastDestructorIndex ) and
925
+ result = this .getParent ( ) .getChildSuccessor ( this , kind )
926
+ )
910
927
}
911
928
912
929
override predicate hasInstruction ( Opcode opcode , InstructionTag tag , CppType resultType ) {
913
930
none ( )
914
931
}
915
932
}
916
933
917
- class TranslatedConstExprIfStmt extends TranslatedStmt , ConditionContext {
918
- override ConstexprIfStmt stmt ;
919
-
920
- override Instruction getFirstInstruction ( EdgeKind kind ) {
921
- if this .hasInitialization ( )
922
- then result = this .getInitialization ( ) .getFirstInstruction ( kind )
923
- else result = this .getFirstConditionInstruction ( kind )
924
- }
925
-
926
- override TranslatedElement getChildInternal ( int id ) {
927
- id = 0 and result = this .getInitialization ( )
928
- or
929
- id = 1 and result = this .getCondition ( )
930
- or
931
- id = 2 and result = this .getThen ( )
932
- or
933
- id = 3 and result = this .getElse ( )
934
- }
934
+ class TranslatedIfStmt extends TranslatedIfLikeStmt {
935
+ override IfStmt stmt ;
935
936
936
- private predicate hasInitialization ( ) { exists ( stmt .getInitialization ( ) ) }
937
+ override predicate hasInitialization ( ) { exists ( stmt .getInitialization ( ) ) }
937
938
938
- private TranslatedStmt getInitialization ( ) {
939
+ override TranslatedStmt getInitialization ( ) {
939
940
result = getTranslatedStmt ( stmt .getInitialization ( ) )
940
941
}
941
942
942
- private TranslatedCondition getCondition ( ) {
943
+ override TranslatedCondition getCondition ( ) {
943
944
result = getTranslatedCondition ( stmt .getCondition ( ) .getFullyConverted ( ) )
944
945
}
945
946
946
- private Instruction getFirstConditionInstruction ( EdgeKind kind ) {
947
- result = this .getCondition ( ) .getFirstInstruction ( kind )
948
- }
947
+ override TranslatedStmt getThen ( ) { result = getTranslatedStmt ( stmt .getThen ( ) ) }
949
948
950
- private TranslatedStmt getThen ( ) { result = getTranslatedStmt ( stmt .getThen ( ) ) }
949
+ override TranslatedStmt getElse ( ) { result = getTranslatedStmt ( stmt .getElse ( ) ) }
951
950
952
- private TranslatedStmt getElse ( ) { result = getTranslatedStmt ( stmt .getElse ( ) ) }
951
+ override predicate hasElse ( ) { exists ( stmt .getElse ( ) ) }
952
+ }
953
953
954
- private predicate hasElse ( ) { exists ( stmt .getElse ( ) ) }
954
+ class TranslatedConstExprIfStmt extends TranslatedIfLikeStmt {
955
+ override ConstexprIfStmt stmt ;
955
956
956
- override Instruction getInstructionSuccessorInternal ( InstructionTag tag , EdgeKind kind ) { none ( ) }
957
+ override predicate hasInitialization ( ) { exists ( stmt . getInitialization ( ) ) }
957
958
958
- override Instruction getChildTrueSuccessor ( TranslatedCondition child , EdgeKind kind ) {
959
- child = this .getCondition ( ) and
960
- result = this .getThen ( ) .getFirstInstruction ( kind )
959
+ override TranslatedStmt getInitialization ( ) {
960
+ result = getTranslatedStmt ( stmt .getInitialization ( ) )
961
961
}
962
962
963
- override Instruction getChildFalseSuccessor ( TranslatedCondition child , EdgeKind kind ) {
964
- child = this .getCondition ( ) and
965
- if this .hasElse ( )
966
- then result = this .getElse ( ) .getFirstInstruction ( kind )
967
- else result = this .getParent ( ) .getChildSuccessor ( this , kind )
963
+ override TranslatedCondition getCondition ( ) {
964
+ result = getTranslatedCondition ( stmt .getCondition ( ) .getFullyConverted ( ) )
968
965
}
969
966
970
- override Instruction getChildSuccessorInternal ( TranslatedElement child , EdgeKind kind ) {
971
- child = this .getInitialization ( ) and
972
- result = this .getFirstConditionInstruction ( kind )
973
- or
974
- ( child = this .getThen ( ) or child = this .getElse ( ) ) and
975
- result = this .getParent ( ) .getChildSuccessor ( this , kind )
976
- }
967
+ override TranslatedStmt getThen ( ) { result = getTranslatedStmt ( stmt .getThen ( ) ) }
977
968
978
- override predicate hasInstruction ( Opcode opcode , InstructionTag tag , CppType resultType ) {
979
- none ( )
980
- }
969
+ override TranslatedStmt getElse ( ) { result = getTranslatedStmt ( stmt .getElse ( ) ) }
981
970
982
- override Instruction getALastInstructionInternal ( ) {
983
- result = this .getThen ( ) .getALastInstruction ( )
984
- or
985
- result = this .getElse ( ) .getALastInstruction ( )
986
- }
971
+ override predicate hasElse ( ) { exists ( stmt .getElse ( ) ) }
987
972
}
988
973
989
974
abstract class TranslatedLoop extends TranslatedStmt , ConditionContext {
0 commit comments