-
Notifications
You must be signed in to change notification settings - Fork 294
postprocess: support multiple transforms #1543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the c2rust postprocessing system to support multiple transforms in sequence. The main goal is to enable different post-processing steps (like comment transfer, assert folding, relooper cleanup, etc.) to be applied independently and in configurable order.
Changes:
- Introduced an abstract base class
AbstractTransformto standardize transform implementations - Renamed
CommentTransfertoCommentsTransformand moved it to a new module structure - Added factory function
get_transform_by_idto instantiate transforms by name - Updated CLI to accept comma-separated list of transforms via
--transformsparameter
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| c2rust-postprocess/postprocess/transforms/base.py | New abstract base class defining transform interface with apply() and apply_dir() methods |
| c2rust-postprocess/postprocess/transforms/comments.py | Refactored comments transform with renamed classes, added validation, and AbstractTransform inheritance |
| c2rust-postprocess/postprocess/transforms/init.py | New factory function to instantiate transforms by ID |
| c2rust-postprocess/postprocess/comments/init.py | Duplicate/incomplete implementation with critical bugs that appears to be leftover from refactoring |
| c2rust-postprocess/postprocess/init.py | Updated main entry point to support multiple transforms and use factory pattern |
| c2rust-postprocess/tests/llm-cache/CommentsTransform/*/metadata.toml | Updated cache metadata to reflect "CommentsTransform" naming |
| c2rust-postprocess/tests/llm-cache/CommentsTransform/*/response.txt | New cached test responses for quickSort and partition functions |
Comments suppressed due to low confidence (3)
c2rust-postprocess/postprocess/transforms/comments.py:69
- The docstring parameter documentation is missing the colon prefix for reST/Sphinx format. It should be
:param rust_fn:and:return:instead ofparam:andreturn:.
c2rust-postprocess/postprocess/transforms/comments.py:242 - The transfer_comments_dir method calls self.apply with a rust_source_file parameter, but the apply method signature only accepts root_rust_source_file. This mismatch will cause a TypeError at runtime. Either the apply method needs to be updated to accept rust_source_file, or this call needs to be updated to match the apply signature.
c2rust-postprocess/postprocess/transforms/comments.py:242 - Keyword argument 'rust_source_file' is not a supported parameter name of method CommentsTransform.apply.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
828f00c to
79adc8c
Compare
3c35f8a to
ade83ec
Compare
A later change adds an abstract base class using the `Transform` suffix so it is more consistent with naming elsewhere in this project to call the inaugural transform `CommentsTransform`. Updated cache dir correspondingly.
ade83ec to
d21f1eb
Compare
Adds base class for transforms.
d21f1eb to
111e4d5
Compare
Support multiple transforms such that we can support different post-processing steps such as:
Some transforms might also be broken down into a sequence of simpler transforms. A concrete use case is lua which contains license headers and other matter before function definitions which we do not want to pass so the comment transfer transform.
(Replaces PR #1512 as it was automatically closed when I renamed the branch)