[clang] [clang] Don't use `VarDecl` of local variables as `ManglingContextDecl` for lambdas (PR #179035)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 1 18:33:43 PST 2026
Jan =?utf-8?q?Kokemüller?= <jan.kokemueller at gmail.com>,
Jan =?utf-8?q?Kokemüller?= <jan.kokemueller at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/179035 at github.com>
================
@@ -294,6 +294,13 @@ Sema::getCurrentMangleNumberContext(const DeclContext *DC) {
bool IsInNonspecializedTemplate =
inTemplateInstantiation() || CurContext->isDependentContext();
+ // If we must allocate mangling numbers but the `ManglingContextDecl`
+ // is a local variable, use the `DeclContext` containing the lambda expression
+ // instead.
+ if (VarDecl *Var = dyn_cast_or_null<VarDecl>(ManglingContextDecl);
+ Var && Var->isLocalVarDecl())
+ ManglingContextDecl = const_cast<Decl *>(cast<Decl>(DC));
----------------
ChuanqiXu9 wrote:
If this only happens for modules, I'd like to move it to the following check for modules.
https://github.com/llvm/llvm-project/pull/179035
More information about the cfe-commits
mailing list