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:
Vendored
+9
-10
@@ -344,25 +344,24 @@ digraph boundSmartcasts_kt {
|
||||
126 -> {127};
|
||||
|
||||
subgraph cluster_28 {
|
||||
color=red
|
||||
128 [label="Enter property" style="filled" fillcolor=red];
|
||||
129 [label="Access variable R|<local>/any|"];
|
||||
130 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
128 -> {129};
|
||||
129 -> {130};
|
||||
130 -> {133} [color=green];
|
||||
|
||||
subgraph cluster_29 {
|
||||
color=red
|
||||
131 [label="Enter class D" style="filled" fillcolor=red];
|
||||
132 [label="Part of class initialization"];
|
||||
subgraph cluster_29 {
|
||||
color=blue
|
||||
128 [label="Enter property" style="filled" fillcolor=red];
|
||||
129 [label="Access variable R|<local>/any|"];
|
||||
130 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
133 [label="Exit class D" style="filled" fillcolor=red];
|
||||
}
|
||||
131 -> {132} [color=green];
|
||||
132 -> {128} [color=green];
|
||||
132 -> {133} [style=dotted];
|
||||
132 -> {128} [style=dashed];
|
||||
128 -> {129};
|
||||
129 -> {130};
|
||||
130 -> {133} [color=green];
|
||||
|
||||
subgraph cluster_30 {
|
||||
color=red
|
||||
|
||||
+9
-10
@@ -13,25 +13,24 @@ digraph boundSmartcastsInBranches_kt {
|
||||
1 -> {2};
|
||||
|
||||
subgraph cluster_1 {
|
||||
color=red
|
||||
3 [label="Enter property" style="filled" fillcolor=red];
|
||||
4 [label="Const: String()"];
|
||||
5 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
3 -> {4};
|
||||
4 -> {5};
|
||||
5 -> {8} [color=green];
|
||||
|
||||
subgraph cluster_2 {
|
||||
color=red
|
||||
6 [label="Enter class A" style="filled" fillcolor=red];
|
||||
7 [label="Part of class initialization"];
|
||||
subgraph cluster_2 {
|
||||
color=blue
|
||||
3 [label="Enter property" style="filled" fillcolor=red];
|
||||
4 [label="Const: String()"];
|
||||
5 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
8 [label="Exit class A" style="filled" fillcolor=red];
|
||||
}
|
||||
6 -> {7} [color=green];
|
||||
7 -> {3} [color=green];
|
||||
7 -> {8} [style=dotted];
|
||||
7 -> {3} [style=dashed];
|
||||
3 -> {4};
|
||||
4 -> {5};
|
||||
5 -> {8} [color=green];
|
||||
|
||||
subgraph cluster_3 {
|
||||
color=red
|
||||
|
||||
Vendored
+9
-10
@@ -29,25 +29,24 @@ digraph functionCallBound_kt {
|
||||
6 -> {7};
|
||||
|
||||
subgraph cluster_3 {
|
||||
color=red
|
||||
8 [label="Enter property" style="filled" fillcolor=red];
|
||||
9 [label="Access variable R|<local>/data|"];
|
||||
10 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
8 -> {9};
|
||||
9 -> {10};
|
||||
10 -> {13} [color=green];
|
||||
|
||||
subgraph cluster_4 {
|
||||
color=red
|
||||
11 [label="Enter class Sub" style="filled" fillcolor=red];
|
||||
12 [label="Part of class initialization"];
|
||||
subgraph cluster_4 {
|
||||
color=blue
|
||||
8 [label="Enter property" style="filled" fillcolor=red];
|
||||
9 [label="Access variable R|<local>/data|"];
|
||||
10 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
13 [label="Exit class Sub" style="filled" fillcolor=red];
|
||||
}
|
||||
11 -> {12} [color=green];
|
||||
12 -> {8} [color=green];
|
||||
12 -> {13} [style=dotted];
|
||||
12 -> {8} [style=dashed];
|
||||
8 -> {9};
|
||||
9 -> {10};
|
||||
10 -> {13} [color=green];
|
||||
|
||||
subgraph cluster_5 {
|
||||
color=red
|
||||
|
||||
Reference in New Issue
Block a user