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
+84
-88
@@ -83,64 +83,9 @@ digraph delegateWithAnonymousObject_kt {
|
||||
24 -> {25};
|
||||
|
||||
subgraph cluster_9 {
|
||||
color=red
|
||||
35 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
36 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
||||
37 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
35 -> {36};
|
||||
36 -> {37};
|
||||
|
||||
subgraph cluster_10 {
|
||||
color=red
|
||||
38 [label="Enter function getValue" style="filled" fillcolor=red];
|
||||
subgraph cluster_11 {
|
||||
color=blue
|
||||
39 [label="Enter block"];
|
||||
40 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow];
|
||||
41 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"];
|
||||
42 [label="Stub" style="filled" fillcolor=gray];
|
||||
43 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
44 [label="Exit function getValue" style="filled" fillcolor=red];
|
||||
}
|
||||
38 -> {39};
|
||||
39 -> {40};
|
||||
40 -> {41};
|
||||
41 -> {44};
|
||||
41 -> {42} [style=dotted];
|
||||
42 -> {43} [style=dotted];
|
||||
43 -> {44} [style=dotted];
|
||||
|
||||
subgraph cluster_12 {
|
||||
color=red
|
||||
45 [label="Enter function setValue" style="filled" fillcolor=red];
|
||||
subgraph cluster_13 {
|
||||
color=blue
|
||||
46 [label="Enter block"];
|
||||
47 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow];
|
||||
48 [label="Access variable R|<local>/value|"];
|
||||
49 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)" style="filled" fillcolor=yellow];
|
||||
50 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|<local>/value|)"];
|
||||
51 [label="Stub" style="filled" fillcolor=gray];
|
||||
52 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
53 [label="Exit function setValue" style="filled" fillcolor=red];
|
||||
}
|
||||
45 -> {46};
|
||||
46 -> {47};
|
||||
47 -> {48};
|
||||
48 -> {49};
|
||||
49 -> {50};
|
||||
50 -> {53};
|
||||
50 -> {51} [style=dotted];
|
||||
51 -> {52} [style=dotted];
|
||||
52 -> {53} [style=dotted];
|
||||
|
||||
subgraph cluster_14 {
|
||||
color=red
|
||||
54 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
subgraph cluster_15 {
|
||||
subgraph cluster_10 {
|
||||
color=blue
|
||||
55 [label="Enter block"];
|
||||
56 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
|
||||
@@ -162,10 +107,10 @@ digraph delegateWithAnonymousObject_kt {
|
||||
60 -> {61} [style=dotted];
|
||||
61 -> {62} [style=dotted];
|
||||
|
||||
subgraph cluster_16 {
|
||||
subgraph cluster_11 {
|
||||
color=red
|
||||
63 [label="Enter function setter" style="filled" fillcolor=red];
|
||||
subgraph cluster_17 {
|
||||
subgraph cluster_12 {
|
||||
color=blue
|
||||
64 [label="Enter block"];
|
||||
65 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
|
||||
@@ -184,35 +129,79 @@ digraph delegateWithAnonymousObject_kt {
|
||||
68 -> {69};
|
||||
69 -> {70};
|
||||
|
||||
subgraph cluster_18 {
|
||||
subgraph cluster_13 {
|
||||
color=red
|
||||
71 [label="Enter property" style="filled" fillcolor=red];
|
||||
72 [label="Postponed enter to lambda"];
|
||||
subgraph cluster_19 {
|
||||
79 [label="Enter class IssuesListUserProfile" style="filled" fillcolor=red];
|
||||
80 [label="Part of class initialization"];
|
||||
subgraph cluster_14 {
|
||||
color=blue
|
||||
26 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||
71 [label="Enter property" style="filled" fillcolor=red];
|
||||
72 [label="Postponed enter to lambda"];
|
||||
subgraph cluster_15 {
|
||||
color=blue
|
||||
26 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||
subgraph cluster_16 {
|
||||
color=blue
|
||||
27 [label="Enter block"];
|
||||
28 [label="Enter anonymous object"];
|
||||
subgraph cluster_17 {
|
||||
color=blue
|
||||
33 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
|
||||
34 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
|
||||
}
|
||||
29 [label="Exit anonymous object"];
|
||||
30 [label="Exit anonymous object expression"];
|
||||
31 [label="Exit block"];
|
||||
}
|
||||
32 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||
}
|
||||
subgraph cluster_18 {
|
||||
color=blue
|
||||
45 [label="Enter function setValue" style="filled" fillcolor=red];
|
||||
subgraph cluster_19 {
|
||||
color=blue
|
||||
46 [label="Enter block"];
|
||||
47 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow];
|
||||
48 [label="Access variable R|<local>/value|"];
|
||||
49 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)" style="filled" fillcolor=yellow];
|
||||
50 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|<local>/value|)"];
|
||||
51 [label="Stub" style="filled" fillcolor=gray];
|
||||
52 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
53 [label="Exit function setValue" style="filled" fillcolor=red];
|
||||
}
|
||||
subgraph cluster_20 {
|
||||
color=blue
|
||||
27 [label="Enter block"];
|
||||
28 [label="Enter anonymous object"];
|
||||
38 [label="Enter function getValue" style="filled" fillcolor=red];
|
||||
subgraph cluster_21 {
|
||||
color=blue
|
||||
33 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
|
||||
34 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
|
||||
39 [label="Enter block"];
|
||||
40 [label="Function call: R|/IssueListView.IssueListView|()" style="filled" fillcolor=yellow];
|
||||
41 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"];
|
||||
42 [label="Stub" style="filled" fillcolor=gray];
|
||||
43 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
29 [label="Exit anonymous object"];
|
||||
30 [label="Exit anonymous object expression"];
|
||||
31 [label="Exit block"];
|
||||
44 [label="Exit function getValue" style="filled" fillcolor=red];
|
||||
}
|
||||
32 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||
subgraph cluster_22 {
|
||||
color=blue
|
||||
35 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
36 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
||||
37 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
73 [label="Postponed exit from lambda"];
|
||||
74 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)" style="filled" fillcolor=yellow];
|
||||
75 [label="Access variable this@R|/IssuesListUserProfile|"];
|
||||
76 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...).<Unresolved name: provideDelegate>#(...)" style="filled" fillcolor=yellow];
|
||||
77 [label="Exit property delegate" style="filled" fillcolor=yellow];
|
||||
78 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
73 [label="Postponed exit from lambda"];
|
||||
74 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)" style="filled" fillcolor=yellow];
|
||||
75 [label="Access variable this@R|/IssuesListUserProfile|"];
|
||||
76 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...).<Unresolved name: provideDelegate>#(...)" style="filled" fillcolor=yellow];
|
||||
77 [label="Exit property delegate" style="filled" fillcolor=yellow];
|
||||
78 [label="Exit property" style="filled" fillcolor=red];
|
||||
81 [label="Exit class IssuesListUserProfile" style="filled" fillcolor=red];
|
||||
}
|
||||
79 -> {80} [color=green];
|
||||
80 -> {71} [color=green];
|
||||
80 -> {81} [style=dotted];
|
||||
80 -> {71} [style=dashed];
|
||||
71 -> {72};
|
||||
72 -> {26 73 74};
|
||||
72 -> {26} [style=dashed];
|
||||
@@ -236,16 +225,23 @@ digraph delegateWithAnonymousObject_kt {
|
||||
31 -> {32};
|
||||
33 -> {34} [color=green];
|
||||
34 -> {29} [color=green];
|
||||
|
||||
subgraph cluster_22 {
|
||||
color=red
|
||||
79 [label="Enter class IssuesListUserProfile" style="filled" fillcolor=red];
|
||||
80 [label="Part of class initialization"];
|
||||
81 [label="Exit class IssuesListUserProfile" style="filled" fillcolor=red];
|
||||
}
|
||||
79 -> {80} [color=green];
|
||||
80 -> {71} [color=green];
|
||||
80 -> {81} [style=dotted];
|
||||
80 -> {71} [style=dashed];
|
||||
35 -> {36};
|
||||
36 -> {37};
|
||||
38 -> {39};
|
||||
39 -> {40};
|
||||
40 -> {41};
|
||||
41 -> {44};
|
||||
41 -> {42} [style=dotted];
|
||||
42 -> {43} [style=dotted];
|
||||
43 -> {44} [style=dotted];
|
||||
45 -> {46};
|
||||
46 -> {47};
|
||||
47 -> {48};
|
||||
48 -> {49};
|
||||
49 -> {50};
|
||||
50 -> {53};
|
||||
50 -> {51} [style=dotted];
|
||||
51 -> {52} [style=dotted];
|
||||
52 -> {53} [style=dotted];
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user