C#: Fix bug in getEnclosingCallable

This commit is contained in:
Tom Hvitved
2021-11-24 13:43:00 +01:00
parent f85fa87f69
commit 1d1780b30f
2 changed files with 4 additions and 8 deletions

View File

@@ -140,7 +140,9 @@ private module Cached {
}
private Expr getAChildExpr(ExprOrStmtParent parent) {
result = parent.getAChildExpr() or
result = parent.getAChildExpr() and
not result = parent.(DeclarationWithGetSetAccessors).getExpressionBody()
or
result = parent.(AssignOperation).getExpandedAssignment()
}
@@ -159,7 +161,7 @@ private module Cached {
private predicate parent(ControlFlowElement child, ExprOrStmtParent parent) {
child = getAChild(parent) and
not child instanceof Callable
not child = any(Callable c).getBody()
}
/** Holds if the enclosing body of `cfe` is `body`. */

View File

@@ -4882,17 +4882,11 @@ nodeEnclosing
| cflow.cs:306:60:310:5 | exit get__getter | cflow.cs:306:60:310:5 | get__getter |
| cflow.cs:306:60:310:5 | exit get__getter (normal) | cflow.cs:306:60:310:5 | get__getter |
| cflow.cs:307:5:310:5 | {...} | cflow.cs:306:60:310:5 | (...) => ... |
| cflow.cs:307:5:310:5 | {...} | cflow.cs:306:60:310:5 | get__getter |
| cflow.cs:308:9:308:21 | ... ...; | cflow.cs:306:60:310:5 | (...) => ... |
| cflow.cs:308:9:308:21 | ... ...; | cflow.cs:306:60:310:5 | get__getter |
| cflow.cs:308:16:308:20 | Object x = ... | cflow.cs:306:60:310:5 | (...) => ... |
| cflow.cs:308:16:308:20 | Object x = ... | cflow.cs:306:60:310:5 | get__getter |
| cflow.cs:308:20:308:20 | access to parameter o | cflow.cs:306:60:310:5 | (...) => ... |
| cflow.cs:308:20:308:20 | access to parameter o | cflow.cs:306:60:310:5 | get__getter |
| cflow.cs:309:9:309:17 | return ...; | cflow.cs:306:60:310:5 | (...) => ... |
| cflow.cs:309:9:309:17 | return ...; | cflow.cs:306:60:310:5 | get__getter |
| cflow.cs:309:16:309:16 | access to local variable x | cflow.cs:306:60:310:5 | (...) => ... |
| cflow.cs:309:16:309:16 | access to local variable x | cflow.cs:306:60:310:5 | get__getter |
blockEnclosing
| AccessorCalls.cs:5:23:5:25 | enter get_Item | AccessorCalls.cs:5:23:5:25 | get_Item |
| AccessorCalls.cs:5:33:5:35 | enter set_Item | AccessorCalls.cs:5:33:5:35 | set_Item |