Skip to content

doc: Compiler Explorer links - #134

Open
jll63 wants to merge 11 commits into
boostorg:developfrom
jll63:doc/ce-links
Open

jll63 wants to merge 11 commits into
boostorg:developfrom
jll63:doc/ce-links

Conversation

@jll63

@jll63 jll63 commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

(Written by Claude Code, on behalf of @jll63.)

Adds Compiler Explorer links to three documentation pages, generated from the example sources.

The links

Page Opens
motivation.adoc The complete program behind the listing that adds postfix as a virtual function (ast_virtual_function_2.cpp), with its assembly and output.
basics.adoc, "Putting it all together" ast.cpp, the open-method version, with its assembly and output.
performance.adoc call_virtual_function beside call_via_ref and call_via_virtual_ptr, each in its own assembly pane.

All three use x86-64 clang 23.1.0 with -std=c++17 -O2. Examples that include Boost use Boost 1.92 from CE's library list, not this tree's headers.

dev/ce_link.py

The script prints a godbolt.org/clientstate/<base64> URL that carries the source itself. Nothing is stored on Compiler Explorer until a reader opens the link, and the link can be regenerated whenever the example changes:

dev/ce_link.py doc/modules/ROOT/examples/ast.cpp
dev/ce_link.py doc/modules/ROOT/examples/ast_virtual_function_2.cpp --tag all
dev/ce_link.py doc/modules/ROOT/examples/dispatch_open_method.cpp \
    --beside doc/modules/ROOT/examples/dispatch_virtual_function.cpp
  • The source is the tagged region the page includes, minus any nested tag::/end:: lines, as Asciidoctor drops them. The reader gets exactly the code shown on the page.
  • The URL is percent-encoded. Otherwise a pair of + in the base64 would be taken by AsciiDoc for a passthrough before the link: macro sees it.
  • --beside turns off CE's "Library functions" filter. CE decides what is library code by line info. Every instruction of call_via_virtual_ptr is dispatch code inlined from core.hpp, so the filter hid the whole function.

Nothing checks that a link is still current: if an example changes, its link keeps the old code until it is regenerated.

Examples and pages

  • New minimal translation units: dispatch_virtual_function.cpp and dispatch_open_method.cpp. A full program buries the call under the registration code. Each file ends with an empty main, outside the tagged region, so it still builds as an example.
  • performance.adoc includes its three call listings from those files, so the page and the link show the same code.
  • The assembly listings now come from clang 23.1, which folds the final load into the indirect jump: one mov fewer in all three calls. A note gives the compiler, options and Boost version. llvm-mca (Skylake) gives the same 1 and 4 cycles for the new code, so the text stands.
  • ast.cpp, ast_virtual_function.cpp and ast_virtual_function_2.cpp print from a demo function called by main. The inline postfix listing on motivation.adoc changes with them.

CI

ci.yml now also runs on pushes to doc/** branches.

Testing

  • Examples: the three changed examples and the two new ones build with -Wall -Wextra -Werror under gcc 13 and clang 22, at -O0 and at -O2 -DNDEBUG, and print the expected output. The Boost examples also compile against the boost-1.92.0 headers.
  • On Compiler Explorer: built and run through CE's compile API with clang 23.1; the output matches. Every link is accepted by CE's server.
  • Docs: built with doc/build_antora.sh, no warnings on the three pages. Each rendered href matches the generated URL byte for byte. The performance.adoc code blocks render identically before and after the switch to includes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01958YRGfNfb6SfQS9v4hWTr

@cppalliance-bot

cppalliance-bot commented Oct 18, 2026 •

Copy link
Copy Markdown

An automated preview of the documentation is available at https://134.openmethod.prtest3.cppalliance.org/libs/openmethod/doc/html/index.html

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

2026-10-19 21:16:14 UTC

@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.56%. Comparing base (93bb513) to head (c5ddf51).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #134   +/-   ##
========================================
  Coverage    92.56%   92.56%           
========================================
  Files           29       29           
  Lines         2314     2314           
  Branches       699      699           
========================================
  Hits          2142     2142           
  Misses         111      111           
  Partials        61       61           

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 93bb513...c5ddf51. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jll63 and others added 11 commits October 19, 2026 15:34
dev/ce_link.py turns the tagged region of a doc example into a
godbolt.org/clientstate URL that carries the source itself, so nothing
is stored on Compiler Explorer until a reader opens the link, and the
link is regenerated from the example when the example changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dev/ce_link.py --base opens the example beside another one, with CE's
source diff between the two and the example's output: here, the
open-method AST against the virtual function version from the
motivation page. An example that includes a Boost header gets Boost
1.92 from CE's library list. The tag directives nested in the region
are dropped, as Asciidoctor drops them from the include.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The motivation link moves to the listing that adds `postfix` as a
virtual function, and opens the complete program,
ast_virtual_function_2.cpp. The "Putting it all together" diff now
takes that program as its base, and compiles both sides so that it
also shows the diff between their disassemblies (Intel syntax).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
performance.adoc gets a link that compiles the virtual function call
and the two method calls side by side with clang, each in its own
compiler pane. They come from two minimal translation units,
dispatch_virtual_function.cpp and dispatch_open_method.cpp: a full
program buries the calls under the registration code. The page now
includes its three call listings from those files, so the page and
the link show the same code; each file ends with an empty main,
outside the tagged region, so it still builds as an example.

The diff on basics.adoc drops its assembly diff, which compared whole
programs, and keeps the source diff and the output.

dev/ce_link.py: --beside, --compiler; --base-tag becomes --other-tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01958YRGfNfb6SfQS9v4hWTr
CE's "Library functions" filter hid it: the filter goes by line info,
and every instruction of call_via_virtual_ptr is dispatch code inlined
from core.hpp. Turn the filter off; the call functions still come
first in the clang output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01958YRGfNfb6SfQS9v4hWTr
The Compiler Explorer comparison compiles with clang 23, which folds the
last load into the indirect jump: one `mov` fewer in the virtual function
call and in both method calls. Update the three listings to match, and
say in a note which compiler, options and Boost version they come from.
llvm-mca (skylake) gives the same throughputs for the clang 23 code, 1
and 4 cycles, so the text stands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01958YRGfNfb6SfQS9v4hWTr
The "Putting it all together" link now opens ast.cpp and runs it, with
no diff against the virtual function version. That leaves --base
without a user, so it goes; --other-tag, now used by --beside only,
becomes --beside-tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01958YRGfNfb6SfQS9v4hWTr
main() builds the expression and hands it to demo(), which prints it
and its value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01958YRGfNfb6SfQS9v4hWTr
The motivation and basics links compiled with gcc 16.2; make clang 23.1,
which the performance comparison already used, the default of
dev/ce_link.py, and regenerate them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01958YRGfNfb6SfQS9v4hWTr
As ast.cpp does: main() builds the expression and hands it to demo().
Both programs on the page change together, so that the postfix listing
still reads as the first one plus postfix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01958YRGfNfb6SfQS9v4hWTr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01958YRGfNfb6SfQS9v4hWTr

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.

2 participants