[clang] [Clang] fix false-positive lambda shadow diagnostics in explicit object member functions (PR #165919)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 1 11:46:38 PDT 2025
================
@@ -8492,12 +8492,13 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
DeclContext *NewDC = D->getDeclContext();
if (FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
- if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDC)) {
+ if (CXXMethodDecl *MD =
+ dyn_cast<CXXMethodDecl>(getFunctionLevelDeclContext())) {
// Fields are not shadowed by variables in C++ static methods.
if (MD->isStatic())
return;
- if (!MD->getParent()->isLambda() && MD->isExplicitObjectMemberFunction())
+ if (MD->isExplicitObjectMemberFunction())
----------------
cor3ntin wrote:
We could merge that `if` with the `if(is static())` above.
https://github.com/llvm/llvm-project/pull/165919
More information about the cfe-commits
mailing list