Skip to content

Commit 87c6dff

Browse files
committed
Add -mermaid flag and update reactive pipeline diagram
- Add -mermaid CLI flag to output auto-generated Mermaid diagram - Update manual diagram to show all nodes (no hidden intermediate nodes) - Use clearer names (less abbreviated, multi-line where needed) - Regenerate SVG
1 parent d4092ed commit 87c6dff

File tree

4 files changed

+159
-89
lines changed

4 files changed

+159
-89
lines changed
Lines changed: 152 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,177 @@
11
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#e8f4fd', 'primaryTextColor': '#1a1a1a', 'primaryBorderColor': '#4a90d9', 'lineColor': '#4a90d9', 'secondaryColor': '#f0f7e6', 'tertiaryColor': '#fff5e6'}}}%%
22
flowchart TB
33
subgraph FileLayer["File Layer"]
4-
RFC[("RFC")]
4+
file_collection[("file_collection")]
55
end
66

77
subgraph FileData["Per-File Data"]
8-
FD["FD"]
8+
file_data[file_data]
9+
files[files]
10+
file_deps[file_deps]
911
end
1012

1113
subgraph Extracted["Extracted (ReactiveMerge)"]
12-
DECLS["D"]
13-
ANNOT["A"]
14-
VREFS["VR"]
15-
TREFS["TR"]
16-
CFI["CFI"]
14+
decls[decls]
15+
annotations[annotations]
16+
value_refs[value_refs]
17+
type_refs[type_refs]
18+
cross_file[cross_file<br/>items]
1719
end
1820

1921
subgraph TypeDeps["ReactiveTypeDeps"]
20-
DBP["DBP"]
21-
ATR["ATR"]
22+
decl_by_path[decl_by_path]
23+
intf_decls[intf_decls]
24+
impl_decls[impl_decls]
25+
intf_to_impl[intf→impl]
26+
impl_to_intf[impl→intf]
27+
same_path[same_path]
28+
combined_refs[combined<br/>refs_to]
29+
all_type_refs[all_type<br/>refs_from]
2230
end
2331

24-
subgraph ExcDeps["ReactiveExceptionRefs"]
25-
EXCREF["ER"]
26-
EXCDECL["ED"]
27-
RESOLVED["RR"]
32+
subgraph ExcRefs["ReactiveExceptionRefs"]
33+
exc_collection[exception<br/>refs]
34+
exc_decls[exception<br/>decls]
35+
resolved_refs[resolved<br/>refs]
36+
resolved_from[resolved<br/>refs_from]
2837
end
2938

3039
subgraph DeclRefs["ReactiveDeclRefs"]
31-
DR["DR"]
40+
decls_by_file[decls<br/>by_file]
41+
value_decl_refs[value<br/>decl_refs]
42+
type_decl_refs[type<br/>decl_refs]
43+
with_value[with_value<br/>refs]
44+
with_type[with_type<br/>refs]
45+
combined[combined]
3246
end
3347

3448
subgraph Liveness["ReactiveLiveness"]
35-
ROOTS["roots"]
36-
EDGES["edges"]
37-
FP["fixpoint"]
38-
LIVE["LIVE"]
49+
value_refs_from[value<br/>refs_from]
50+
type_refs_from[type<br/>refs_from]
51+
ext_value_refs[external<br/>value_refs]
52+
ext_type_refs[external<br/>type_refs]
53+
ext_referenced[externally<br/>referenced]
54+
annotated_roots[annotated<br/>roots]
55+
all_roots[all_roots]
56+
edges[edges]
57+
live[live<br/>fixpoint]
3958
end
4059

4160
subgraph Solver["ReactiveSolver"]
42-
DEAD_DECLS["dead_decls"]
43-
LIVE_DECLS["live_decls"]
44-
DEAD_MODULES["dead_modules"]
45-
DEAD_BY_FILE["dead_by_file"]
46-
REFS_BY_FILE["refs_by_file"]
47-
ISSUES_BY_FILE["issues_by_file"]
48-
INCORRECT["incorrect_dead"]
49-
MOD_REPORTED["mod_reported"]
50-
MOD_ISSUES["mod_issues"]
61+
dead_decls[dead_decls]
62+
live_decls[live_decls]
63+
modules_dead[modules<br/>with_dead]
64+
modules_live[modules<br/>with_live]
65+
dead_modules[dead<br/>modules]
66+
dead_by_file[dead<br/>by_file]
67+
issues_by_file[issues<br/>by_file]
68+
incorrect_dead[incorrect<br/>dead]
69+
modules_reported[modules<br/>reported]
70+
module_issues[module<br/>issues]
5171
end
5272

5373
subgraph Report["Report (iter only)"]
5474
OUTPUT[("REPORT")]
5575
end
5676

57-
RFC -->|"process"| FD
58-
FD -->|"flatMap"| DECLS
59-
FD -->|"flatMap"| ANNOT
60-
FD -->|"flatMap"| VREFS
61-
FD -->|"flatMap"| TREFS
62-
FD -->|"flatMap"| CFI
63-
64-
DECLS -->|"flatMap"| DBP
65-
DBP -->|"union+flatMap"| ATR
66-
67-
CFI -->|"flatMap"| EXCREF
68-
DECLS -->|"flatMap"| EXCDECL
69-
EXCREF -->|"join"| RESOLVED
70-
EXCDECL -->|"join"| RESOLVED
71-
72-
DECLS --> DR
73-
VREFS --> DR
74-
TREFS --> DR
75-
ATR --> DR
76-
RESOLVED --> DR
77-
78-
DECLS --> ROOTS
79-
ANNOT --> ROOTS
80-
81-
DR -->|"flatMap"| EDGES
82-
ROOTS --> FP
83-
EDGES --> FP
84-
FP -->|"fixpoint"| LIVE
85-
86-
DECLS -->|"join (NOT in live)"| DEAD_DECLS
87-
LIVE -->|"join"| DEAD_DECLS
88-
DECLS -->|"join (IN live)"| LIVE_DECLS
89-
LIVE -->|"join"| LIVE_DECLS
90-
91-
DEAD_DECLS -->|"flatMap (anti-join)"| DEAD_MODULES
92-
LIVE_DECLS -->|"flatMap (anti-join)"| DEAD_MODULES
93-
94-
DEAD_DECLS -->|"flatMap by file"| DEAD_BY_FILE
95-
VREFS -->|"flatMap by file"| REFS_BY_FILE
96-
97-
DEAD_BY_FILE -->|"flatMap"| ISSUES_BY_FILE
98-
ANNOT -->|"filter"| ISSUES_BY_FILE
99-
REFS_BY_FILE -->|"hasRefBelow"| ISSUES_BY_FILE
100-
101-
LIVE_DECLS -->|"join (@dead)"| INCORRECT
102-
ANNOT -->|"join (@dead)"| INCORRECT
103-
104-
ISSUES_BY_FILE -->|"flatMap"| MOD_REPORTED
105-
DEAD_MODULES -->|"join"| MOD_ISSUES
106-
MOD_REPORTED -->|"join"| MOD_ISSUES
107-
108-
ISSUES_BY_FILE -->|"iter"| OUTPUT
109-
INCORRECT -->|"iter"| OUTPUT
110-
MOD_ISSUES -->|"iter"| OUTPUT
77+
%% File Layer
78+
file_collection -->|process| file_data
79+
file_data --> files
80+
file_data --> file_deps
81+
file_data --> decls
82+
file_data --> annotations
83+
file_data --> value_refs
84+
file_data --> type_refs
85+
file_data --> cross_file
86+
87+
%% TypeDeps
88+
decls --> decl_by_path
89+
decls --> intf_decls
90+
decls --> impl_decls
91+
decl_by_path --> intf_to_impl
92+
decl_by_path --> impl_to_intf
93+
decl_by_path --> same_path
94+
intf_decls --> intf_to_impl
95+
impl_decls --> impl_to_intf
96+
intf_to_impl --> combined_refs
97+
impl_to_intf --> combined_refs
98+
same_path --> combined_refs
99+
combined_refs --> all_type_refs
100+
101+
%% ExceptionRefs
102+
cross_file --> exc_collection
103+
decls --> exc_decls
104+
exc_collection --> resolved_refs
105+
exc_decls --> resolved_refs
106+
resolved_refs --> resolved_from
107+
108+
%% DeclRefs
109+
decls --> decls_by_file
110+
decls --> with_value
111+
decls --> with_type
112+
decls_by_file --> value_decl_refs
113+
decls_by_file --> type_decl_refs
114+
value_decl_refs --> with_value
115+
type_decl_refs --> with_type
116+
with_value --> combined
117+
with_type --> combined
118+
119+
%% Liveness inputs
120+
value_refs --> value_refs_from
121+
type_refs --> type_refs_from
122+
all_type_refs --> type_refs_from
123+
resolved_from --> value_refs_from
124+
125+
%% Liveness external refs
126+
decls --> ext_value_refs
127+
decls --> ext_type_refs
128+
value_refs_from --> ext_value_refs
129+
type_refs_from --> ext_type_refs
130+
value_refs_from --> value_decl_refs
131+
type_refs_from --> type_decl_refs
132+
ext_value_refs --> ext_referenced
133+
ext_type_refs --> ext_referenced
134+
135+
%% Liveness roots
136+
decls --> annotated_roots
137+
annotations --> annotated_roots
138+
ext_referenced --> all_roots
139+
annotated_roots --> all_roots
140+
141+
%% Liveness fixpoint
142+
combined --> edges
143+
all_roots --> live
144+
edges --> live
145+
146+
%% Solver partition
147+
decls --> dead_decls
148+
decls --> live_decls
149+
live --> dead_decls
150+
live --> live_decls
151+
152+
%% Solver modules
153+
dead_decls --> modules_dead
154+
live_decls --> modules_live
155+
modules_dead --> dead_modules
156+
modules_live --> dead_modules
157+
158+
%% Solver issues
159+
dead_decls --> dead_by_file
160+
dead_by_file --> issues_by_file
161+
162+
%% Solver incorrect @dead
163+
live_decls --> incorrect_dead
164+
annotations --> incorrect_dead
165+
166+
%% Solver module issues
167+
issues_by_file --> modules_reported
168+
dead_modules --> module_issues
169+
modules_reported --> module_issues
170+
171+
%% Output
172+
issues_by_file -->|iter| OUTPUT
173+
incorrect_dead -->|iter| OUTPUT
174+
module_issues -->|iter| OUTPUT
111175

112176
classDef fileLayer fill:#e8f4fd,stroke:#4a90d9,stroke-width:2px
113177
classDef extracted fill:#f0f7e6,stroke:#6b8e23,stroke-width:2px
@@ -118,11 +182,11 @@ flowchart TB
118182
classDef solver fill:#ffe6f0,stroke:#cc6699,stroke-width:2px
119183
classDef output fill:#e6ffe6,stroke:#2e8b2e,stroke-width:2px
120184

121-
class RFC,FD fileLayer
122-
class DECLS,ANNOT,VREFS,TREFS,CFI extracted
123-
class DBP,ATR typeDeps
124-
class EXCREF,EXCDECL,RESOLVED excDeps
125-
class DR declRefs
126-
class ROOTS,EDGES,FP,LIVE liveness
127-
class DEAD_DECLS,LIVE_DECLS,DEAD_MODULES,DEAD_BY_FILE,REFS_BY_FILE,ISSUES_BY_FILE,INCORRECT,MOD_REPORTED,MOD_ISSUES solver
185+
class file_collection,file_data,files,file_deps fileLayer
186+
class decls,annotations,value_refs,type_refs,cross_file extracted
187+
class decl_by_path,intf_decls,impl_decls,intf_to_impl,impl_to_intf,same_path,combined_refs,all_type_refs typeDeps
188+
class exc_collection,exc_decls,resolved_refs,resolved_from excDeps
189+
class decls_by_file,value_decl_refs,type_decl_refs,with_value,with_type,combined declRefs
190+
class value_refs_from,type_refs_from,ext_value_refs,ext_type_refs,ext_referenced,annotated_roots,all_roots,edges,live liveness
191+
class dead_decls,live_decls,modules_dead,modules_live,dead_modules,dead_by_file,issues_by_file,incorrect_dead,modules_reported,module_issues solver
128192
class OUTPUT output

analysis/reanalyze/diagrams/reactive-pipeline.svg

Lines changed: 1 addition & 1 deletion
Loading

analysis/reanalyze/src/Cli.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ let reactive = ref false
3333

3434
(* number of analysis runs (for benchmarking reactive mode) *)
3535
let runs = ref 1
36+
37+
(* output mermaid diagram of reactive pipeline *)
38+
let mermaid = ref false

analysis/reanalyze/src/Reanalyze.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ let runAnalysis ~dce_config ~cmtRoot ~reactive_collection ~reactive_merge
419419
| Some liveness -> ReactiveLiveness.print_stats ~t:liveness
420420
| None -> ());
421421
ReactiveSolver.print_stats ~t:solver);
422+
if !Cli.mermaid then
423+
Printf.eprintf "\n%s\n" (Reactive.to_mermaid ());
422424
Some (AnalysisResult.add_issues AnalysisResult.empty all_issues)
423425
| None ->
424426
(* Non-reactive path: use old solver with optional args *)
@@ -645,6 +647,7 @@ let cli () =
645647
"n Process files in parallel using n domains (0 = sequential, default; \
646648
-1 = auto-detect cores)" );
647649
("-timing", Set Cli.timing, "Report internal timing of analysis phases");
650+
("-mermaid", Set Cli.mermaid, "Output Mermaid diagram of reactive pipeline");
648651
( "-reactive",
649652
Set Cli.reactive,
650653
"Use reactive analysis (caches processed file_data, skips unchanged \

0 commit comments

Comments
 (0)