[all-commits] [llvm/llvm-project] f01364: [Clang] Instantiate the correct lambda call operat...

Sirraide via All-commits all-commits at lists.llvm.org
Tue Oct 8 04:34:22 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f01364ebc88d875fbfc0e00413538465aaa8a2b3
      https://github.com/llvm/llvm-project/commit/f01364ebc88d875fbfc0e00413538465aaa8a2b3
  Author: Sirraide <aeternalmail at gmail.com>
  Date:   2024-10-08 (Tue, 08 Oct 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/AST/DeclCXX.cpp
    A clang/test/Modules/gh110401.cppm

  Log Message:
  -----------
  [Clang] Instantiate the correct lambda call operator (#110446)

This is a fix for the following issue: when a lambda’s class type is
merged across modules (e.g. because it is defined in a template in the
GMF of some module `A`, and some other module `B` both imports `A` and
has the same template in its GMF), then `getLambdaCallOperator()` might
return the wrong operator (e.g. while compiling `B`, the lambda’s class
type would be the one attached to `B`’s GMF, but the call operator ends
up being the one attached to `A`’s GMF).

This causes issues in situations where the call operator is in a
template and accesses declarations in the surrounding context: when
those declarations are instantated, a mapping is introduced from the
original node in the template to that of the instantiation. If such an
instantiation happens in `B`, and we then try to instantiate `A`’s call
operator, any nodes in that call operator refer to declarations in the
template in `A`, but the `LocalInstantiationScope` only contains
mappings for declarations in `B`! This causes the following assertion
(for godbolt links and more, see the issue below):

```
Assertion `isa<LabelDecl>(D) && "declaration not instantiated in this scope"' failed.
```

We now walk the redecl chain of the call operator to find the
one that is in the same module as the record decl.

This fixes #110401.



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