Skip to main content

Module units

Module units 

Source
Expand description

Coarse unit-boundary detection over a C-family token stream.

Boundaries are the clone-report anchors: function definitions, methods (functions inside a record body), record bodies (struct/union/class) and, for C++, block-bodied lambdas. Detection is a delimiter-matching heuristic over tokens, not a parse; in Fast mode no syntax tree is built and the preprocessor never runs.

A function definition is recognised from its body brace: walking backwards over signature-trailer tokens (const, noexcept, a trailing return type, …) must reach the parameter list’s ), whose matching ( must be preceded by the function’s name. Constructor initialiser lists are walked through entry by entry. The heuristic is deliberately conservative: constructs a lexer cannot classify with confidence (K&R definitions, function-try-blocks, functions returning function pointers) are left un-anchored rather than risking spurious units.

Functions§

detect
Detect unit boundaries and recoverable boundary errors under dialect.