Fix function pointer param args being qualified to outer class (#56217)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56217

Changelog: [Internal]

Doxygen may incorrectly cross-reference parameter names inside function
pointer types to member variables of the enclosing class. For example,
`void (*cb)(const void* data)` inside a class that has a `data` member
would produce `const void* Class::data` instead of
`const void* data` in the snapshot. This diff addresses two issues:

1. In `get_doxygen_params`, re-parse function pointer type strings
   through `parse_type_with_argstrings` which delegates to
   `_parse_single_argument` that already strips "::" from parameter
   names.
2. In `parse_type_with_argstrings`, recognize complex declarator groups
   starting with `*` or `&` (e.g. `*(*fp)(int)`) as non-argument-list
   parenthesized sections, preventing incorrect name extraction from
   nested function pointer declarators.

Reviewed By: cipolleschi

Differential Revision: D98118629

fbshipit-source-id: a8532e2adaec1dd2b50be8a20eae1068ac49d548
This commit is contained in:
Jakub Piasecki authored and meta-codesync[bot] committed 2026-03-26 08:40:54 -07:00
1 parent cc9d06bef7
commit 31f262ed2e
4 files changed
+46 -1

No files matched your search

+16 -1
View File
@@ -41,7 +41,12 @@ from .utils import (
resolve_linked_text_name,
split_specialization,
)
from .utils.argument_parsing import _find_matching_angle, _split_arguments
from .utils.argument_parsing import (
_find_matching_angle,
_split_arguments,
format_parsed_type,
parse_type_with_argstrings,
)
@dataclass
@@ -307,6 +312,16 @@ def get_doxygen_params(
if param.get_type()
else ""
)
# Doxygen may incorrectly cross-reference parameter names inside
# inline function pointer types to member variables of the enclosing
# class, producing qualified paths like "const void*
# ns::Class::data" instead of "const void* data". Re-parse the
# type through parse_type_with_argstrings which delegates to
# _parse_single_argument — that already strips "::" from names.
segments = parse_type_with_argstrings(param_type)
if len(segments) > 1:
param_type = format_parsed_type(segments)
param_name = param.declname or param.defname or None
param_default = (
resolve_linked_text_name(param.defval)[0].strip() if param.defval else None
@@ -530,6 +530,14 @@ def parse_type_with_argstrings(
i = close + 1
continue
# Complex declarator starting with * or &, e.g. *(*fp)(int)
# in "int(*(*fp)(int))(double)". Argument lists never start
# with pointer/reference characters.
if stripped and stripped[0] in ("*", "&"):
current_text.append(type_str[i : close + 1])
i = close + 1
continue
# Try to parse as a function argument list
args: list[Argument] = []
if stripped: