1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! Dataflow Analysis Module
//!
//! This module provides two forward dataflow analyses:
//!
//! 1. **Available Expressions Analysis** (CAP-AE-01 through CAP-AE-12)
//! - Forward MUST (intersection) dataflow analysis
//! - Common Subexpression Elimination (CSE) detection
//! - Commutative expression normalization
//!
//! 2. **Abstract Interpretation** (CAP-AI-01 through CAP-AI-22)
//! - Forward dataflow with widening for loop termination
//! - Range tracking for integer variables
//! - Nullability tracking (NEVER/MAYBE/ALWAYS)
//! - Division-by-zero detection
//! - Null dereference detection
//! - Multi-language support (Python, TypeScript, Go, Rust)
//!
//! ## Module Structure
//!
//! ```text
//! dataflow/
//! ├── mod.rs # This file - module entry point
//! ├── types.rs # Shared types (BlockId, predecessors)
//! ├── available.rs # Available expressions analysis
//! ├── abstract_interp.rs # Abstract interpretation
//! └── dataflow_tests.rs # Comprehensive test suite
//! ```
//!
//! ## Usage
//!
//! ```rust,ignore
//! use tldr_core::dataflow::{
//! compute_available_exprs, AvailableExprsInfo, Expression,
//! compute_abstract_interp, AbstractInterpInfo, AbstractValue, Nullability,
//! };
//!
//! // Available Expressions Analysis
//! let cfg = get_cfg_context(path, func, None, None)?;
//! let dfg = get_dfg_context(path, func, None, None)?;
//! let avail = compute_available_exprs(&cfg, &dfg)?;
//! let redundant = avail.redundant_computations();
//!
//! // Abstract Interpretation
//! let interp = compute_abstract_interp(&cfg, &refs, Some(&source), "python")?;
//! for (line, var) in &interp.potential_div_zero {
//! println!("Warning: potential division by zero at line {} ({})", line, var);
//! }
//! ```
//!
//! ## Specification Reference
//!
//! See `spec.md` in this directory for:
//! - Full capability definitions (34 capabilities)
//! - Algorithm descriptions
//! - Behavioral contracts
//! - JSON output formats
//! - Edge case handling
// =============================================================================
// Submodules
// =============================================================================
// Types submodule (shared types and helpers)
// Available Expressions Analysis
// Abstract Interpretation
// Tests
// =============================================================================
// Re-exports (Phase 12: Integration & Public API)
// =============================================================================
// Available Expressions types and functions
pub use ;
// Abstract Interpretation types and functions
pub use ;
// Shared types and helpers
pub use ;