[clang] [C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #109167)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 23 18:57:46 PDT 2024


================
@@ -4351,6 +4351,15 @@ void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
           reader::ASTDeclContextNameLookupTrait(*this, *Update.Mod));
     DC->setHasExternalVisibleStorage(true);
   }
+
+  // Load any pending lambdas for the function.
+  if (auto *FD = dyn_cast<FunctionDecl>(D); FD && FD->isCanonicalDecl()) {
+    if (auto IT = FunctionToLambdasMap.find(ID);
+        IT != FunctionToLambdasMap.end()) {
+      for (auto LID : IT->second)
+        GetDecl(LID);
----------------
ChuanqiXu9 wrote:

Then, let's erase `IT`.

https://github.com/llvm/llvm-project/pull/109167


More information about the cfe-commits mailing list