Repository navigation
Generate the module wrapper from clang's JSON AST, with a declarative export policy - #1
Merged
Merged
Conversation
… export policy Follow the mwrap generation principle (.agents/docs/2026-10-28-mwrap-module- wrapper-generation.md): the compiler computes the public surface, the generator only lists it, and nothing edits the result afterwards. - tools/ast_json.py: compile each bundle TU once with `clang++ -fsyntax-only -Xclang -ast-dump=json -Xclang -ast-dump-filter=boost` and stream the dump into a flat declaration table (delta-encoded loc.file tracking, implicit instantiations dropped and aliased to their template). The same compile is the syntax gate; libclang is gone. - tools/gen_exports.py: rebuilt on the JSON model; `--check` regenerates into a scratch copy and compares byte for byte; writes generated/meta/ api-surface.json and skipped.txt; verifies each facade's GMF against its bundle; cache entries survive pass-2 edge merges; --libs runs replay claims. - tools/export_policy.toml replaces the module-side patches, patches/final/, the programmatic .inc guards, tools/curated/ and the GMF/define overrides; every rule carries a reason. - src/*.cppm are hand-maintained facades; tools/apply_patches.py replays only the vendored upstream/boost patches (replaces reapply_hand_edits.py). - CI uses the clang++ pinned in .xlings.json (llvm 23.1.3) instead of a full LLVM archive; mcpp pin aligned to 2026.11.5.1. Validated locally: gen_exports --check clean; gcc 16.1 all-modules build and mcpp test 144/144; LLVM 23.1.3 groups A/B 144/144 each.
Collaborator
Author
代码审查报告(high 级别)共发现 10 个问题,按严重程度排序。审查期间没有构建或运行代码;导出丢失问题已通过对比重新生成的 修复某一项后,请勾选该项前面的复选框表示已解决。
概要
问题列表
更新: 5~8 已在 4ffac21 处修复。 |
…ps edge Generator (tools/gen_exports.py): - A using-declaration written `boost::...` injects its last segment into the enclosing namespace, like the `::` and `std::` forms (boost::range::formatted_range). - Enumerators of an unscoped enum are also indexed under the enclosing scope, so `using algorithm::token_compress_on;` resolves (boost::token_compress_on). - Injection dedup is keyed by (name, target): range's boost::join no longer swallows algorithm's boost::join, a different overload set. - check_facade requires each facade's `export import` block to cover its .deps edges; an edge a facade cannot take is declared in the policy's [<lib>.facade] omit-imports with a reason (range -> regex, scope -> core, sort -> range). Facades: add the 44 facades' missing .deps edges (algorithm regains boost::shared_ptr, boost::bind, ... through smart_ptr/bind/function). Policy: drop the atomic BOOST_HAS_INT128 guards the corrected injected names no longer match. Regenerated generated/. Tests: unit tests for the three generator fixes and the facade check; consumer assertions in tests/algorithm.cpp and tests/range.cpp (they fail on the previous commit).
4 tasks
…een; check for cache drift nightly - apply_patches: a missing git is a failed run, so the patch -p1 fallback is reachable; failures report both tools. - ast_json: while skipping an implicit instantiation, alias only nodes of its "inner" arrays, not the declarations listed in lookups. - gen_exports: gate and skip entries record every file clang read (its -MD dependency list) and are valid only while those files are unchanged; skip entries also record the first-wins ownership they were computed under and are valid only while it still holds. - verify-scripts: nightly cache-drift job compares cached, cold and committed generation, uploads the evidence, saves the cold cache and reports to a cache-drift issue; toolchain setup moves to a shared composite action.
…s on the driver line
- tests.yml: install `mcpp@$MCPP_VERSION` instead of the whole .xlings.json
manifest; its llvm pin is the generator's clang++, which the build legs
never use.
- gen_exports: the {stable key: decl} export index is built once per Model
(export_index) and shared by closure_from and collect_body_edges; the
closure's extra targets stay local to closure_from, so the output is
unchanged (cold --check up to date).
- gen_exports: the skip key hashes the clang driver line, as the gate key
does, so CXX and CLANG_NO_DEFAULT_CONFIG invalidate it.
- gen_exports: the gate key is computed by gate_key(lib, headers, policy), shared by parse_bundle and gen_audit; its value is unchanged. - gen_audit: each library's report and counts are cached in target/gen/exports-cache/<lib>.audit.json, keyed on the gate key, the generator's code and gen_audit.py itself, and valid only while every file clang read for it is unchanged. A hit skips the AST dump, so the audit no longer re-dumps every library after a fully skipped gen_exports --check.
- check_cache_drift: both passes also run gen_audit.py, and the linkage reports of the cached and cold runs must match. The reports are not committed, so a stale replay has nothing to be caught against on pull requests. Drift is reported with its diff and the affected .audit.json entries, and saves the cold cache like export drift does. - verify-scripts: comments name the audit cache.
ZheFeng7110
added a commit
that referenced
this pull request
Nov 29, 2026
…ke test asserts it (#9) * exports: boost::dll::fs follows boost::filesystem (policy republish) boost/dll/config.hpp spells boost::dll::fs as `using namespace boost::filesystem;`. The generator follows a using-directive only in the ADL-barrier shape, so #5 re-declared 33 filesystem names by hand; 28 non-operator spellings of main before #1 (symlink_status, space, permissions, unique_path, ...) stayed unreachable. A [[<lib>.republish]] policy entry names the directive's namespace: every name the owning module emitted directly in the target namespace (after its drops, with its guards) is re-exported through it, and the owner becomes a .deps edge. dll::fs now carries filesystem's 138 names under !defined(BOOST_DLL_USE_STD_FS); the std::filesystem branch stays an extra, completed to the standard's 54 names. Cached entries hold only while the owner's emitted names are unchanged. * tests/dll: assert the boost::dll::fs spelling in the smoke test Same-type checks against boost::filesystem, program_location's return type, enumerators, Boost-only functions (unevaluated) and a temp-directory round trip through functions the hand-kept list lacked, on the error_code overloads. With main's dll.inc the file fails to compile on exactly those names. * docs: the republish policy rule; design record for dll::fs
ZheFeng7110
added a commit
that referenced
this pull request
Nov 29, 2026
…hable export set in CI (#11) * exports: restore the names #2 left unanalysed, declare the rest unreachable Restored: - functional imports function: overloaded_function takes its targets as boost::function. The edge was invisible to the generator (partial specializations, includes inside the library's own detail/ headers). - concept_check owns boost/concept_archetype.hpp (regex reaches the archetypes again; concept_check exports them for the first time). - utility owns boost/call_traits.hpp (wave reaches call_traits again); variant imports utility for it. Declared, with the reason, by the new policy rule [[unreachable]] and listed in skipped.txt: names of include-only libraries (MPL, Parameter, Fusion) that the pre-#1 generator listed again for every specialization it met, two Container implementation details, and the names of the headers cobalt and geometry leave out. skipped.txt also names the target of each skip-directive, and a drop by the spelling an importer loses (boost::size, not std::size). * ci: check_reachable: a name importers could spell may only go with a reason gen_exports.py --check proves the committed lists are what the generator writes; it cannot see that they lost names (#5 lost nine with verify-scripts green). check_reachable.py compares what each module's importers reach with 9953323 (main before #1) and with the CI base. A lost (module, name) pair must be explained in skipped.txt by the module it went from: a drop, an unreachable, or a skip-directive whose target still has the name. An entry for a name the module does reach is an error. verify_generated.py runs it. * docs: the unreachable rule and the reachable-export check; design record
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Applies the mwrap generation principle (
.agents/docs/2026-10-28-mwrap-module-wrapper-generation.md): the compiler computes the public surface, the generator only lists it, and nothing edits the result afterwards. Design record:.agents/docs/2026-11-05-json-ast-generation.md.tools/ast_json.pycompiles each bundle TU once withclang++ -fsyntax-only -Xclang -ast-dump=json -Xclang -ast-dump-filter=boostand streams the dump into a flat declaration table. Geometry's filtered dump is 6.8 GB; the reader handles it in about 45 s at roughly 300 MB peak memory. It tracks clang's delta-encodedloc.fileand drops implicit instantiations, aliasing them back to their template. That one compile is also the syntax gate.patches/final/, the programmatic.incguards inreapply_hand_edits.py, andtools/curated/are replaced bytools/export_policy.toml: guard / drop / extra / add / gmf / facade-includes / inline-namespaces / deps rules, each with a written reason.generated/meta/skipped.txtlists every name a rule touches.generated/meta/api-surface.jsonrecords the generator identity (clang release, target, defines) plus per-library GMF, export count and edges.gen_exports.py --checkregenerates into a scratch copy, compares byte for byte, and verifies that each facade's GMF equals the bundle it was generated from. CI uses it instead of agit difforacle.src/*.cppm.tools/apply_patches.pyreplays only the vendoredupstream/boostpatches..xlings.json(llvm 23.1.3, installed by xlings) instead of downloading the LLVM release archive. Thetests.ymlmcpp pin is aligned to2026.11.5.1.Behavior changes
boost::filesystem::{absolute,canonical,equivalent,weakly_canonical}are exported under their documented spelling (previously missing). The same applies tompl_::*fromBOOST_MPL_AUX_ADL_BARRIER_DECL..depsgoes from 608 to 633 edges (no import cycles), and themcpp.tomldefault closure gainsbindandfunction.flyweight.inc,algorithm.inc/.depsandversion.depsare generated from policy rules instead of hand-maintained final forms.export importblocks are unchanged.Validation (local, x86_64 Linux)
gen_exports.py --checkclean;gen_features.py --checkcleanmcpp build --features all-modulesOK;mcpp test --features all-modules144/144mcpp testwith CI groups A and B, 144/144 each (the whole closure hits clang's known source-location limit)test_ast_json.py)🤖 Generated with Claude Code