[clang] [FixIt] Improve Source Ranges and Fix-It Hints for Unused Lambda Captures #106445 (PR #117953)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Tue May 13 20:15:51 PDT 2025
================
@@ -1207,12 +1222,61 @@ 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;
+ // Ensure the initialization is valid before proceeding
+
+ if (!C->InitCaptureType || C->InitCaptureType.get().isNull()) {
+ if (!C->Init.isUsable()) {
+ Diag(C->Loc, diag::err_invalid_lambda_capture_initializer_type);
+ continue;
+ }
+
+ if (!C->Init.get()) {
+ continue;
+ }
- if (C->Init.get()->containsUnexpandedParameterPack() &&
- !C->InitCaptureType.get()->getAs<PackExpansionType>())
- DiagnoseUnexpandedParameterPack(C->Init.get(), UPPC_Initializer);
+ ASTContext &Ctx = this->Context;
+ QualType DeducedType = C->Init.get()->getType();
+
+ if (DeducedType.isNull()) {
+ continue;
+ }
+
+ if (DeducedType->isVoidType()) {
+ if (!DeducedType->isDependentType()) {
----------------
ojhunt wrote:
excess braces again
https://github.com/llvm/llvm-project/pull/117953
More information about the cfe-commits
mailing list