C++: Some tidyups following review comments

This commit is contained in:
Ian Lynagh
2019-06-07 11:34:55 +01:00
parent 896e64b987
commit fa604a393b
2 changed files with 16 additions and 10 deletions

View File

@@ -981,7 +981,7 @@ private predicate subEdgeIncludingDestructors(Pos p1, Node n1, Node n2, Pos p2)
// called, connect the "before destructors" node directly to the "after
// destructors" node. For performance, only do this when the nodes exist.
exists(Pos afterDtors | afterDtors.isAfterDestructors() | subEdge(afterDtors, n1, _, _)) and
not synthetic_destructor_call(n1, 0, _) and
not exists(getSynthesisedDestructorCallAfterNode(n1, 0)) and
p1.nodeBeforeDestructors(n1, n1) and
p2.nodeAfterDestructors(n2, n1)
or
@@ -990,12 +990,12 @@ private predicate subEdgeIncludingDestructors(Pos p1, Node n1, Node n2, Pos p2)
exists(int maxCallIndex |
maxCallIndex = max(int i | exists(getSynthesisedDestructorCallAfterNode(n, i))) and
p1.nodeBeforeDestructors(n1, n) and
p2.nodeAt(n2, getSynthesisedDestructorCallVariableAccessAfterNode(n, maxCallIndex)))
p2.nodeAt(n2, getSynthesisedDestructorCallAfterNode(n, maxCallIndex).getQualifier()))
or
// call(i+1) -> access(i)
exists(int i |
p1.nodeAt(n1, getSynthesisedDestructorCallAfterNode(n, i + 1)) and
p2.nodeAt(n2, getSynthesisedDestructorCallVariableAccessAfterNode(n, i))
p2.nodeAt(n2, getSynthesisedDestructorCallAfterNode(n, i).getQualifier())
)
or
// call(0) -> after destructors end
@@ -1005,9 +1005,13 @@ private predicate subEdgeIncludingDestructors(Pos p1, Node n1, Node n2, Pos p2)
}
/**
* Gets the `index`'th synthetic destructor call that should follow `node`. The
* exact placement of that call in the CFG depends on the type of `node` as
* follows:
* Gets the synthetic constructor call for the `index`'th entity that
* should be destructed following `node`. Note that entities should be
* destructed in reverse construction order, so these should be called
* from highest to lowest index.
*
* The exact placement of that call in the CFG depends on the type of
* `node` as follows:
*
* - `Block`: after ordinary control flow falls off the end of the block
* without jumps or exceptions.
@@ -1036,10 +1040,6 @@ DestructorCall getSynthesisedDestructorCallAfterNode(Node n, int i) {
synthetic_destructor_call(n, i, result)
}
VariableAccess getSynthesisedDestructorCallVariableAccessAfterNode(Node n, int i) {
result = getSynthesisedDestructorCallAfterNode(n, i).getChild(-1)
}
/**
* An expression whose outgoing true/false sub-edges may come from different
* sub-nodes.

View File

@@ -1048,6 +1048,12 @@ exprconv(
compgenerated(unique int id: @element ref);
/**
* `destructor_call` destructs the `i`'th entity that should be
* destructed following `element`. Note that entities should be
* destructed in reverse construction order, so for a given `element`
* these should be called from highest to lowest `i`.
*/
synthetic_destructor_call(
int element: @element ref,
int i: int ref,