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::nargsreads itsparametersfield (#1200).- The
Getter::get_func_space_nameimpls for C, C++, mozcpp and Objective-C read its name side throughdeclarator_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
parametersfield holds the function’s own formal arguments.declarator_nametakes the name from the same node’sdeclaratorfield.