[all-commits] [llvm/llvm-project] 9d1b5d: [C++20] [Modules] Set ManglingContextDecl when we ...

Jan Kokemüller via All-commits all-commits at lists.llvm.org
Thu Mar 5 10:43:33 PST 2026


  Branch: refs/heads/release/22.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 9d1b5d8615e8fd10b8da36ed108a4b43604e7256
      https://github.com/llvm/llvm-project/commit/9d1b5d8615e8fd10b8da36ed108a4b43604e7256
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2026-03-05 (Thu, 05 Mar 2026)

  Changed paths:
    M clang/lib/Sema/SemaLambda.cpp
    A clang/test/Modules/pr177385.cppm

  Log Message:
  -----------
  [C++20] [Modules] Set ManglingContextDecl when we need to mangle a lambda but it's nullptr (#177899)

Close https://github.com/llvm/llvm-project/issues/177385

The root cause of the problem is, when we decide to mangle a lamdba in a
module interface while the ManglingContextDecl is nullptr, we didn't
update ManglingContextDecl. So that the following use of
ManglingContextDecl is an invalid value.

(cherry picked from commit 772b15b3be153b1d2df910057af17926ea227243)


  Commit: e408392b7fb5a14ae53dc1d336436666a5952151
      https://github.com/llvm/llvm-project/commit/e408392b7fb5a14ae53dc1d336436666a5952151
  Author: Jan Kokemüller <jan.kokemueller at gmail.com>
  Date:   2026-03-05 (Thu, 05 Mar 2026)

  Changed paths:
    M clang/lib/Sema/SemaLambda.cpp
    A clang/test/Modules/pr178893.cppm

  Log Message:
  -----------
  [clang] Don't use `VarDecl` of local variables as `ManglingContextDecl` for lambdas (#179035)

Currently, in a C++20 modules context, a `VarDecl` of a local variable
can wrongly end up as a `ManglingContextDecl` for a lambda.

Fix this by removing `ContextKind::NonInlineInModulePurview` in
`Sema::getCurrentMangleNumberContext` and add
`IsExternallyVisibleInModulePurview` checks in the appropriate places:

- For externally visible functions defined in a module purview, add a
check to `isInInlineFunction`, renaming it to
`IsInFunctionThatRequiresMangling`
- For externally visible variables defined in a module purview, add a
new `ContextKind::ExternallyVisibleVariableInModulePurview` and an
appropriate check to the `VarDecl` case

Fixes #178893

---------

Co-authored-by: Corentin Jabot <corentinjabot at gmail.com>
Co-authored-by: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
(cherry picked from commit 765c4e6e8fb25ca999bc19654b5f324df62879ad)


Compare: https://github.com/llvm/llvm-project/compare/cc296598ee70...e408392b7fb5

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