mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
C#: Base the getAPostUpdateNote predicate purely on cfg.
This commit is contained in:
@@ -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()
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user