[all-commits] [llvm/llvm-project] 63c29d: [Serialization] Fix assertion on re-deserialized f...

Dmitry Polukhin via All-commits all-commits at lists.llvm.org
Mon Jun 1 02:02:50 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 63c29df8ecebb57bdcc04de652afc8d2d98650d7
      https://github.com/llvm/llvm-project/commit/63c29df8ecebb57bdcc04de652afc8d2d98650d7
  Author: Dmitry Polukhin <34227995+dmpolukhin at users.noreply.github.com>
  Date:   2026-06-01 (Mon, 01 Jun 2026)

  Changed paths:
    M clang/lib/Serialization/ASTReaderDecl.cpp
    A clang/test/PCH/friend-template-spec-redecl.cpp

  Log Message:
  -----------
  [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



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list