Skip to content

postprocess: Add AssertsTransform and FormattingTransform and GPT tool calling#1855

Draft
thedataking wants to merge 12 commits into
masterfrom
perl/postprocess-multiple-transforms-v2
Draft

postprocess: Add AssertsTransform and FormattingTransform and GPT tool calling#1855
thedataking wants to merge 12 commits into
masterfrom
perl/postprocess-multiple-transforms-v2

Conversation

@thedataking

Copy link
Copy Markdown
Contributor

Probably needs to be split into smaller bits.

TODO: AssertTransform might need different validations with different C libraries/hosts.

@thedataking thedataking force-pushed the perl/postprocess-multiple-transforms-v2 branch 3 times, most recently from 962e684 to 8d01f3c Compare June 16, 2026 01:45
The transpiler now emits an allow for clippy::missing_safety_doc, which
shifts the expected function spans by one line.
Restructure *.c_decls.json from a flat identifier-to-snippet map into
{definitions: {ident: {definition, preprocessed_definition}}}.

The AST exporter runs an in-process preprocessor-only pass per
translation unit (clang -E -fdirectives-only -C equivalent): conditional
directives are resolved, dropping inactive regions and their comments,
while macro invocations and comments are preserved. Line markers map the
output back to each function definition's source range; the main file is
recognized by the spelling in the leading line marker, since marker
paths are relative to the compilation directory. Functions whose mapping
fails get a null preprocessed_definition.
…prompts

Read both forms from the structured *.c_decls.json instead of running a
clang subprocess per snippet. The CommentsTransform prompt includes the
preprocessed text only when it differs from the original, so prompts
(and llm-cache keys) are unchanged for directive-free functions; comment
gating and response validation use the preprocessed text so comments in
inactive preprocessor regions are not transferred.
The C declarations can contain preprocessor definitions with their own
associated comments. Sometimes we also get license headers and similar
front matter. Use a separate transformation to remove this front matter
such that validation of comment insertion only take the relevant comments
into account.

Note: the trim step is currently tightly integrated into the comment
transfer step but I expect we'll want to run it before other transforms
as well. This can be handled in a follow-up change.
@thedataking thedataking force-pushed the perl/postprocess-multiple-transforms-v2 branch from 8d01f3c to d7945cc Compare July 7, 2026 08:32
@thedataking thedataking changed the base branch from perl/postprocess-lua to master July 7, 2026 08:34
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