Skip to content

transpile: Refactor, document and correct uses of used() flag - #1975

Open
Rua wants to merge 7 commits into
immunant:masterfrom
Rua:is_used
Open

transpile: Refactor, document and correct uses of used() flag#1975
Rua wants to merge 7 commits into
immunant:masterfrom
Rua:is_used

Conversation

@Rua

@Rua Rua commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

I've documented how is_used is supposed to be set, and added/removed used() accordingly.

If you're wondering what's up with some of the code in the exprs.c test suddenly disappearing: The transpiler normally eliminates unused code, which includes unused results of binary expressions:

  • 1 + 1; gets eliminated altogether
  • 1 + func(); gets reduced to func();

But for some reason unary expressions were not handled the same way, and were emitted even if they didn't do anything. Now they get removed too.

@Rua Rua changed the title transpile: Refactor and correct uses of used() flag transpile: Refactor, document and correct uses of used() flag Aug 16, 2026
@Rua
Rua force-pushed the is_used branch 6 times, most recently from c02d700 to 95b17f7 Compare August 16, 2026 16:02
@fw-immunant
fw-immunant self-requested a review August 18, 2026 06:47
@fw-immunant fw-immunant self-assigned this Aug 18, 2026

@fw-immunant fw-immunant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes all look good, but before merging I want to go verify that this doesn't interfere with the way Hayroll inserts no-op expressions into c2rust inputs to link C preprocessor macro expansions with their c2rust translations.

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.

2 participants