Skip to content

fix(cpp): recover callables after preprocessor-gated signatures#949

Open
blankanswer wants to merge 2 commits into
DeusData:mainfrom
blankanswer:agent/fix-cpp-preproc-signature-gap
Open

fix(cpp): recover callables after preprocessor-gated signatures#949
blankanswer wants to merge 2 commits into
DeusData:mainfrom
blankanswer:agent/fix-cpp-preproc-signature-gap

Conversation

@blankanswer

Copy link
Copy Markdown

Summary

Fixes #946.

C++ files that gate alternate out-of-line method signatures with #ifdef / #else / #endif can confuse the raw tree-sitter parse and cause methods after the conditional block to disappear from the graph.

This PR extends the existing C/C++/CUDA preprocessor second pass so it can recover missing Function / Method definitions from the expanded AST, while keeping the normal raw-source extraction as the primary source of truth.

What Changed

  • Added a regression test for the SurfaceFlinger-style conditional signature shape.
  • Added a lightweight definition-walker entry point that does not emit a Module node or variables.
  • During the existing preprocessor second pass, merge only missing callable definitions from the expanded AST.
  • Deduplicate recovered callables by label + qualified_name.
  • Did not change vendored tree-sitter grammars.

Validation

  • make -f Makefile.cbm SANITIZE= build/c/test-runner build/c/codebase-memory-mcp
  • build/c/test-runner extraction — 211 passed
  • build/c/test-runner c_lsp — 750 passed
  • git diff --check
  • CLI smoke test with a temporary C++ repo:
    • index_repository
    • search_graph verified both commit and composite are indexed after the #ifdef/#else/#endif signature block.

Signed-off-by: Blank_Answer <97771966+blankanswer@users.noreply.github.com>
@blankanswer blankanswer requested a review from DeusData as a code owner July 8, 2026 04:38
Signed-off-by: Blank_Answer <97771966+blankanswer@users.noreply.github.com>
@DeusData DeusData added bug Something isn't working parsing/quality Graph extraction bugs, false positives, missing edges priority/normal Standard review queue; useful PR with ordinary maintainer urgency. labels Jul 8, 2026
@DeusData DeusData mentioned this pull request Jul 8, 2026
2 tasks
@DeusData

DeusData commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Thanks for the focused C++ parser fix. Triage: parser recovery bug for #946, normal priority. Review focus is ownership of recovered callables, avoiding duplicate definitions across #ifdef branches, and keeping unrelated extraction behavior unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working parsing/quality Graph extraction bugs, false positives, missing edges priority/normal Standard review queue; useful PR with ordinary maintainer urgency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug for parse c++

2 participants