GitNexus/gitnexus/test/unit/cfg
Gergo Magyar bbee2da92e fix(cfg): synthetic-escape pass restores CDG for exit-unreachable cycles (#2195 U1)
Unconditional goto-cycles (C/C++/C#/Go) wire a backward seq edge with no
structural exit-escape edge, so EXIT becomes non-reverse-reachable and
emitFileCdg silently skipped ALL control-dependence for the function.

New cfg/synthetic-escape.ts: a pure deterministic SCC routine (iterative
Tarjan, sorted adjacency) + augmentForPostDom(cfg). No-op when EXIT is
already reverse-reachable (terminating fns + visitor-escaped loops are
byte-identical — returns the same object). Otherwise it batch-bridges
every exit-less SCC by adding an ANALYSIS-ONLY escape edge from the SCC's
controlling block (highest out-degree branch; lowest-index tie-break) to
EXIT, on a shallow-cloned FunctionCfg — never mutating persisted
cfg.edges. emitFileCdg threads that augmented view through BOTH
isExitReachableFromAllBlocks AND computeControlDependence (the Ferrante
walk re-reads cfg.edges, so a tree-only augmentation would be wrong).

Precision (anti-masking): only a trapped region containing a control
point (>=2-successor block) is bridged — a branch-less trapped region
carries no recoverable control-dependence and is indistinguishable from a
genuine construction anomaly, so it stays on the skip path (the existing
disconnected-block skip test still skips, skippedUnsoundFunctions===1). A
residual non-cycle dangling block is never bridged.

repro `void handler(int a){ start: if(a>0){work();} goto start; }`:
before exitReachable=false/CDG=0 → after one synthetic 2->1 edge,
exitReachable=true, exact CDG = {2->2:T,2->2:F,2->3:T,2->4:T,2->4:F}
(pinned exactly, not CDG>0 — catches a wrong representative). AC2 property
test extended to the augmented graph; per-language goto-cycle regressions
(C/C++/C#/Go). 199 cfg tests green; bench --check fingerprints unchanged
(analysis-only, zero persisted drift).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 15:58:50 +00:00
..
c-cpp-visitor.test.ts fix(cfg): synthetic-escape pass restores CDG for exit-unreachable cycles (#2195 U1) 2026-06-14 15:58:50 +00:00
cfg-builder.test.ts feat(ingestion): add control-flow-graph layer for TS/JS (#2081) (#2099) 2026-06-10 19:26:45 +01:00
control-dependence.test.ts fix(cfg): synthetic-escape pass restores CDG for exit-unreachable cycles (#2195 U1) 2026-06-14 15:58:50 +00:00
csharp-visitor.test.ts fix(cfg): synthetic-escape pass restores CDG for exit-unreachable cycles (#2195 U1) 2026-06-14 15:58:50 +00:00
dart-visitor.test.ts feat(cfg): Dart CFG visitor + def/use harvest (#2195 U14) 2026-06-14 14:09:21 +00:00
emit-guard.test.ts feat(cfg): intra-procedural REACHING_DEF data-dependence layer (#2082) (#2160) 2026-06-11 05:49:39 +01:00
go-visitor.test.ts fix(cfg): synthetic-escape pass restores CDG for exit-unreachable cycles (#2195 U1) 2026-06-14 15:58:50 +00:00
harness.test.ts test(cfg): language-agnostic CFG unit-test harness (#2195 U1) 2026-06-14 10:43:00 +00:00
harvest.test.ts feat(taint): intra-procedural taint analysis (#2083) (#2164) 2026-06-12 07:35:09 +01:00
java-visitor.test.ts feat(cfg): call-site sites[] taint substrate for C-family (#2195 U6) 2026-06-14 11:56:21 +00:00
kotlin-visitor.test.ts feat(cfg): Kotlin CFG visitor + def/use harvest (#2195 U13) 2026-06-14 13:53:59 +00:00
opt-in.test.ts feat(ingestion): add control-flow-graph layer for TS/JS (#2081) (#2099) 2026-06-10 19:26:45 +01:00
php-visitor.test.ts feat(cfg): PHP CFG visitor + def/use harvest (#2195 U9) 2026-06-14 12:46:39 +00:00
post-dominators.test.ts feat(pdg): control dependence — post-dominators + CDG (Ferrante) [M5 #2085] (#2188) 2026-06-13 18:49:03 +01:00
python-visitor.test.ts feat(cfg): Python CFG visitor + def/use harvest (#2195 U8) 2026-06-14 12:31:59 +00:00
reaching-defs.test.ts feat(cfg): intra-procedural REACHING_DEF data-dependence layer (#2082) (#2160) 2026-06-11 05:49:39 +01:00
ruby-visitor.test.ts feat(cfg): Ruby CFG visitor + def/use harvest (#2195 U10) 2026-06-14 13:02:17 +00:00
rust-visitor.test.ts feat(cfg): Rust CFG visitor + def/use harvest (#2195 U11) 2026-06-14 13:18:44 +00:00
swift-visitor.test.ts feat(cfg): Swift CFG visitor + def/use harvest (#2195 U12) 2026-06-14 13:40:44 +00:00
synthetic-escape.test.ts fix(cfg): synthetic-escape pass restores CDG for exit-unreachable cycles (#2195 U1) 2026-06-14 15:58:50 +00:00
typescript-visitor.test.ts feat(cfg): intra-procedural REACHING_DEF data-dependence layer (#2082) (#2160) 2026-06-11 05:49:39 +01:00
vue-visitor.test.ts feat(cfg): Vue (reuse TS visitor) + worker-mode proof for all langs (#2195 U15) 2026-06-14 14:19:10 +00:00