Files
codeql/python/ql/test/library-tests
yoff 79db96c717 Python: introduce shared-SSA adapter on the new CFG
Adds 'python/ql/lib/semmle/python/dataflow/new/internal/SsaImpl.qll', a
minimal Python SSA implementation built on the shared SSA library
('codeql.ssa.Ssa::Make<Location, Cfg, Input>'). The structure mirrors
Java's adapter at 'java/ql/lib/semmle/code/java/dataflow/internal/SsaImpl.qll'.

Key design choices:

  * 'SourceVariable' wraps 'Py::Variable'. Only variables that are read
    or deleted somewhere are tracked - write-only variables don't
    benefit from SSA construction.

  * Variable references are positional ('BasicBlock', 'int') pairs
    looked up via 'Cfg::NameNode.defines'/'.uses'/'.deletes' (which
    themselves are one-line bridges to AST-level 'Name.defines' etc.).

  * Parameter writes are not synthesised: parameter Name nodes are
    already wired into the CFG (per the earlier C#-style parameter
    extension in 'AstNodeImpl.qll'), so the regular 'variableWrite'
    path handles them at their natural CFG index.

  * Non-local / captured / global / builtin variables read in a scope
    but not written in it receive a synthetic entry definition at
    index '-1' of the scope's entry basic block. This matches Java's
    'hasEntryDef'.

  * 'del x' is modelled as a certain write at the deletion site.

Includes an inline-expectations test under
'python/ql/test/library-tests/dataflow-new-ssa/' covering:
plain parameter pass-through, simple assignment + read, reassignment
with dead-write pruning, if/else with phi insertion at the join, and
an undefined-name read (currently a known limitation - no SSA flow
without an enclosing definition).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-26 16:32:43 +00:00
..
2025-11-26 12:30:31 +00:00
2025-11-26 12:30:31 +00:00
2026-04-14 13:27:31 +02:00
2020-03-30 11:59:10 +02:00
2025-11-26 12:30:31 +00:00
2025-11-26 12:30:31 +00:00
2022-08-24 16:51:50 +01:00
2025-11-26 12:30:31 +00:00
2025-11-26 12:30:31 +00:00
2025-11-26 12:30:31 +00:00
2023-11-06 13:50:55 +00:00
2020-03-30 11:59:10 +02:00
2025-11-26 12:30:31 +00:00
2025-11-26 12:30:31 +00:00
2023-04-26 13:41:57 +02:00