Skip to content

[AUTOMATED] Keep the NULL comparison of a pointer tested inside && / || (truthycond ptrchain) - #1975

Merged
mahaloz merged 4 commits into
mainfrom
feat/ptrcmp
Nov 25, 2026
Merged

mahaloz merged 4 commits into
mainfrom
feat/ptrcmp

Conversation

@mahaloz

@mahaloz mahaloz commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

A pointer tested inside an && / || chain prints bare, while C source usually spells that test p != NULL (and p == NULL for !p). On the repo's boolret fixture (decompiler/crates/kuna-analysis/tests/fixtures/boolret.c has return path != 0 && path[0] == '/'; and return p != 0 && *p == a;):

$ kuna decompile decompiler/crates/kuna-analysis/tests/fixtures/boolret_gcc_O0_x86_64 is_abs
  return ((a0) && (*a0 == '/'));
$ kuna decompile decompiler/crates/kuna-analysis/tests/fixtures/boolret_gcc_O0_x86_64 bump_and_test
  if ((a0) && (a1 == *a0))

With this change:

  return ((a0 != NULL) && (*a0 == '/'));
  if ((a0 != NULL) && (a1 == *a0))
  • truthycond gains a value, ptrchain, which becomes the default. It is on except that a comparison that is itself an operand of a printed && / || keeps its != NULL / == NULL when the value it tests prints as a plain pointer parameter or local. on and off keep their exact output.
  • Integers, flags, field accesses, calls, globals and stand-alone tests such as if (p) stay truthy, as does a chain that is a loop's condition (while (p && *p)), where the bare form is the common spelling.
  • Only the spelling changes: every line that changes on the decbench corpus differs from the old one only by X != NULL / X == NULL in place of X / !X.
  • On the decbench O2 (no inlining) corpus 13 more functions match the source's control flow exactly (gained 20, lost 7); at O0, 73 more (gained 122, lost 49). Whole-binary decompile-all time is unchanged (sshd x0.98, ls x0.94, bash x0.99, min of 7).

Tests: tests/stages/kuna-ptrchain.xml checks a pointer between a call and an integer, a negated pointer, a returned chain, a field access, a stand-alone test and a loop condition under the default and under option truthycond on. Nine stage tests about other features pin option truthycond on; the vendored datatests do not move. The boolret round trip, which compiles the printed C and runs it against the source, now expects the comparison.

Model: anthropic/claude-opus-5-5

🤖 Generated with Claude Code

https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU

mahaloz and others added 4 commits November 25, 2026 21:09
…rison

[AUTOMATED] work in progress (temporary KUNA_PTRCMP_GLOBALS toggle for measurement).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
[AUTOMATED] regenerate docs/options.md and the phase catalog fixture, re-record
docs/baseline-stages.json for the new kuna-ptrchain.xml (5464 -> 5474), bump the
stage corpus count (926 -> 927).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
[AUTOMATED] boolret_round_trip expects `a0 != NULL` in its chains and still
compiles and runs the printed C against the source; the conditional register
model defines NULL for the printed `entity == NULL`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
@mahaloz
mahaloz merged commit f3856f8 into main Nov 25, 2026
9 checks passed
@mahaloz
mahaloz deleted the feat/ptrcmp branch November 25, 2026 22:14
mahaloz added a commit to phix33/kuna that referenced this pull request Nov 25, 2026
Resolves the stage-count conflicts with Noelo-Lab#1975: the corpus count is 928
(927 + kuna-elfv1-symbolextent), and docs/baseline-stages.json is re-recorded
on the merged tree (5,480 assertions: main's 5,474 plus this stage's 6).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013BBaWTdjVzTz11WxPZmJ9b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant