QDoc: Attribute broken-link warnings to the originating directive


Broken-link warnings from the template generator's link resolver have
pointed at the relative node's documentation block since the IR
pipeline replaced HtmlGenerator's direct atom traversal. The relative
node is whichever page LinkResolver is currently walking — for
inherited content (a parent class's \sa propagated into a derived
page's detail sections) that page is the inheritor, far from the file
and line that authored the reference. Readers chasing a warning to
the cited location find no link there, only the inheriting type's
preamble. The legacy HtmlGenerator preserved the authoring location
through LinkAtom::location; the template generator dropped that
information when ContentBuilder converted Atom::Link to
InlineContent::Link.

The IR now carries the originating atom's source file and line as an
optional SourceLocation on LinkData. ContentBuilder captures them
from each LinkAtom it encounters; LinkResolver reaches for them first
when emitting Can't-link-to and Can't-autolink-to warnings, falling
back to the relative node's location for links that arrived without
an attached origin. Builder-synthesized links bypass ContentBuilder
and so take the fallback path — pointing at the inheriting page is
the right attribution there, since the synthesized link has no
author-written origin. Diagnostics now point at the line a maintainer
can actually edit.

A new validateqdocoutputfiles fixture exercises the five attribution
shapes the redesign was scoped to handle: bare-form \l, bracketed-form
\l with custom display text, autolink, paragraph with trailing inlines
after a broken link, and a broken link inside formatting. The expected
warning log captures the corrected file and line for each case.

Fixes: QTBUG-146722
Change-Id: I24ffb121b23d891bfdbc68ad2cd0dcd58ac675de
Reviewed-by: Topi Reinio <topi.reinio@qt.io>
commita59ad01a9d488b91cccd802cfc8c7e76696a93c6
parenta13497c92b49a6896a69c65dc6fddea83a93625b
authorPaul Wicking <paul.wicking@qt.io>
committerPaul Wicking <paul.wicking@qt.io>
commit timeWed, 13 May 2026 07:05:36 +0000