[Clang][P2996] Implement PCH serialization for ExplDependentCallExpr - #330
Open
ddd2951 wants to merge 1 commit into
Open
[Clang][P2996] Implement PCH serialization for ExplDependentCallExpr#330ddd2951 wants to merge 1 commit into
ddd2951 wants to merge 1 commit into
Conversation
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.
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.
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
clang/test/PCH/expl-dependent-call.cppfails on an unpatchedbuild (record-consumption assertion) and passes with this change. It also
pins the node's presence via
-ast-dump+ FileCheck so it cannotsilently degrade if node-creation conditions change.
generated PCHs on the patched build.
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.