Skip to content

fix(ast): explicitly instantiate two-argument ConstantExprInfo populate - #1334

Open
liuq wants to merge 1 commit into
cppalliance:developfrom
liuq:fix/explicit-instantiation-populate-constexpr
Open

liuq wants to merge 1 commit into
cppalliance:developfrom
liuq:fix/explicit-instantiation-populate-constexpr

Conversation

@liuq

@liuq liuq commented Oct 4, 2026

Copy link
Copy Markdown

TypeBuilder::buildArray calls ASTVisitor::populate(ConstantExprInfo<std::uint64_t>&, clang::Expr const*) for DependentSizedArrayType. That template is defined in ASTVisitor.cpp, but only the three-argument overload (..., llvm::APInt const&) is explicitly instantiated there. The two-argument one exists in the object file only as an implicit instantiation from the three-argument body. When the compiler inlines that call, no symbol is emitted, and linking tools/mrdocs fails:

Undefined symbols for architecture arm64:
  "void mrdocs::ASTVisitor::populate<unsigned long long>(mrdocs::ConstantExprInfo<unsigned long long>&, clang::Expr const*)", referenced from:
      mrdocs::TypeBuilder::buildArray(clang::ArrayType const*) in libmrdocs-core.a[11](TypeBuilder.cpp.o)
ld: symbol(s) not found for architecture arm64

I hit this building 2026.9.29 (Release, -O3) on macOS arm64 against Homebrew's llvm 23.1.2, for a Homebrew formula. The pinned LLVM build happens not to inline the call, which is why CI doesn't see it.

Changes

  • Source: add the missing explicit instantiation of the two-argument populate<std::uint64_t> in src/mrdocs/AST/ASTVisitor.cpp.

Testing

With this change, the configuration above builds and links, and mrdocs generates documentation for a sample project. There's no new test: the failure only shows up at link time with a toolchain that inlines the call, and none of the CI toolchains do.

Documentation

None needed; this is a build fix with no user-visible behavior change.

🤖 Generated with Claude Code

TypeBuilder::buildArray calls populate(ConstantExprInfo<std::uint64_t>&,
clang::Expr const*) for dependent-sized arrays, but its definition lives in
ASTVisitor.cpp and only the three-argument overload is explicitly
instantiated there. The two-argument one is emitted only as an implicit
instantiation from the three-argument body, so when the compiler inlines
it the symbol is missing and linking tools/mrdocs fails:

    Undefined symbols for architecture arm64:
      "void mrdocs::ASTVisitor::populate<unsigned long long>(
        mrdocs::ConstantExprInfo<unsigned long long>&, clang::Expr const*)"

This happens building against Homebrew's LLVM 23.1.2 on macOS arm64 at -O3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 4, 2026 07:41
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

⚠️ Warnings

Warning

Source changed but no tests or fixtures were updated.

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🛠️ Source 100% 7 7 - 1 - 1 - -
Total 100% 7 7 - 1 - 1 - -

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

🔝 Top Files

  • src/mrdocs/AST/ASTVisitor.cpp (Source): 7 lines Δ (+7 / -0)

Generated by 🚫 dangerJS against b05c440

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused instantiation correctly addresses the reported linker failure without changing runtime behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Adds the missing explicit template instantiation needed to prevent optimized macOS arm64 link failures.

Changes:

  • Explicitly instantiates the two-argument populate<std::uint64_t> overload.
File Description
src/​mrdocs/​AST/​ASTVisitor.cpp Ensures the required template specialization emits a linkable symbol.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cppalliance-bot

Copy link
Copy Markdown

An automated preview of the documentation is available at https://1334.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-04 07:47:26 UTC

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.

3 participants