Skip to main content

Module c_declarator

Module c_declarator 

Source
Expand description

The C-family declarator-chain walk, shared by the two surfaces that need it.

C declarator syntax nests outward from the declared name, so neither a function’s parameter list nor its name is reliably a child of the function node itself. Both are found from the one node innermost_declarator returns — the innermost link on the chain that is the function’s own declarator rather than its return type’s:

  • big_code_analysis::metrics::nargs reads its parameters field (#1200).
  • The Getter::get_func_space_name impls for C, C++, mozcpp and Objective-C read its name side through declarator_name (#1208).

Keeping one walk keeps the two answers about the same function from disagreeing, which is how #1208 arose: the arity came from this chain and the name came from a leftmost pre-order search that stopped one level too early. The invariant is one function, one walk — not one node: an unexpanded function-like macro puts the arity and the name on two links of the chain, which each function’s own doc below explains (#1213).

Functions§

declarator_name
The node spelling a C-family function’s name.
innermost_declarator
The innermost declarator along a C-family function’s declarator chain: the node whose parameters field holds the function’s own formal arguments. declarator_name takes the name from the same node’s declarator field.