[all-commits] [llvm/llvm-project] 6ca59a: [clang][modules] Fix lambda and its enclosing func...

Haojian Wu via All-commits all-commits at lists.llvm.org
Tue Jun 3 08:41:58 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6ca59aae8e13168467f743c749a36bd9c5074b41
      https://github.com/llvm/llvm-project/commit/6ca59aae8e13168467f743c749a36bd9c5074b41
  Author: Haojian Wu <hokein.wu at gmail.com>
  Date:   2025-06-03 (Tue, 03 Jun 2025)

  Changed paths:
    M clang/include/clang/Serialization/ASTReader.h
    M clang/lib/Serialization/ASTWriterDecl.cpp
    A clang/test/Headers/crash-instantiated-in-scope-cxx-modules6.cpp

  Log Message:
  -----------
  [clang][modules] Fix lambda and its enclosing function are not loaded from same module. (#142467)

This is a follow-up fix to
https://github.com/llvm/llvm-project/pull/109167.

Previously, we stored a mapping between the enclosing function and the
lambda class declaration. When loading the enclosing function, we also
loaded the corresponding lambda class declaration. However, loading the
lambda class declaration does not guarantee that its call operator (a
`CXXMethodDecl`) is loaded as well.
As a result, if the lambda call operator is later loaded from a
different module, we can end up with a `DeclRefExpr` that refers to a
`VarDecl` from a different module — leading to inconsistencies.

To fix this, we should ensure the lambda call operator itself is loaded.

Fixes #141582



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