Skip to content

[Clang][P2996] Implement PCH serialization for ExplDependentCallExpr - #330

Open
ddd2951 wants to merge 1 commit into
bloomberg:p2996from
ddd2951:fix/pch-expl-dependent-call
Open

[Clang][P2996] Implement PCH serialization for ExplDependentCallExpr#330
ddd2951 wants to merge 1 commit into
bloomberg:p2996from
ddd2951:fix/pch-expl-dependent-call

Conversation

@ddd2951

@ddd2951 ddd2951 commented Jul 20, 2026

Copy link
Copy Markdown

Issue number of the reported bug or feature request: #329

Describe your changes
ExplDependentCallExpr (the P2996-specific node wrapping calls to functions marked [[clang::instantiation_dependent]], e.g. access_context::current()) had no working PCH round-trip: the writer emitted the record without its operands (TODO(P2996) in ASTWriterStmt), and the reader had no construction case for the node, so its Visit method was unreachable. Consuming a PCH containing the node aborted on the record-consumption assertion in assertion builds and segfaulted in the constant evaluator in release builds (matching the original report).

This implements the missing serialization: an EmptyShell constructor and CreateEmpty for the reader's construction switch, and symmetric write/read of the template depth and wrapped call expression.

Testing performed

  • New test clang/test/PCH/expl-dependent-call.cpp fails on an unpatched
    build (record-consumption assertion) and passes with this change. It also
    pins the node's presence via -ast-dump + FileCheck so it cannot
    silently degrade if node-creation conditions change.
  • The reduced and original reproducers from Segfault during constant evaluation of a reflection call loaded from a PCH #329 both pass with freshly
    generated PCHs on the patched build.
  • Ran the PCH, Reflection, and Modules lit suites. 12 tests fail in my
    environment, but all 12 fail identically on the unpatched baseline; they
    are pre-existing and unrelated to this change.

Additional context
Found while compiling reflection-heavy code through clangd's
precompiled-preamble path; the standalone reproducer in #329 does not
require clangd.

Fixes #329.

The writer emitted ExplDependentCallExpr records without their operands
(TODO left in ASTWriterStmt), and the reader had no construction case for
the node, so its Visit method was unreachable. Consuming a PCH containing
the node aborted on the record-consumption assertion in assertion builds
and segfaulted during constant evaluation in release builds. This was hit
by any consteval function in a PCH calling
std::meta::access_context::current().

Serialize the wrapped call expression and template depth, add the
CreateEmpty construction path in the reader, and add a self-verifying PCH
regression test that pins the node with an AST-dump check.

Fixes bloomberg#329.
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.

1 participant