================
@@ -2162,11 +2166,17 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation 
StartLoc,
 
   PopExpressionEvaluationContext();
 
-  sema::AnalysisBasedWarnings::Policy WP =
-      AnalysisWarnings.getPolicyInEffectAt(EndLoc);
   // We cannot release LSI until we finish computing captures, which
   // requires the scope to be popped.
-  Sema::PoppedFunctionScopePtr _ = PopFunctionScopeInfo(&WP, 
LSI->CallOperator);
+  Sema::PoppedFunctionScopePtr _ = [&] {
+    if (LSI->CallOperator->getDescribedFunctionTemplate())
+      return PopFunctionScopeInfo(/*WP=*/nullptr,
+                                  TemplateOrNonTemplateCallOperatorDecl);
+
+    sema::AnalysisBasedWarnings::Policy WP =
+        AnalysisWarnings.getPolicyInEffectAt(EndLoc);
+    return PopFunctionScopeInfo(&WP, TemplateOrNonTemplateCallOperatorDecl);
+  }();
----------------
zyn0217 wrote:

can we just
```cpp
sema::AnalysisBasedWarnings::Policy *Policy = nullptr;
if (...)
  Policy = &...;
```
afaik Policy is a pretty small object to create on a stack anyway so we should 
avoid this nesting.

https://github.com/llvm/llvm-project/pull/159364
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to