postprocess: Add AssertsTransform and FormattingTransform and GPT tool calling#1855
Draft
thedataking wants to merge 12 commits into
Draft
postprocess: Add AssertsTransform and FormattingTransform and GPT tool calling#1855thedataking wants to merge 12 commits into
AssertsTransform and FormattingTransform and GPT tool calling#1855thedataking wants to merge 12 commits into
Conversation
962e684 to
8d01f3c
Compare
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.
8d01f3c to
d7945cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Probably needs to be split into smaller bits.
TODO:
AssertTransformmight need different validations with different C libraries/hosts.