@@ -23,15 +23,6 @@ private import SideEffects
2323Element getRealParent ( Expr expr ) {
2424 result = expr .getParentWithConversions ( )
2525 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-
3526 result .( Destructor ) .getADestruction ( ) = expr
3627 or
3728 result .( Expr ) .getAnImplicitDestructorCall ( ) = expr
@@ -873,12 +864,18 @@ abstract class TranslatedElement extends TTranslatedElement {
873864 /**
874865 * Holds if this element has implicit destructor calls that should follow it.
875866 */
876- predicate hasImplicitDestructorCalls ( ) { none ( ) }
867+ predicate hasAnImplicitDestructorCall ( ) { none ( ) }
877868
878869 /**
870+ * Gets the child index of the first destructor call that should be executed after this `TranslatedElement`
879871 */
880872 int getFirstDestructorCallIndex ( ) { none ( ) }
881873
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+ */
882879 predicate handlesDestructorsExplicitly ( ) { none ( ) }
883880
884881 private int getUniqueId ( ) {
@@ -916,42 +913,65 @@ abstract class TranslatedElement extends TTranslatedElement {
916913 /**
917914 * Gets the successor instruction of the instruction that was generated by
918915 * 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.
919919 */
920920 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 ) {
923926 if
924- this .hasImplicitDestructorCalls ( ) and
925- this .getInstruction ( tag ) = this .getLastInstructionInternal ( ) and
927+ this .hasAnImplicitDestructorCall ( ) and
928+ this .getInstruction ( tag ) = this .getALastInstructionInternal ( ) and
926929 not this .handlesDestructorsExplicitly ( )
927930 then
928931 result = this .getChild ( this .getFirstDestructorCallIndex ( ) ) .getFirstInstruction ( kind ) and
929932 kind instanceof GotoEdge
930933 else result = this .getInstructionSuccessorInternal ( tag , kind )
931934 }
932935
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 ( )
937944 }
938945
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 ( ) ;
940953
941954 TranslatedElement getLastChild ( ) { none ( ) }
942955
943956 /**
944957 * Gets the successor instruction to which control should flow after the
945958 * child element specified by `child` has finished execution. The successor
946959 * 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.
947962 */
948963 Instruction getChildSuccessorInternal ( TranslatedElement child , EdgeKind kind ) { none ( ) }
949964
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 ) {
951971 (
952972 if
953973 // this is the last child and we need to handle destructors for it
954- this .hasImplicitDestructorCalls ( ) and
974+ this .hasAnImplicitDestructorCall ( ) and
955975 not this .handlesDestructorsExplicitly ( ) and
956976 child = this .getLastChild ( )
957977 then result = this .getChild ( this .getFirstDestructorCallIndex ( ) ) .getFirstInstruction ( kind )
0 commit comments