[clang] [clang] Avoid invalid iterator in `MergeDefinitionData` (PR #172559)
Jonas Hahnfeld via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 17 06:10:31 PST 2025
================
@@ -2107,8 +2107,9 @@ void ASTDeclMerger::MergeDefinitionData(
auto *Def = DD.Definition;
DD = std::move(MergeDD);
DD.Definition = Def;
- for (auto *D : Def->redecls())
- cast<CXXRecordDecl>(D)->DefinitionData = ⅅ
+ for (auto *R = Reader.getMostRecentExistingDecl(Def); R;
+ R = R->getPreviousDecl())
----------------
hahnjo wrote:
I guess only @alexfh can give us the final confirmation that all issues are gone, but since this change avoids the iterator it cannot become invalid anymore and the test added in 5ee6cff90ba5d8e08066eeeef0c27aa0b6f24d2c continues to pass.
https://github.com/llvm/llvm-project/pull/172559
More information about the cfe-commits
mailing list