1
0
mirror of https://git.FreeBSD.org/src.git synced 2026-06-02 11:24:32 +00:00

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
This commit is contained in:
Dimitry Andric
2026-06-01 19:10:11 +02:00
parent 16f21c5af3
commit 86326398b7
@@ -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();
}
}