[clang] [Clang][Sema] Make lambda in non-dependent context generate same analysis-based warnings as function[ template] (PR #159364)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 17 19:08:07 PDT 2025
================
@@ -2149,24 +2153,28 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc,
CleanupInfo LambdaCleanup = LSI->Cleanup;
bool ContainsUnexpandedParameterPack = LSI->ContainsUnexpandedParameterPack;
bool IsGenericLambda = Class->isGenericLambda();
+ sema::AnalysisBasedWarnings::Policy WP =
+ AnalysisWarnings.getPolicyInEffectAt(EndLoc);
CallOperator->setLexicalDeclContext(Class);
- Decl *TemplateOrNonTemplateCallOperatorDecl =
- CallOperator->getDescribedFunctionTemplate()
- ? CallOperator->getDescribedFunctionTemplate()
- : cast<Decl>(CallOperator);
----------------
zyn0217 wrote:
I think you can leave it as-is? That way you can
```cpp
sema::AnalysisBasedWarnings::Policy *ActivePolicy = IsGenericLambda ? nullptr : &WP;
Sema::PoppedFunctionScopePtr _ =
PopFunctionScopeInfo(ActivePolicy, TemplateOrNonTemplateCallOperatorDecl);
```
Though I have no idea why `LSI->CallOperator` doesn't work when it's a template.
https://github.com/llvm/llvm-project/pull/159364
More information about the cfe-commits
mailing list