[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 10 18:13:28 PST 2025
================
@@ -1184,8 +1196,10 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
// for e.g., [n{0}] { }; <-- if no <initializer_list> is included.
// FIXME: we should create the init capture variable and mark it invalid
// in this case.
- if (C->InitCaptureType.get().isNull())
- continue;
+ if (C->InitCaptureType.get().isNull() && !C->Init.isUsable()) {
----------------
charan-003 wrote:
@AaronBallman @Sirraide
Okay, that makes sense. I tried working on it and removed the redundant && !C->Init.isUsable() condition, but I still get a crash when running tests. Here’s the error I see:
RUN: at line 1: /Users/.../clang -cc1 -internal-isystem /Users/.../build/lib/clang/20/include -nostdsysteminc -std=c++1y /Users/.../llvm-project/.../clang/test/SemaCXX/cxx1y-init-captures.cpp -verify -emit-llvm-only
+ /Users/.../clang -cc1 -internal-isystem /Users/.../build/lib/clang/20/include -nostdsysteminc -std=c++1y /Users/.../llvm-project/.../clang/test/SemaCXX/cxx1y-init-captures.cpp -verify -emit-llvm-only
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
It seems like the issue is still present, so I’m wondering if there’s something else I might be missing. Could this be related to InitCaptureType still being null in some cases? Or could there be another part of createLambdaInitCaptureVarDecl() that needs to be adjusted? Any hints on what I should check next?
https://github.com/llvm/llvm-project/pull/117953
More information about the cfe-commits
mailing list