Commit f9f81f9
authored
feat(cfg): bypass JS CFG visitor on native builds, fix Go for-range parity (#595)
* feat(cfg): bypass JS CFG visitor on native builds, fix Go for-range parity
Add allCfgNative() fast path in buildCFGData that skips WASM parser
init, tree parsing, and JS visitor when all definitions already have
native CFG data from the Rust extractor — directly persists to SQLite.
Fix Go for-range loop detection in Rust CFG builder: check for
range_clause child node so for-range is treated as bounded (emitting
branch_true + loop_exit) instead of infinite.
Expand parity tests: add Go/Rust/Ruby to matrix, add complex pattern
fixtures (try/catch/finally, switch, do-while, nested loops, labeled
break) validating block counts, edge counts, and kinds match.
* feat(cfg): bypass JS CFG visitor on native builds, fix Go for-range parity
Add allCfgNative() fast path in buildCFGData that skips WASM parser
init, tree parsing, and JS visitor when all definitions already have
native CFG data from the Rust extractor — directly persists to SQLite.
Fix Go for-range loop detection in Rust CFG builder: check for
range_clause child node so for-range is treated as bounded (emitting
branch_true + loop_exit) instead of infinite.
Expand parity tests: add Go/Rust/Ruby to matrix, add complex pattern
fixtures (try/catch/finally, switch, do-while, nested loops, labeled
break) validating block counts, edge counts, and kinds match.
* fix(cfg): resolve temporary value borrow error in has_child_of_kind
Use a let binding for the tree cursor instead of borrowing a temporary,
fixing E0716 compilation error on all platforms.
* fix(cfg): remove unnecessary parentheses in allCfgNative check
Biome formatter flagged the redundant grouping parens around the
optional-chain expression.
* fix(test): move hasGoRangeFix to beforeAll, use ctx.skip() for skipped tests
- Move hasGoRangeFix computation into beforeAll where nativeResults is
already populated, fixing the IIFE evaluation-order bug that always
yielded false.
- Replace bare return statements with ctx.skip() so Vitest reports
skipped tests explicitly instead of as silent passes.
- Fix inaccurate test description: complex-dowhile uses early return,
not break.
* fix(cfg): bind iterator result to extend cursor lifetime
The iterator returned by node.children() borrows the cursor, but the
cursor is dropped at the end of the statement when the result is returned
directly. Binding the result to a local variable ensures the cursor
outlives the iterator.
* fix(cfg): align allCfgNative with initCfgParsers, clean stale CFG rows on fast path (#595)
- Skip _tree files in allCfgNative to match initCfgParsers behavior,
preventing false fast-path suppression in mixed-engine pipelines
- Always call deleteCfgForNode in fast path before checking cfg content,
ensuring stale rows are cleaned when function bodies are removed
- Replace bare return guards with ctx.skip() in parity tests so Vitest
reports them as skipped rather than silently passed
Impact: 2 functions changed, 6 affected
* fix(cfg): prevent fast path from wiping CFG in WASM-only builds (#595)
When all files have _tree set (WASM-only builds), allCfgNative()
vacuously returns true. The fast path then deletes all existing CFG
rows without recomputing them, since _tree files have no native CFG.
Guard the fast path with !symbols._tree so _tree files fall through
to the slow path where getTreeAndLang uses the pre-parsed tree directly.
Impact: 1 functions changed, 5 affected
* refactor(cfg): simplify has_child_of_kind by returning directly (#595)
Impact: 1 functions changed, 1 affected
* docs(test): clarify hasGoRangeFix heuristic false-positive risk (#595)
* fix(cfg): revert has_child_of_kind simplification (borrow checker) (#595)
The intermediate `result` variable is required because `cursor` must
outlive the iterator returned by `node.children()`. Returning directly
causes a borrow-after-drop error since cursor is dropped before the
temporary iterator's destructor runs.
Impact: 1 functions changed, 1 affected
* refactor(cfg): extract hasNativeCfgForFile shared predicate (#595)
The native-CFG check was duplicated in allCfgNative, initCfgParsers,
and getTreeAndLang. Extract into a single hasNativeCfgForFile helper
so all three callers stay in sync automatically.
Impact: 4 functions changed, 4 affected
* fix(cfg): address review feedback — vacuous allCfgNative, stale CFG cleanup, doc comment (#595)
- allCfgNative now returns false (not vacuous true) when fileSymbols is
empty, all-_tree, or contains only non-CFG extensions. Tracks hasCfgFile
sentinel to distinguish "all native" from "nothing to process".
- Fast path adds !symbols._tree guard so WASM-parsed files fall through
to the slow path (prevents CFG wipe on WASM-only builds).
- Both fast and slow paths now unconditionally call deleteCfgForNode before
the blocks-length guard, cleaning stale cfg_blocks/cfg_edges rows when
a function body is removed.
- Added doc comment to has_child_of_kind clarifying shallow (one-level)
direct-child check semantics.
Impact: 2 functions changed, 6 affected
* fix(test): guard against silent pass when no defs have CFG blocks (#595)
* docs(cfg): clarify parsers=null invariant for _tree files in fast path (#595)
Impact: 1 functions changed, 5 affected
* fix(test): guard against findFunctionNode returning null for all defs (#595)
Both the parity test loop and complex patterns suite could silently pass
with zero assertions if findFunctionNode returned null for every entry in
defsWithCfg (e.g., due to line-number offset mismatch between native and
WASM parsers). Added defsWithNode guard that calls ctx.skip() when no
function nodes are found, matching the existing defsWithCfg pattern.1 parent b1369b5 commit f9f81f9
3 files changed
Lines changed: 319 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
803 | 803 | | |
804 | 804 | | |
805 | 805 | | |
| 806 | + | |
| 807 | + | |
806 | 808 | | |
807 | 809 | | |
808 | 810 | | |
| |||
1134 | 1136 | | |
1135 | 1137 | | |
1136 | 1138 | | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
1137 | 1147 | | |
1138 | 1148 | | |
1139 | 1149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
87 | 98 | | |
88 | 99 | | |
89 | 100 | | |
| |||
93 | 104 | | |
94 | 105 | | |
95 | 106 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 107 | + | |
100 | 108 | | |
101 | 109 | | |
102 | 110 | | |
| |||
129 | 137 | | |
130 | 138 | | |
131 | 139 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
| 140 | + | |
137 | 141 | | |
138 | 142 | | |
139 | 143 | | |
| |||
246 | 250 | | |
247 | 251 | | |
248 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
249 | 273 | | |
250 | 274 | | |
251 | 275 | | |
252 | 276 | | |
253 | 277 | | |
254 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
255 | 283 | | |
256 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
257 | 290 | | |
258 | 291 | | |
259 | 292 | | |
| |||
270 | 303 | | |
271 | 304 | | |
272 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
273 | 335 | | |
274 | 336 | | |
275 | 337 | | |
| |||
302 | 364 | | |
303 | 365 | | |
304 | 366 | | |
| 367 | + | |
| 368 | + | |
305 | 369 | | |
306 | 370 | | |
307 | | - | |
308 | 371 | | |
309 | 372 | | |
310 | 373 | | |
| |||
0 commit comments