Skip to content

fix: using declaration names and anchors - #1317

Open
gennaroprota wants to merge 2 commits into
cppalliance:developfrom
gennaroprota:fix/using_declaration_names_and_anchors
Open

gennaroprota wants to merge 2 commits into
cppalliance:developfrom
gennaroprota:fix/using_declaration_names_and_anchors

Conversation

@gennaroprota

@gennaroprota gennaroprota commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

This PR fixes the two defects #1276 reports in the "Using Declarations" table: an entry labeled "Unnamed using", and a link that renders as raw AsciiDoc. Both show up with a base that depends on a template parameter, or with a target the filters removed.

Inheriting constructors are named after their base. using Base::Base; was named after the derived class, with the synopsis using Base::Derived;, or, with a dependent base, not named at all ("Unnamed using", using Base<T>::;). The name now comes from the last component of the qualifier, as written: a class, a class template specialization, an alias or a template parameter. Lookup passes over these declarations, so a @ref Base or @copydoc Base written in the derived class still finds the class.

Operators named by a using-declaration get a usable anchor. Without a shadow declaration to take its anchor from, such a declaration used its own name, punctuation included: operator[] broke the AsciiDoc link, operator-> linked to a page that doesn't exist, operator/ created a subdirectory, and, on Windows, an operator spelled with ", *, <, > or | stopped the generation. It now gets the anchor the operator itself would get, such as operator_subs; a conversion gets the shared 2conversion, and a literal operator drops its quotes. The anchor is derived from the operator's name rather than from an operator kind recorded on the declaration, which would change the public data model and the schema for this one fallback.

Changes

  • Source: ASTVisitor names an inheriting constructor from its qualifier, Corpus lookup passes over it, and AnchorFinalizer gives a using-declaration of an operator the operator's anchor.
  • Tests: Golden fixtures, with XML and AsciiDoc output, for inheriting constructors (concrete, dependent and template-parameter bases, a pack, aliases), for inherited operators, for filtered bases, and for @ref and @copydoc naming the base.
  • Breaking changes: The affected declarations get new anchors, so their pages and the links to them move. Most of those links didn't resolve before.

Testing

The golden fixtures above. The existing using-member-function.xml now names its inheriting constructors after their bases. For a pack, using Bases::Bases...;, the fixture pins only the name and the heading, because the synopsis doesn't show the ... yet (#1357).

Documentation

None needed: no option, command or documented behavior changes.

Closes #1276.

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

✨ Highlights

  • 🧪 Existing golden tests changed (behavior likely shifted)

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🥇 Golden Tests 98% 5923 5896 27 16 12 4 - -
🛠️ Source 2% 109 88 21 3 - 3 - -
Total 100% 6032 5984 48 19 12 7 - -

Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)

🔝 Top Files

  • tests/golden/fixtures/symbols/using/using-inheriting-constructor.xml (Golden Tests): 1478 lines Δ (+1478 / -0)
  • tests/golden/fixtures/symbols/using/using-inherited-operator.xml (Golden Tests): 1087 lines Δ (+1087 / -0)
  • tests/golden/fixtures/javadoc/ref/inheriting-constructor-base.xml (Golden Tests): 1008 lines Δ (+1008 / -0)

Generated by 🚫 dangerJS against f7215bc

@gennaroprota gennaroprota changed the title Fix/using declaration names and anchors fix: using declaration names and anchors Sep 22, 2026
@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.21%. Comparing base (b45d019) to head (f7215bc).
⚠️ Report is 38 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1317      +/-   ##
===========================================
+ Coverage    83.12%   83.21%   +0.09%     
===========================================
  Files           35       35              
  Lines         3662     3670       +8     
  Branches       844      845       +1     
===========================================
+ Hits          3044     3054      +10     
  Misses         410      410              
+ Partials       208      206       -2     
Flag Coverage Δ
bootstrap 83.21% <ø> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cppalliance-bot

cppalliance-bot commented Sep 22, 2026 •

Copy link
Copy Markdown

An automated preview of the documentation is available at https://1317.mrdocs.prtest2.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-10-14 14:33:48 UTC

This fixes a bug for which an inheriting constructor was documented
under the wrong name, or under no name at all. The synopsis of `using
Base::Base;` read `using Base::Derived;`, and the heading and the member
table gave the declaration the derived class's name, so several of them
in one class were indistinguishable. With a base that depends on a
template parameter the name came out empty instead, reaching the page as
"Unnamed using" and the synopsis as `using Base<T>::;`.

Clang stores the first as a constructor of the derived class, and the
second as a constructor of a type that has no class behind it at all. We
now take the name from the last component of the qualifier, which spells
the class as written, be it a class, a class template specialization, an
alias or a template parameter.

A declaration named after the base would hide the base from references
written in the derived class or in its members, such as `@ref Base` or
`@copydoc Base`, since lookup searches the members of a class before the
enclosing scopes. Lookup now passes over an inheriting constructor, so
these references still resolve to the base class.

I've added tests.

Refs cppalliance#1276.
This fixes a bug for which a using-declaration that names an operator
produced a page no link could reach, and sometimes no page at all.
`operator[]` broke the link, because AsciiDoc ends a link target at the
first bracket. `operator->` and `operator<=>` broke more quietly,
because AsciiDoc rewrites `->` and `=>` inside the target as arrow
characters, and the link then points at a page that does not exist.
`operator/` put the page inside a directory of its own, because a slash
is a path separator. A conversion such as `operator bool` got a space in
the file name and in the link. On Windows a file name cannot hold `"`,
`*`, `<`, `>` or `|` at all, so every operator spelled with one of those
could not be opened and generation stopped with an error.

The anchor is what a page file name and a link are built from, so it has
to be a plain identifier. A using-declaration does not make one up: it
takes the anchor of its first shadow declaration, which is safe already,
an operator having gone through the table of safe operator names. There
are no shadow declarations when the base depends on a template
parameter, since the name cannot be looked up before the template is
instantiated, nor when the filters removed the target. The anchor then
fell back to the declaration's own name, punctuation and all.

All of them now take the anchor the operator itself would get (e.g.
`operator_subs` for `operator[]`), and a conversion takes the one that
every conversion shares. A literal operator such as `operator""_km`
drops its double quotes, as the anchor of the literal operator itself
already does.

I've added tests.

Fixes cppalliance#1276.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strange broken "Unnamed using" link in new "Using declarations"

2 participants