[clang] [Serialization] Fix lazy template loading (PR #133057)
Jonas Hahnfeld via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 21 01:39:35 PST 2025
hahnjo wrote:
> If I understand correctly, we could implement this locally in `ASTReaderDecl.cpp`, matching a number of patterns in `ASTReader::finishPendingActions()`:
>
> ```diff
> diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
> index 882d54f31280..ec7c2449d77e 100644
> --- a/clang/lib/Serialization/ASTReaderDecl.cpp
> +++ b/clang/lib/Serialization/ASTReaderDecl.cpp
> @@ -2107,8 +2107,10 @@ void ASTDeclMerger::MergeDefinitionData(
> auto *Def = DD.Definition;
> DD = std::move(MergeDD);
> DD.Definition = Def;
> - for (auto *D : Def->redecls())
> - cast<CXXRecordDecl>(D)->DefinitionData = ⅅ
> + // FIXME: this duplicates logic from ASTReader::finishPendingActions()...
> + for (auto *R = Reader.getMostRecentExistingDecl(Def); R;
> + R = R->getPreviousDecl())
> + cast<CXXRecordDecl>(R)->DefinitionData = ⅅ
> return;
> }
>
> ```
https://github.com/llvm/llvm-project/pull/172559 landed this change and fixed the reported crashes (https://github.com/llvm/llvm-project/pull/172559#discussion_r2636632321). @alexfh if you have time, could you give this PR one more run?
https://github.com/llvm/llvm-project/pull/133057
More information about the cfe-commits
mailing list