Repository navigation
Conversation
Use the C grammar for native C AST analysis while honoring compilation-language overrides and recognized compiler-driver defaults. Reuse compilation-database normalization for dependency analysis and prepare grammar selection per phase invocation. Preserve shared phase aggregation and header behavior, disclose conflicting compilation contexts, and cover C keyword identifiers, explicit C++ compilation, path normalization, optional parsers, and scan isolation with regression tests.
github-actions Bot
added a commit
to citizenadam/desloppify
that referenced
this pull request
Oct 29, 2026
This branch has not been deployed
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.
Problem and reproduced behavior
The existing
cxxplugin binds its Tree-sitter AST phases toCPP_SPECfor every discovered file, including native C. This produces two demonstrated defects in valid C17 code:throwis an ordinary C identifier. Invoid dispatch(void (*throw)(int), void (*cleanup)(void)) { throw(1); cleanup(); }, the C++ grammar interprets the call as a throw statement and reports the reachablecleanup()call as unreachable. Both grammars accept the source without syntax errors, so parse-error fallback cannot disambiguate it.mutableis silently omitted by the C++ function query. The cohesion regression fixture consequently yields seven functions instead of eight, dropping below the detector's minimum and suppressing an otherwise valid cohesion finding.Dispatch also needs to preserve existing C++ behavior for a
.ctranslation unit explicitly compiled as C++. For example,void f() { throw(1); f(); }compiled with-x c++ -std=c++17must retain the unreachable-code finding after the throw. Selecting C solely from the extension would introduce the inverse false negative; bothargumentsandcommandcompilation-database regressions cover this case.Implementation
.cuses C and ordinary C++ sources use C++. Headers, including.h, retain their established C++ parsing policy.-xmodes, joined forms and-x none, supported MSVC/TC//TPand per-file/Tc//Tpforms, recognized C++ driver defaults, simple compiler-cache wrappers, and Clang--driver-mode. Do not infer input language from-std=alone; driver/override behavior was checked with installed compilers.There is no separate C plugin, parser framework, or new package dependency.
Validation
Executed locally on Python 3.14 / Linux with Tree-sitter 0.26.0 and tree-sitter-language-pack 1.6.2. Parser-dependent runs used an already-populated temporary grammar cache via
XDG_CACHE_HOME; all Python commands used the project virtualenv..venv/bin/python -m pytest desloppify/languages/cxx/tests -q.venv/bin/python -m pytest desloppify/tests/lang/common -q.venv/bin/python -m pytest -q.venv/bin/python -m ruff check . --select E9,F63,F7,F82git diff --checkThe focused Cxx/shared suites were rerun immediately before committing: 589 passed, 2 skipped. Coverage includes both DB representations, native C-only and mixed projects, C++ source/header preservation, relative paths and quoted filenames, language-option precedence, malformed metadata, independent scan roots and metadata edits in one process, conflict handling, parser-cache separation, missing optional parsers, scan integration and per-phase DB load counts.
C17/C++17 syntax checks of the reproducers passed, including clang-cl checks with C/C++ modes. CLI scans confirm that native C retains only the genuine finding after
return, while the explicit C++ case retains the finding afterthrow; each has unreachable potential count 1. The conflicting-context scan produces the documented warning and low-confidence result. These scans had reduced external-tool coverage because cppcheck was unavailable; they are evidence for the AST changes, not a claim of complete native analysis.Known baseline full-suite failures (not fixed here)
Both failures were independently reproduced by running the exact tests against untouched upstream base 3a7735d:
desloppify/tests/review/integration/test_review_commands.py::TestCmdReviewPrepare::test_do_run_batches_dry_run_generates_packet_and_promptsdesloppify/tests/review/test_review_commands.py::TestCmdReviewPrepare::test_do_run_batches_dry_run_generates_packet_and_promptsBoth assert that the first generated review prompt contains
Previously flagged issues; the assertion fails on the base and this branch. They remain disclosed failures, not xfailed, skipped or weakened tests. The previous full-suite baseline was 6,845 passed, 18 skipped and these same two failures; the additional 57 Cxx cases account for the increase to 6,902 passing tests.Remaining limitations
arguments. MSVC option behavior was checked using clang-cl on Linux, not a native Windows installation.compile_commands.json; no new ancestor/build-directory discovery was added.Description written with claude.