[clang] Fix a crash when a lambda capturing a local array is used in an invalid templated constructor (PR #187676)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 26 20:44:33 PDT 2026
================
@@ -7815,8 +7812,15 @@ ExprResult Sema::ActOnFinishFullExpr(Expr *FE, SourceLocation CC,
while (isa_and_nonnull<CapturedDecl>(DC))
DC = DC->getParent();
const bool IsInLambdaDeclContext = isLambdaCallOperator(DC);
+
+ // Do not check for potential captures if the function in which the lambda
+ // is defined does not have a valid decl. (GH187183)
+ FunctionDecl *FD = getCurFunctionDecl();
+ bool IsValidParentFunc = !FD || !FD->isInvalidDecl();
----------------
zyn0217 wrote:
I think we should bail out very early for invalid function declarations before getting here
https://github.com/llvm/llvm-project/pull/187676
More information about the cfe-commits
mailing list