[clang] [Clang] Fix Handling of Init Capture with Parameter Packs in LambdaScopeForCallOperatorInstantiationRAII (PR #100766)

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 9 07:37:11 PDT 2024


================
@@ -712,22 +712,30 @@ bool Sema::addInstantiatedCapturesToScope(
   auto AddSingleCapture = [&](const ValueDecl *CapturedPattern,
                               unsigned Index) {
     ValueDecl *CapturedVar = LambdaClass->getCapture(Index)->getCapturedVar();
-    if (CapturedVar->isInitCapture())
-      Scope.InstantiatedLocal(CapturedPattern, CapturedVar);
+    assert(CapturedVar->isInitCapture());
+    Scope.InstantiatedLocal(CapturedPattern, CapturedVar);
   };
 
   for (const LambdaCapture &CapturePattern : LambdaPattern->captures()) {
     if (!CapturePattern.capturesVariable()) {
       Instantiated++;
       continue;
     }
-    const ValueDecl *CapturedPattern = CapturePattern.getCapturedVar();
+    ValueDecl *CapturedPattern = CapturePattern.getCapturedVar();
+
+    if (!CapturedPattern->isInitCapture()) {
+      continue;
+    }
----------------
cor3ntin wrote:

Hum, nvm, I misread that code , I failed to realize the assert L715 was in a different scope, so I was confused.

https://github.com/llvm/llvm-project/pull/100766


More information about the cfe-commits mailing list