QDoc: Fix hidden friend lookup when name clashes exist
When a hidden friend function shares its name with a free template
in the same translation unit, the documentation lookup fails to
find the hidden friend. The initial search locates only the
template in the global namespace and stops there, because the
hidden friend is stored under its enclosing class. This causes
the \fn command to go unmatched, and the function's documentation
silently disappears from the output.
A related problem affects the \relates command. Hidden friends are
marked as related non-members during initial parsing, so a later
\relates directive that targets a different class is skipped
entirely. This prevents authors from documenting a hidden friend
on a conceptually related class's page, which is a common pattern
for customization points such as hashing or serialization helpers.
The lookup now also searches enclosing classes when no hidden
friend candidate exists among the initial results, rather than
only when no candidates exist at all. The \relates resolution now
distinguishes between a node that's already been adopted by a
different target and one that still belongs to its original parent.
This ensures hidden friends appear on the intended page even when
name collisions or cross-class relationships are involved.
Note: This change depends on the hidden friend infrastructure
introduced in commits 752291bff and 51167e9ba, which target 6.12.
Thus, this change cannot be cherry-picked to earlier branches.
Fixes: QTBUG-145790
Task-number: QTBUG-124306
Change-Id: Ic600dcd015c2ecaa06411eef4131525d501be180
Reviewed-by: Topi Reinio <topi.reinio@qt.io>