Skip to content

feat(config): inherit hidden friends of base classes - #1329

Merged
alandefreitas merged 15 commits into
cppalliance:developfrom
alandefreitas:feat/inherit-hidden-friends
Sep 30, 2026
Merged

alandefreitas merged 15 commits into
cppalliance:developfrom
alandefreitas:feat/inherit-hidden-friends

Conversation

@alandefreitas

Copy link
Copy Markdown
Collaborator

A class whose operators are hidden friends of a base loses them from the reference when that base is filtered out. This is the shape mp-units (see #1309) uses for every operator on its quantity type, and our own demo of that library showed no comparison operators at all. This is a common C++ idiom.

This PR adds a setting that carries a base's hidden friends onto the classes that inherit them. It mirrors the existing setting for inherited members: never, reference, copy dependencies, or copy all. A copy is placed in the derived class's namespace with its parameter types changed to the derived type, and its page says which class declared it. Every function now also records which class it is a hidden friend of (#124), so its page can explain why ordinary lookup can't find the name.

The other commits are problems this feature ran into, since this feature is very complex and sensitive to edge cases.

  • A derived class that declared a base member again under different parameter names was not seen as the same function, so the member was listed twice.
  • Implementation-defined bases were literally named as placeholders in class summaries instead of "implementation-defined" or nothing.
  • The friend extraction option turned out to drop hidden friends rather than just the friendship, so it is now deprecated and always on.
  • Deprecation notices and forwarding now come from the option schema instead of hand-written code.
  • A copied symbol records the base class it came from rather than a flag, which is what lets the notes name that class.
  • Two other small basic fixes: a crash on compilation database entries without a file extension (a buffer overflow as it was), and template helpers that failed on an empty list (growing the stack indefinitely).

Fixes #1309. Fixes #124. Fixes #1326.

Changes

  • A new pass copies or references hidden friends of base classes in derived classes (very similar to what we already do for members of base classes).
  • Two declarations are now compared by symbol identity to decide whether they are the same function, and deprecated options get their notices and forwarding from the schema.
  • Golden fixtures cover every value of the new option, each filtering state of the base, and each source shape a hidden friend can take, with the expected output stated in each header.
  • Existing fixtures gained the new hidden friend field and the base class field that replaces the copy flag, with no other change to their output.

Testing

The golden fixtures under the new option's directory cover the feature, and the full suite passes.

Documentation

The extraction page has a new section on the setting, and the option reference and schema files are generated from the schema.

@github-actions

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 78% 16316 16114 202 121 83 26 6 6
🛠️ Source 20% 4085 3546 539 45 3 41 1 -
📄 Docs 1% 214 137 77 6 - 6 - -
🧪 Unit Tests 1% 189 185 4 4 1 3 - -
🧰 Tooling <1% 69 69 - 1 - 1 - -
Total 100% 20873 20051 822 177 87 77 7 6

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

🔝 Top Files

  • tests/golden/fixtures/config/inherit-hidden-friends/shapes/private-virtual-base.xml (Golden Tests): 1300 lines Δ (+1300 / -0)
  • tests/golden/fixtures/config/inherit-base-members/redeclared-parameter-names.xml (Golden Tests): 1233 lines Δ (+1233 / -0)
  • include/mrdocs/Support/Reflection/Describe.hpp (Source): 1052 lines Δ (+1001 / -51)

Generated by 🚫 dangerJS against 7f09124

@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.12%. Comparing base (11af978) to head (7f09124).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1329   +/-   ##
========================================
  Coverage    83.12%   83.12%           
========================================
  Files           35       35           
  Lines         3662     3662           
  Branches       844      844           
========================================
  Hits          3044     3044           
  Misses         410      410           
  Partials       208      208           
Flag Coverage Δ
bootstrap 83.12% <ø> (ø)

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

Copy link
Copy Markdown

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

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

2026-09-29 23:04:20 UTC

@alandefreitas
alandefreitas added this pull request to the merge queue Sep 29, 2026
Merged via the queue into cppalliance:develop with commit 6a984f6 Sep 30, 2026
32 checks passed
@alandefreitas
alandefreitas deleted the feat/inherit-hidden-friends branch September 30, 2026 20:42
@mpusz

mpusz commented Oct 1, 2026

Copy link
Copy Markdown

Follow-up on this pass filed as #1332: one generic hidden friend is copied into every derived class rather than documented once, and when two filtered bases declare friends of the same name the second is dropped from the corpus entirely. In mp-units that costs the units and the quantity specs all of their arithmetic and comparison operators.

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.

Crashes on startup Hidden friends of an excluded base class are dropped, with no way to keep them on the derived class identify "hidden friends"

3 participants