FIR CFA: properly visit subgraphs in checkers
Interpretation: a graph A is a subgraph of B if information available at nodes of A depends on the paths taken in B. For example, local classes are subgraphs of a graph in which they are declared, and members of those classes are subgraphs of the local class itself - because these members can reference captured values. Consequences: * if graph G is a subgraph of node N, then G is a subgraph of N's owner; * `ControlFlowAnalysisDiagnosticComponent` will only visit root graphs; * `graph.traverse` will ignore subgraph boundaries, as if all subgraphs are inlined into one huge root graph; * if a control flow checker needs information from a declaration to which a graph is attached, it must look at subgraphs explicitly. For example, consider the `callsInPlace` checker. When a function has a `callsInPlace` contract and a local declaration, the checker must visit that local declaration to ensure it does not capture the allegedly called-in-place argument - hence `graph.traverse` will look at the nodes. However, the local declaration can also be a function with its own `callsInPlace` contracts, so the checker should also run for it in isolation. If that sounds quadratic, that's because unfortunately it is.
This commit is contained in:
@@ -62,19 +62,9 @@ digraph nullability_kt {
|
||||
15 -> {16};
|
||||
|
||||
subgraph cluster_8 {
|
||||
color=red
|
||||
17 [label="Enter property" style="filled" fillcolor=red];
|
||||
18 [label="Access variable R|<local>/data|"];
|
||||
19 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
17 -> {18};
|
||||
18 -> {19};
|
||||
19 -> {29} [color=green];
|
||||
|
||||
subgraph cluster_9 {
|
||||
color=red
|
||||
20 [label="Enter function fdata" style="filled" fillcolor=red];
|
||||
subgraph cluster_10 {
|
||||
subgraph cluster_9 {
|
||||
color=blue
|
||||
21 [label="Enter block"];
|
||||
22 [label="Const: Null(null)"];
|
||||
@@ -92,16 +82,25 @@ digraph nullability_kt {
|
||||
24 -> {25} [style=dotted];
|
||||
25 -> {26} [style=dotted];
|
||||
|
||||
subgraph cluster_11 {
|
||||
subgraph cluster_10 {
|
||||
color=red
|
||||
27 [label="Enter class QImpl" style="filled" fillcolor=red];
|
||||
28 [label="Part of class initialization"];
|
||||
subgraph cluster_11 {
|
||||
color=blue
|
||||
17 [label="Enter property" style="filled" fillcolor=red];
|
||||
18 [label="Access variable R|<local>/data|"];
|
||||
19 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
29 [label="Exit class QImpl" style="filled" fillcolor=red];
|
||||
}
|
||||
27 -> {28} [color=green];
|
||||
28 -> {17} [color=green];
|
||||
28 -> {29} [style=dotted];
|
||||
28 -> {17} [style=dashed];
|
||||
17 -> {18};
|
||||
18 -> {19};
|
||||
19 -> {29} [color=green];
|
||||
|
||||
subgraph cluster_12 {
|
||||
color=red
|
||||
@@ -113,19 +112,9 @@ digraph nullability_kt {
|
||||
31 -> {32};
|
||||
|
||||
subgraph cluster_13 {
|
||||
color=red
|
||||
33 [label="Enter property" style="filled" fillcolor=red];
|
||||
34 [label="Access variable R|<local>/data|"];
|
||||
35 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
33 -> {34};
|
||||
34 -> {35};
|
||||
35 -> {45} [color=green];
|
||||
|
||||
subgraph cluster_14 {
|
||||
color=red
|
||||
36 [label="Enter function fdata" style="filled" fillcolor=red];
|
||||
subgraph cluster_15 {
|
||||
subgraph cluster_14 {
|
||||
color=blue
|
||||
37 [label="Enter block"];
|
||||
38 [label="Const: Null(null)"];
|
||||
@@ -143,16 +132,25 @@ digraph nullability_kt {
|
||||
40 -> {41} [style=dotted];
|
||||
41 -> {42} [style=dotted];
|
||||
|
||||
subgraph cluster_16 {
|
||||
subgraph cluster_15 {
|
||||
color=red
|
||||
43 [label="Enter class QImplMutable" style="filled" fillcolor=red];
|
||||
44 [label="Part of class initialization"];
|
||||
subgraph cluster_16 {
|
||||
color=blue
|
||||
33 [label="Enter property" style="filled" fillcolor=red];
|
||||
34 [label="Access variable R|<local>/data|"];
|
||||
35 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
45 [label="Exit class QImplMutable" style="filled" fillcolor=red];
|
||||
}
|
||||
43 -> {44} [color=green];
|
||||
44 -> {33} [color=green];
|
||||
44 -> {45} [style=dotted];
|
||||
44 -> {33} [style=dashed];
|
||||
33 -> {34};
|
||||
34 -> {35};
|
||||
35 -> {45} [color=green];
|
||||
|
||||
subgraph cluster_17 {
|
||||
color=red
|
||||
|
||||
Reference in New Issue
Block a user