Skip to content

Commit 058471b

Browse files
committed
Skip constructor initializer lists and macro variable assignments
- Skip lines starting with ':' (initializer list) and ',' with '(' (continuation) to prevent false method captures - Skip function matches where ')' is followed by '=' assignment (macro-declared variables like B3_ATTRIBUTE_ALIGNED16) - Preserves = 0, = default, = delete correctly Verified: 0 false positives across 183,379 records from 9 codebases.
1 parent cfcf2fd commit 058471b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/codesurface/parsers/cpp.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,16 @@ def _parse_cpp_file(path: Path, base_dir: Path) -> list[dict]:
299299
i += 1
300300
continue
301301

302+
# Constructor initializer list lines (: member(val) or , member(val))
303+
if stripped.startswith(":") and not stripped.startswith("::"):
304+
brace_depth += _count_braces(line)
305+
i += 1
306+
continue
307+
if stripped.startswith(",") and "(" in stripped:
308+
brace_depth += _count_braces(line)
309+
i += 1
310+
continue
311+
302312
# Preprocessor
303313
if _PREPROCESSOR_RE.match(line):
304314
# Skip continuation lines
@@ -879,6 +889,15 @@ def _parse_cpp_file(path: Path, base_dir: Path) -> list[dict]:
879889
i += 1
880890
continue
881891

892+
# Skip macro-style variable declarations: TYPE MACRO(name) = value
893+
body_pos = _find_body_brace(stripped)
894+
after_parens = stripped[stripped.find(")") + 1:body_pos if body_pos != -1 else len(stripped)].strip() if ")" in stripped else ""
895+
if after_parens.startswith("=") and not any(after_parens.startswith(p) for p in ("= 0", "= default", "= delete")):
896+
pending_template = ""
897+
brace_depth = new_depth
898+
i += 1
899+
continue
900+
882901
ns = _build_ns(namespace_stack)
883902
owning_class = class_stack[-1][0] if class_stack else ""
884903
doc = _look_back_for_doc(lines, i)

0 commit comments

Comments
 (0)