QDoc: recognize out-of-line-defined hidden friends
QDoc only marks a friend declaration as a hidden friend when it carries
an inline body. The C++ standard's [hidden.friends] section makes the
distinction lookup-based: a friend is hidden if no namespace-scope
declaration of it exists. Body location is incidental.
The previous heuristic forced authors of out-of-line hidden friends
(forward-declared in the class, defined in the implementation .cpp)
to either inline the body, or to fall back to the backwards-compatible
(but arguably wrong) use of the \fn command qualified with the class
name as a workaround.
This change replaces the isThisDeclarationADefinition() test with a
walk over redecls() looking for a non-friend redeclaration. With no
such redeclaration in scope, the function is hidden by definition, and
QDoc records it under its enclosing class.
Fixes: QTBUG-144141
Task-number: QTBUG-146577
Task-number: QTBUG-101649
Change-Id: I809eb00b6c61b4445250c1a197616e903b7752ac
Reviewed-by: Topi Reinio <topi.reinio@qt.io>
| commit | a1994030d0d1a0a416d487ff03846f15ad79e50f |
| parent | 8d83692c61a7f9635e1288877d44c06d96b9e2a1 |
| author | Paul Wicking <paul.wicking@qt.io> |
| committer | Paul Wicking <paul.wicking@qt.io> |
| commit time | Wed, 6 May 2026 13:36:26 +0000 |
- M src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp
- M src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/frienddeclarations/src/friendclass.h
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/hiddenfriends_fn/expected/html/hashable-members.html
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/hiddenfriends_fn/expected/html/hashable.html
- M src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/hiddenfriends_fn/expected/html/hiddenfriendmodule-module.html
- M src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/hiddenfriends_fn/expected/html/hiddenfriendsfn.index
- M src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/hiddenfriends_fn/expected/webxml/container.webxml
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/hiddenfriends_fn/expected/webxml/hashable.webxml
- M src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/hiddenfriends_fn/expected/webxml/myclass.webxml
- M src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/hiddenfriends_fn/expected/webxml/testclass.webxml
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/hiddenfriends_fn/src/hashable.cpp
- A src/qdoc/qdoc/tests/validateqdocoutputfiles/testdata/hiddenfriends_fn/src/hashable.h