From 0606df12352664030b580566f5c65f94b652f147 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Fri, 13 Nov 2026 03:32:24 -0400 Subject: [PATCH] lane_syntax_check: resolve a bare macro in #if, so app/serve.cpp is actually checked The plant sweep found this the hard way. Planting an unbalanced brace in `app/serve.cpp` returned **rc 0** -- not because the check passed, but because the file was in the tool's own "not checked" bucket: lane_syntax: not checked app/serve.cpp: unresolved #if condition at line 243 Line 243 is `#if defined(ONEBIT_HRX_ALLOW_NO_SVM) && ONEBIT_HRX_ALLOW_NO_SVM`, and the filter resolved the `defined(...)` half but not the bare `ONEBIT_HRX_ALLOW_NO_SVM` beside it. A bare macro resolves exactly like its `defined()` twin when the same name is in the define set, so it is now evaluated the same way: before: 343 file(s) balanced, 8 not checked app/serve.cpp among the 8 after: 346 file(s) balanced, 5 not checked and the planted brace in serve.cpp gives rc 1 `app/serve.cpp` is the largest lane file and the one #2330's class hit in its sibling, so it being silently unchecked was the worst place for this to hide. The remaining 5 are named, not guessed (`laya/scorer.cpp`, `npu/forward/include/{attn_math,hadamard,q4nx_host_head,quant_i8}.h`). Two arms added and mutation-proven (dropping the bare-macro rule fails 2 arms): a bare macro that IS defined takes the live branch, and one that is NOT takes the other. Self-test ok, ctest lane_syntax_selftest Passed 0.03 s, copyright --check rc 0, ci_targets_check --check rc 0. --- tools/ci/lane_syntax_check.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/ci/lane_syntax_check.py b/tools/ci/lane_syntax_check.py index 6997f9d39..f37c6563a 100644 --- a/tools/ci/lane_syntax_check.py +++ b/tools/ci/lane_syntax_check.py @@ -72,6 +72,10 @@ def _truth(expr: str, defines): if m: inside = m.group(2) in defines return (not inside) if m.group(1) else inside + ident = re.fullmatch(r"([A-Za-z_]\w*)", e) + if ident: + # `#if defined(A) && A` -- the second `A` is a bare macro, resolvable the same way as the first. + return ident.group(1) in defines parts = re.split(r"\s*(&&|\|\|)\s*", e) if len(parts) == 1: return None @@ -213,6 +217,8 @@ def self_test() -> int: ("char literal brace does not count", "int f(){ char c = '{'; }", True), ("an inactive #if 0 branch is skipped", "#if 0\nint broken(){\n#endif\nint f(){ return 0; }", True), ("the ONEBIT_NPU branch is the one counted", "#ifdef ONEBIT_NPU\nint f(){\n#endif\nint g(){ return 0; }", False), + ("a bare macro resolves like its defined() twin", "#if defined(ONEBIT_NPU) && ONEBIT_NPU\nint f(){\n#endif\nint g(){ return 0; }", False), + ("a bare macro that is NOT defined takes the other branch", "#if defined(ONEBIT_NOT_SET_HERE) && ONEBIT_NOT_SET_HERE\nint f(){\n#endif\nint g(){ return 0; }", True), ] failed = 0 for name, src, ok in arms: