Skip to content

C/C++ args regex doesn't recognize SAL annotation macros (_In_/_Out_/_Inout_) as valid parameter prefixes #1883

Description

@squid-protocol

Description

Found while verifying #1836/#1837/#1854 (the C/C++ args-bounding and preprocessor-macro fixes) via tests/tools/crucible_check.py's differential scan. Windows SAL (Source-code Annotation Language) macros like _In_, _Out_, _Inout_ prefix parameter declarations in real Windows/PowerToys-style C++ headers (_In_ int nCode, _In_ WPARAM wParam), and gitgalaxy/standards/language_standards.py's cpp args regex requires a real typed-parameter shape after the opening paren -- a leading unrecognized macro token like _In_ doesn't match any of its typed-parameter alternatives, so the whole args_pattern.search() call returns no match at all.

Confirmed repro

from gitgalaxy.standards.language_standards import LANGUAGE_DEFINITIONS
args = LANGUAGE_DEFINITIONS["cpp"]["rules"]["args"]
s = "LRESULT CALLBACK KeyboardHookProc(_In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam)"
print(args.search(s))  # None

powertoys/centralized_kb_hook.cpp::KeyboardHookProc (real arity 3) measures args_count=0 once the signature search is correctly bounded to just the signature (as #1836 now does) -- previously this got a non-zero but still-wrong count purely by accident, from cpp's old unbounded search incidentally matching something else in the function body.

Scope / prevalence

Narrow: only 2 files in the current language-crucible cpp corpus contain SAL-style _In_ /_Out_ /_Inout_ annotations (grep -rlE '_In_ |_Out_ |_Inout_ ' language-crucible/data/cpp/). Not chased as part of #1836/#1837/#1854 since it's a distinct regex gap (unrecognized parameter-type token), not a bounding/preprocessor/depth-counting bug.

Suggested fix

Add _In_, _Out_, _Inout_, _In_opt_, _Out_opt_ (and similar leading-underscore SAL annotation tokens) as an optional, bounded prefix alternative in the cpp/c args regex's typed-parameter branch, mirroring how const/volatile are already handled as optional leading modifiers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnintended behavior or logic failure in the enginecore-engineModifications to the central physics and parsing enginetestingUnit, integration, and E2E pipeline verification

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions