[codex] Fix C preprocessor-heavy symbol extraction#579
Merged
Conversation
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.
Summary
Fixes #577.
Fixes #578.
This PR hardens C/C++ function extraction for preprocessor-heavy source files and fixes JSON symbol names for C functions.
Root Cause
C tree-sitter
function_definitionnodes do not expose the function identifier through the genericnamefield. The generic symbol extractor fell through to thetypefield, so JSON output reported return types such asvoid,NORETURN,size_t, andcharas function names.For
#ifdef-heavy C bodies, tree-sitter can also fail to expose some function definitions as normal symbol nodes. In the rsync repro,acls.comittedchange_sacl_permsbecause of nested preprocessor conditionals inside the function body.Changes
probe symbolsso preprocessor-heavy function bodies are still emitted.probe querypatterns without widening body-specific queries.Validation
cargo test extract::symbols --libcargo test test_query_c_function_inside_preprocessor_heavy_body --test query_command_testscargo test test_query_c_recovery_does_not_widen_body_specific_patterns --test query_command_testscargo check --bin probecargo test test_c_outline_basic_symbols --test c_outline_format_testsManual repro checks against local rsync source:
probe symbols --format json io.cnow reportscheck_timeout,whine_about_eof,safe_read,what_fd_is,safe_writeinstead of return types.probe symbols --format json acls.cnow includeschange_sacl_permsand does not include earlier fallback false positives such asiforversions.probe query '$RET $NAME($$$PARAMS) { $$$BODY }' acls.c --language c --format jsonnow includeschange_sacl_perms.