diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2026-06-01 17:10:11 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2026-06-01 17:10:11 +0000 |
| commit | 86326398b73b81f84831fb5fc4c12d9219bc0f57 (patch) | |
| tree | f56ddc1776dae456f4a74f59d9535eecc64ae137 | |
| parent | 16f21c5af35002b8361ffb2e83ff3c92cd899a3a (diff) | |
Merge commit 63c29df8eceb from llvm git (by Dmitry Polukhin):
[Serialization] Fix assertion on re-deserialized friend template spec… (#200566)
…ialization in PCH (#198133)
A friend function-template specialization declared inside a class
template is serialized into a PCH. When the class template is later
instantiated while loading the PCH, the friend specialization can be
deserialized re-entrantly (VisitFriendDecl -> VisitFunctionDecl -> ...
-> VisitFunctionDecl for the same specialization) at the same time as
the canonical copy, producing two redeclarations of the same
specialization in the template's specialization set.
ASTDeclReader::VisitFunctionDecl asserted that this collision could only
happen when merging declarations from different modules. Since
38b3d87bd384, friend functions defined inside dependent class templates
are loaded eagerly, so the collision can now also occur within a single
PCH/AST file (non-modules build), tripping the assertion:
Assertion failed: (Reader.getContext().getLangOpts().Modules &&
"already deserialized this template specialization"), function
VisitFunctionDecl
The merge that follows (mergeRedeclarable) already links the two
redeclarations correctly regardless of whether modules are enabled, so
the fix is to drop the modules-only assumption and let the merge run.
Fixes https://github.com/llvm/llvm-project/issues/198133
This fixes (well, simply removes :) an assertion when building the
cad/OrcaSlicer port with precompiled headers turned on.
PR: 295296
MFC after: 3 days
| -rw-r--r-- | contrib/llvm-project/clang/lib/Serialization/ASTReaderDecl.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/contrib/llvm-project/clang/lib/Serialization/ASTReaderDecl.cpp b/contrib/llvm-project/clang/lib/Serialization/ASTReaderDecl.cpp index b918bfbd549c..87224fae5dbb 100644 --- a/contrib/llvm-project/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/contrib/llvm-project/clang/lib/Serialization/ASTReaderDecl.cpp @@ -989,8 +989,6 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { if (InsertPos) CommonPtr->Specializations.InsertNode(FTInfo, InsertPos); else { - assert(Reader.getContext().getLangOpts().Modules && - "already deserialized this template specialization"); Existing = ExistingInfo->getFunction(); } } |
