@@ -23,15 +23,6 @@ private import SideEffects
23
23
Element getRealParent ( Expr expr ) {
24
24
result = expr .getParentWithConversions ( )
25
25
or
26
- /*
27
- * exists(Stmt destructorParent, DestructorCall dc |
28
- * destructorParent.getAnImplicitDestructorCall() = dc and
29
- * dc.getQualifier() = expr and
30
- * result = dc
31
- * )
32
- * or
33
- */
34
-
35
26
result .( Destructor ) .getADestruction ( ) = expr
36
27
or
37
28
result .( Expr ) .getAnImplicitDestructorCall ( ) = expr
@@ -873,12 +864,18 @@ abstract class TranslatedElement extends TTranslatedElement {
873
864
/**
874
865
* Holds if this element has implicit destructor calls that should follow it.
875
866
*/
876
- predicate hasImplicitDestructorCalls ( ) { none ( ) }
867
+ predicate hasAnImplicitDestructorCall ( ) { none ( ) }
877
868
878
869
/**
870
+ * Gets the child index of the first destructor call that should be executed after this `TranslatedElement`
879
871
*/
880
872
int getFirstDestructorCallIndex ( ) { none ( ) }
881
873
874
+ /**
875
+ * Holds if this `TranslatedElement` includes any destructor calls that must be performed after
876
+ * it in its `getChildSuccessorInternal`, `getInstructionSuccessorInternal`, and
877
+ * `getALastInstructionInternal` relations, rather than needing them inserted.
878
+ */
882
879
predicate handlesDestructorsExplicitly ( ) { none ( ) }
883
880
884
881
private int getUniqueId ( ) {
@@ -916,42 +913,65 @@ abstract class TranslatedElement extends TTranslatedElement {
916
913
/**
917
914
* Gets the successor instruction of the instruction that was generated by
918
915
* this element for tag `tag`. The successor edge kind is specified by `kind`.
916
+ * This predicate does not usually include destructors, which are inserted as
917
+ * part of `getInstructionSuccessor` unless `handlesDestructorsExplicitly`
918
+ * holds.
919
919
*/
920
920
abstract Instruction getInstructionSuccessorInternal ( InstructionTag tag , EdgeKind kind ) ;
921
-
922
- Instruction getInstructionSuccessor ( InstructionTag tag , EdgeKind kind ) {
921
+ /**
922
+ * Gets the successor instruction of the instruction that was generated by
923
+ * this element for tag `tag`. The successor edge kind is specified by `kind`.
924
+ */
925
+ final Instruction getInstructionSuccessor ( InstructionTag tag , EdgeKind kind ) {
923
926
if
924
- this .hasImplicitDestructorCalls ( ) and
925
- this .getInstruction ( tag ) = this .getLastInstructionInternal ( ) and
927
+ this .hasAnImplicitDestructorCall ( ) and
928
+ this .getInstruction ( tag ) = this .getALastInstructionInternal ( ) and
926
929
not this .handlesDestructorsExplicitly ( )
927
930
then
928
931
result = this .getChild ( this .getFirstDestructorCallIndex ( ) ) .getFirstInstruction ( kind ) and
929
932
kind instanceof GotoEdge
930
933
else result = this .getInstructionSuccessorInternal ( tag , kind )
931
934
}
932
935
933
- final Instruction getLastInstruction ( ) {
934
- if this .hasImplicitDestructorCalls ( ) and not this .handlesDestructorsExplicitly ( )
935
- then result = this .getChild ( max ( int n | exists ( this .getChild ( n ) ) ) ) .getLastInstruction ( ) // last destructor
936
- else result = this .getLastInstructionInternal ( )
936
+ /**
937
+ * Gets an instruction within this `TranslatedElement` (including its transitive children) which
938
+ * will be followed by an instruction outside the `TranslatedElement`.
939
+ */
940
+ final Instruction getALastInstruction ( ) {
941
+ if this .hasAnImplicitDestructorCall ( ) and not this .handlesDestructorsExplicitly ( )
942
+ then result = this .getChild ( max ( int n | exists ( this .getChild ( n ) ) ) ) .getALastInstruction ( ) // last destructor
943
+ else result = this .getALastInstructionInternal ( )
937
944
}
938
945
939
- abstract Instruction getLastInstructionInternal ( ) ;
946
+ /**
947
+ * Gets an instruction within this `TranslatedElement` (including its transitive children) which
948
+ * will be followed by an instruction outside the `TranslatedElement`.
949
+ * This predicate does not usually include destructors, which are inserted as
950
+ * part of `getALastInstruction` unless `handlesDestructorsExplicitly` holds.
951
+ */
952
+ abstract Instruction getALastInstructionInternal ( ) ;
940
953
941
954
TranslatedElement getLastChild ( ) { none ( ) }
942
955
943
956
/**
944
957
* Gets the successor instruction to which control should flow after the
945
958
* child element specified by `child` has finished execution. The successor
946
959
* edge kind is specified by `kind`.
960
+ * This predicate does not usually include destructors, which are inserted as
961
+ * part of `getChildSuccessor` unless `handlesDestructorsExplicitly` holds.
947
962
*/
948
963
Instruction getChildSuccessorInternal ( TranslatedElement child , EdgeKind kind ) { none ( ) }
949
964
950
- Instruction getChildSuccessor ( TranslatedElement child , EdgeKind kind ) {
965
+ /**
966
+ * Gets the successor instruction to which control should flow after the
967
+ * child element specified by `child` has finished execution. The successor
968
+ * edge kind is specified by `kind`.
969
+ */
970
+ final Instruction getChildSuccessor ( TranslatedElement child , EdgeKind kind ) {
951
971
(
952
972
if
953
973
// this is the last child and we need to handle destructors for it
954
- this .hasImplicitDestructorCalls ( ) and
974
+ this .hasAnImplicitDestructorCall ( ) and
955
975
not this .handlesDestructorsExplicitly ( ) and
956
976
child = this .getLastChild ( )
957
977
then result = this .getChild ( this .getFirstDestructorCallIndex ( ) ) .getFirstInstruction ( kind )
0 commit comments