Repository navigation
C/C++: function-defining macros (CCMD, DEFINE_ACTION_FUNCTION, FUNC, TEST) are functions (Part of #5461) - #5483
Conversation
…TEST) are functions (Part of #5461) Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…bless goldens (Part of #5461) The second-argument naming rule turned `NB_MODULE(stablehlo_extension, m) {` into a function named `m` (a variable). `*MODULE` macros now fall to the generic branch. Both golden masters re-blessed via golden-lock + crucible_check; drift is the new C/C++ macro functions and the PageRank renormalisation they cause. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
No description provided. |
|
No description provided. |
|
PR #5483 @ 3dafc79: 1 failed check(s) == tree-sitter-accuracy-audit (failure) -- real |
… of #5461) An indented `MACRO(x) {` sits inside a function body, where it is a statement macro: godot gdscript_vm.cpp's `OPCODE(OPCODE_JUMP) {` expands to `case`, `OPCODE_WHILE(true) {` to `while`. The macro branch named 93 such "functions", which tree-sitter-accuracy-audit's ERROR-region promotion surfaced as cpp real_functions 1381 -> 1474. Column 0 matches the issue's own corpus measurement (`^[A-Z]...`). Both goldens re-bless byte-identical to main: every earlier golden change was these false positives. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
CI shepherd: the head of this PR (c93064e) is not the one a maintainer labelled |
|
No description provided. |
1 similar comment
|
No description provided. |
|
PR #5483 @ c93064e: 2 failed check(s) == full-suite (failure) -- real == full-suite part 1/3 (failure) -- real |
…in (#5511) pinned_ruff_lint / pinned_mypy_audit matched the caller's ruff/mypy against CI's pin, then ran the audit under `env -i PATH=<interpreter bin>:/usr/bin:/bin`. churn's precheck runs pr_gates under /usr/bin/python3 while the pinned ruff sits on ~/.local/bin (nyx), so that PATH had no ruff: lint failed in 0 s with FileNotFoundError and green PRs (#5483, #5493, #5504) were sent back; workers rerunning under the venv python could never reproduce it. Co-authored-by: Joe Esquibel <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
…on, statement = not) (Part of #5461) When the macro's #define is in the scanned file, MACRO(args) { is a function only if some variant of the define expands to a signature (odamex FUNC); do{}while(0), case, while and expression defines are not. No define: the invocation rule stands. Fixtures for both. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
CI shepherd: the head of this PR (2433e8c) is not the one a maintainer labelled |
|
No description provided. |
|
No description provided. |
|
PR #5483 @ 2433e8c: 1 failed check(s) == graph-accuracy-audit (failure) -- real |
Part of #5461.
What
func_startfor C and C++ gains a macro alternative: an ALL-CAPS macro (3+ chars) at column 0 whose argument list is plain identifiers and is followed by{is a function. Name rule: the only argument; of several, the second (Class, name/Type, name/Suite, Name). Excluded: control-flow shouts,BEGIN/END/ASSERT/CASE/RETURN, class-like names (*PIMPL*,*NAMESPACE*,*CLASS*,*STRUCT*,*ENUM*,*TEMPLATE*,*UNION*,*MODULE*), nested calls and operators in the arguments. The macro name lands in group 2, so the generic branch keeps group 1. In C++ the generic branch is guarded so it no longer names the macro itself (CCMD) on these lines. Shared source:_shared_patterns.C_MACRO_FUNC_START_SOURCE.Why column 0: an indented
MACRO(x) {sits inside a body, where it is a statement macro. godotgdscript_vm.cpp'sOPCODE(OPCODE_JUMP) {expands tocase, andOPCODE_WHILE(true) {expands towhile. Before the anchor, the branch produced 93 false functions there, andtree-sitter-accuracy-auditcaught them as cppreal_functions1381 -> 1474 (its ERROR-region promotion). The issue's own corpus count also anchors at column 0 (^[A-Z]...).Class table (macro-introduced definitions)
DEFINE_ACTION_FUNCTION[_NATIVE/_PARAMS],CCMD,CUSTOM_CVAR,CONSOLE_COMMAND,BEGIN_COMMAND,D_CMD,DEFINE_ACTION, odamexFUNC, gtestTEST/TEST_F(all at column 0)NB_MODULE(name, m)mis a variable)DE_PIMPLDEFINE_PROPERTY,DEFINE_MAP_OPTION,DEFINE_CLASS_PROPERTYDEFINE_PROPERTY(name, Type, Class)): sibling gap#define-expansion lookup (odamexFUNC)#definein the same file (see Owner decisions); a define in another file (a header) is not looked up: scan workers are per-file, no repo-wide macro table existsEvidence
common/p_lnspec.cppat the final head: 193 functions, 188 of themLS_*handlers (all 188FUNC(lines).golden-lock.sh crucible_check.py --update --yesre-blessed both fixtures byte-identical to main. Every golden change in earlier heads was the indented false positives.tree_sitter_accuracy_audit.py --lang cpp --ciand--lang c --ci: OK, matching the baseline (cppreal_functionsback to 1381).test_c_macro_funcs_5461.py(37, incl. a godotOPCODEregression test, also run as plainpytestfrom/tmp) +test_c_strict.py+test_cpp_strict.py: 207 passed.pr_gates --fast: 6/6 PASS.pr_gates --ratchets: 8/8 PASS.Remaining slices:
DEFINE_PROPERTY-style name rule; gzdoom/zandronum rescan numbers.Owner decisions
How it is done:
detector._slice_by_braces(c/cpp) reads each#define NAME(params) bodyin the file (continuation lines joined). A define is a signature when the text before its first(has 2+ words, no leading statement word (do/while/case/return...), no{};, and names a macro parameter or a##paste. A macro-branch match whose macro has in-file defines and none is a signature is dropped; one signature variant in an#ifladder keeps it. Tests:test_c_macro_funcs_5461.py(57; signature, continued-line,##,do{}while,case,while, expression,#ifladder, no define).test_c.py/test_cpp.pymacro-shield tests untouched.Limit: "in the scanned tree" is implemented as "in the same file". Scan workers are per-file and there is no repo-wide macro table, so an odamex-style
FUNCdefined in a header and used in a.cppkeeps the invocation rule (still a function). The rawstruct_func_startcount is unfiltered; only the named function list applies the define rule.Re-verified at this head:
tests/extraction/languages9549 passed; goldens (golden-lock.sh crucible_check.py) both PASS, zero drift;tree_sitter_accuracy_audit --lang cpp/c --ciOK; ruff format clean. Localaudit_checkmypy lists 16 findings in untouched lines (no stubs in my env), none in new code.Lessons for agents
tree-sitter-accuracy-audit's "ground-truth drifted ... corpus changed" is not always about the corpus. For cpp/rust/fortran/zig/csharp, GitGalaxy matches inside tree-sitter ERROR regions get promoted intoreal_functions, so an engine false positive there shows up as ground-truth drift. Difffunction_databetween a main scan and a branch scan oflanguage-crucible/data/<lang>to find it.func_startalternative that adds ~1k lines of golden drift deserves a look at which functions it added before you bless.🤖 Generated with Claude Code