Skip to content

fix(discover): select C++ for C-family .inc fragments - #2826

Open
knewstimek wants to merge 2 commits into
DeusData:mainfrom
knewstimek:fix/inc-c-family-routing
Open

knewstimek wants to merge 2 commits into
DeusData:mainfrom
knewstimek:fix/inc-c-family-routing

Conversation

@knewstimek

Copy link
Copy Markdown
Contributor

C/C++ .inc fragments currently reach the BitBake or ObjectScript grammar, so normal C++ linkage declarations and function definitions can disappear from the graph. Recognize explicit C-family code and select the C++ grammar before extraction.

Closes #2825

The existing 4 KiB content probe is retained, and byte-based classification and disk discovery still share lang_inc_text. Leading C comments are skipped; BitBake assignments and shell/Python task bodies are recognized before embedded C-like text. Explicit ObjectScript markers retain precedence, a lone #define retains its existing ObjectScript fallback, and unknown/unreadable content retains BitBake.

Tests use synthetic identifiers only and cover the byte classifier, both disk entry points, linkage/callback extraction, and actual fast/full pipeline indexing. This changes grammar selection; it does not reconstruct the enclosing function at an include site or promise arbitrary external-header macro expansion. Runtime coordination, schemas, public tools, and dependencies are unchanged.

Validation on Windows x64 with LLVM-MinGW/Clang 23:

  • scripts/test.sh --suites language,extraction BUILD_DIR=r CC=clang CXX=clang++ CXX_STDLIB=-lc++ SANITIZE=: 743 passed (local zlib paths supplied through the environment).
  • CBM_TEST_ONLY=pipeline:pipeline_inc_c_family_fragments r/test-runner pipeline: 1 passed, exercising fast and full modes.
  • The new classifier fixture table against the unmodified detector has 6 mismatches; the changed detector has none.
  • Diff-scoped clang-tidy passed; changed code was formatted and git diff --check passed.
  • Full lint is not claimed: scripts/lint.sh --ci was attempted, but this host lacks cppcheck and its formatter reports differences in existing untouched files. Linux and sanitizer validation are left to CI.

Related work checked: #467 introduced the current BitBake/ObjectScript routing; #778 is PHP/Drupal extension support; #2629 is raw/preprocessed-definition deduplication. No equivalent C-family .inc routing fix was found among the searched open and closed issues/PRs.

AI-assisted implementation and verification with Codex.

Recognize explicit C-family code in .inc files before extraction while
preserving BitBake recipe bodies and ObjectScript markers. Exercise disk
and byte classifiers, callback/linkage extraction and fast/full indexing.

Signed-off-by: knewstimek <knewstimek@users.noreply.github.com>
@knewstimek
knewstimek requested a review from DeusData as a code owner October 28, 2026 22:06
@github-actions

Copy link
Copy Markdown

Thanks for opening this — it has been seen, and it is queued.

This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence.

Current review status: working through a backlog. 0.9.1-rc.1 is out, so the release freeze that held reviews is over — but it left a large queue of open pull requests behind it, and we are reading through them oldest-first. The background is in discussion #1144.

What that means for this PR, concretely:

  • It will not be closed for inactivity. No stale bot touches pull requests here.
  • It may still sit a while before a human reads it. That is on us, not on you.
  • Older PRs are read first, so a recent one is not being skipped — it is behind a queue.

Things that will genuinely speed it up whenever review does happen:

  • Keep it rebased on main — the tree is moving quickly right now, and a conflicting branch cannot be reviewed as the diff you intended.
  • Get CI green, or say which failures you believe are pre-existing.
  • Keep the change to one claim. Bundled features and refactors get split before they get merged, which costs you a round trip.
  • Every commit needs a sign-off (git commit -s) — CI enforces DCO.

If this fixes a bug, a reproduction we can run is worth more than a description of the symptom.

Thanks for contributing, and sorry in advance for the wait.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
@DeusData

Copy link
Copy Markdown
Owner

Thank you very much for this fix, @knewstimek, and for filing #2825 with such a clear synthetic reproduction first.

We have reviewed it and measured it on real code. On 294 .inc files from LLVM, compiler-rt, the .NET runtime and the Linux kernel, your classifier moves about 100 to C++, and the large majority really are C/C++: 60 of them could not be parsed at all before, and the graph gains real functions, methods, macros and call edges for them. Both of your routing tests fail on main for the right reason and pass with your change.

Another pull request (#2421) landed on main tonight and also edits src/discover/language.c and discover.h, so we merged current main into your branch (one merge commit, d841ddd; it merged cleanly and your own change is untouched) to get a CI run against today's main. We will follow up here once that run is through. Please pull before pushing again.

This branch has not been deployed

No deployments
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.

C/C++ .inc fragments are classified as BitBake or ObjectScript

2 participants