Skip to content

Commit fa604a3

Browse files
committed
C++: Some tidyups following review comments
1 parent 896e64b commit fa604a3

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

cpp/ql/src/semmle/code/cpp/controlflow/internal/CFG.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ private predicate subEdgeIncludingDestructors(Pos p1, Node n1, Node n2, Pos p2)
981981
// called, connect the "before destructors" node directly to the "after
982982
// destructors" node. For performance, only do this when the nodes exist.
983983
exists(Pos afterDtors | afterDtors.isAfterDestructors() | subEdge(afterDtors, n1, _, _)) and
984-
not synthetic_destructor_call(n1, 0, _) and
984+
not exists(getSynthesisedDestructorCallAfterNode(n1, 0)) and
985985
p1.nodeBeforeDestructors(n1, n1) and
986986
p2.nodeAfterDestructors(n2, n1)
987987
or
@@ -990,12 +990,12 @@ private predicate subEdgeIncludingDestructors(Pos p1, Node n1, Node n2, Pos p2)
990990
exists(int maxCallIndex |
991991
maxCallIndex = max(int i | exists(getSynthesisedDestructorCallAfterNode(n, i))) and
992992
p1.nodeBeforeDestructors(n1, n) and
993-
p2.nodeAt(n2, getSynthesisedDestructorCallVariableAccessAfterNode(n, maxCallIndex)))
993+
p2.nodeAt(n2, getSynthesisedDestructorCallAfterNode(n, maxCallIndex).getQualifier()))
994994
or
995995
// call(i+1) -> access(i)
996996
exists(int i |
997997
p1.nodeAt(n1, getSynthesisedDestructorCallAfterNode(n, i + 1)) and
998-
p2.nodeAt(n2, getSynthesisedDestructorCallVariableAccessAfterNode(n, i))
998+
p2.nodeAt(n2, getSynthesisedDestructorCallAfterNode(n, i).getQualifier())
999999
)
10001000
or
10011001
// call(0) -> after destructors end
@@ -1005,9 +1005,13 @@ private predicate subEdgeIncludingDestructors(Pos p1, Node n1, Node n2, Pos p2)
10051005
}
10061006

10071007
/**
1008-
* Gets the `index`'th synthetic destructor call that should follow `node`. The
1009-
* exact placement of that call in the CFG depends on the type of `node` as
1010-
* follows:
1008+
* Gets the synthetic constructor call for the `index`'th entity that
1009+
* should be destructed following `node`. Note that entities should be
1010+
* destructed in reverse construction order, so these should be called
1011+
* from highest to lowest index.
1012+
*
1013+
* The exact placement of that call in the CFG depends on the type of
1014+
* `node` as follows:
10111015
*
10121016
* - `Block`: after ordinary control flow falls off the end of the block
10131017
* without jumps or exceptions.
@@ -1036,10 +1040,6 @@ DestructorCall getSynthesisedDestructorCallAfterNode(Node n, int i) {
10361040
synthetic_destructor_call(n, i, result)
10371041
}
10381042

1039-
VariableAccess getSynthesisedDestructorCallVariableAccessAfterNode(Node n, int i) {
1040-
result = getSynthesisedDestructorCallAfterNode(n, i).getChild(-1)
1041-
}
1042-
10431043
/**
10441044
* An expression whose outgoing true/false sub-edges may come from different
10451045
* sub-nodes.

cpp/ql/src/semmlecode.cpp.dbscheme

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,12 @@ exprconv(
10481048

10491049
compgenerated(unique int id: @element ref);
10501050

1051+
/**
1052+
* `destructor_call` destructs the `i`'th entity that should be
1053+
* destructed following `element`. Note that entities should be
1054+
* destructed in reverse construction order, so for a given `element`
1055+
* these should be called from highest to lowest `i`.
1056+
*/
10511057
synthetic_destructor_call(
10521058
int element: @element ref,
10531059
int i: int ref,

0 commit comments

Comments
 (0)