C#: Base the getAPostUpdateNote predicate purely on cfg.

This commit is contained in:
Michael Nebel
2022-09-28 13:46:19 +02:00
parent c07c10a808
commit a36bba94f1
2 changed files with 7 additions and 6 deletions

View File

@@ -35,7 +35,7 @@ private class MyConsistencyConfiguration extends ConsistencyConfiguration {
override predicate argHasPostUpdateExclude(ArgumentNode n) {
n instanceof SummaryNode
or
not exists(LocalFlow::getAPostUpdateNodeForArg(n.asExpr()))
not exists(LocalFlow::getAPostUpdateNodeForArg(n.getControlFlowNode()))
or
n instanceof ImplicitCapturedArgumentNode
or
@@ -46,7 +46,7 @@ private class MyConsistencyConfiguration extends ConsistencyConfiguration {
override predicate postHasUniquePreExclude(PostUpdateNode n) {
exists(ControlFlow::Nodes::ExprNode e, ControlFlow::Nodes::ExprNode arg |
e = LocalFlow::getAPostUpdateNodeForArg(arg.getExpr()) and
e = LocalFlow::getAPostUpdateNodeForArg(arg) and
e != arg and
n = TExprPostUpdateNode(e)
)
@@ -54,7 +54,7 @@ private class MyConsistencyConfiguration extends ConsistencyConfiguration {
override predicate uniquePostUpdateExclude(Node n) {
exists(ControlFlow::Nodes::ExprNode e, ControlFlow::Nodes::ExprNode arg |
e = LocalFlow::getAPostUpdateNodeForArg(arg.getExpr()) and
e = LocalFlow::getAPostUpdateNodeForArg(arg) and
e != arg and
n.asExpr() = arg.getExpr()
)

View File

@@ -420,8 +420,9 @@ module LocalFlow {
}
/** Gets a node for which to construct a post-update node for argument `arg`. */
ControlFlow::Nodes::ExprNode getAPostUpdateNodeForArg(Argument arg) {
result = getALastEvalNode*(arg.getAControlFlowNode()) and
ControlFlow::Nodes::ExprNode getAPostUpdateNodeForArg(ControlFlow::Nodes::ExprNode arg) {
arg.getExpr() instanceof Argument and
result = getALastEvalNode*(arg) and
exists(Expr e | result.getExpr() = e |
exists(Type t | t = e.stripCasts().getType() |
t instanceof RefType and
@@ -1946,7 +1947,7 @@ private module PostUpdateNodes {
//
// This ensures that we get flow out of the call into both leafs (1), while still
// maintaining the invariant that the underlying expression is a pre-update node (2).
cfn = LocalFlow::getAPostUpdateNodeForArg(result.asExpr())
cfn = LocalFlow::getAPostUpdateNodeForArg(result.getControlFlowNode())
or
cfn = result.getControlFlowNode()
}