[clang] [C++20][Modules] Fix crash/compiler error due broken AST links (PR #123648)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 21 03:20:18 PST 2025
================
@@ -1571,9 +1571,10 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
} else {
Record.push_back(0);
}
- // For lambdas inside canonical FunctionDecl remember the mapping.
+ // For lambdas inside template functions, remember the mapping to
+ // deserialize them together.
if (auto FD = llvm::dyn_cast_or_null<FunctionDecl>(D->getDeclContext());
- FD && FD->isCanonicalDecl()) {
+ FD && FD->isDependentContext() && FD->isThisDeclarationADefinition()) {
----------------
hokein wrote:
> But types are different and isThisDeclarationADefinition is not a virtual function.
We can use a template function.
> Moreover I'm not sure that conditions will be the same in future so extracting them to a function might be a wrong hint.
OK, that makes sense.
(this change seems to be an oversight in https://github.com/llvm/llvm-project/pull/111992, where it was applied to `RecordDecl` but not to `FunctionDecl`. Extracting this into a dedicated function might be helpful and could potentially be reused in other parts of the code.)
https://github.com/llvm/llvm-project/pull/123648
More information about the cfe-commits
mailing list