Skip to content

Commit 2c08649

Browse files
committed
feat(dataflow): stage 1 — exceptional statement-level CFG per callable
Level-3 groundwork (#67): hand-built CFG from the stdlib ast with the shared node/edge vocabulary, Python lowering rules (try/except/else/ finally, with, yield/await resume kinds, break/continue, synthetic escape edge for infinite loops), dead-code pruning, and source-span- ordered node ids (ENTRY=0, EXIT=last). Dataflow fixture project and CFG gate tests included.
1 parent 2cab542 commit 2c08649

6 files changed

Lines changed: 1001 additions & 0 deletions

File tree

codeanalyzer/dataflow/__init__.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
################################################################################
2+
# Copyright IBM Corporation 2025
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
################################################################################
16+
17+
"""Level-3 native dataflow graphs: CFG, PDG (CDG + DDG), and the SDG.
18+
19+
One pass per module, mirroring the construction ladder:
20+
21+
- :mod:`cfg` — stage 1, exceptional statement-level CFG per callable;
22+
- :mod:`dominance` — stage 2, post-dominators and control dependence;
23+
- :mod:`access_paths` — stage 3a, the k-limited access-path variable model;
24+
- :mod:`defuse` — stage 3b, reaching definitions → DDG edges;
25+
- :mod:`alias` — stage 5, the type-based may-alias oracle (MVP stub);
26+
- :mod:`scc` — stage 5, Tarjan SCC condensation of the call graph;
27+
- :mod:`summaries` — stage 6, bottom-up formal-in → formal-out summaries;
28+
- :mod:`sdg` — stage 7, parameter nodes and CALL/PARAM_IN/PARAM_OUT/SUMMARY
29+
edges;
30+
- :mod:`slicing` — stage 8, the two-phase context-sensitive backward slice;
31+
- :mod:`builder` — the orchestrator ``build_program_graphs`` wired into
32+
``Codeanalyzer.analyze`` at ``-a 3``.
33+
"""
34+
35+
from codeanalyzer.dataflow.cfg import build_cfg # noqa: F401

0 commit comments

Comments
 (0)