[clang] [Clang] eliminate shadowing warnings for parameters using deducing this (PR #114813)

Oleksandr T. via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 6 02:56:05 PST 2024


================
@@ -8236,11 +8236,14 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
   DeclContext *NewDC = D->getDeclContext();
 
   if (FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
-    // Fields are not shadowed by variables in C++ static methods.
-    if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDC))
+    if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDC)) {
+      // Fields are not shadowed by variables in C++ static methods.
       if (MD->isStatic())
         return;
 
+      if (!MD->getParent()->isLambda() && MD->isExplicitObjectMemberFunction())
+        return;
----------------
a-tarasyuk wrote:

The weird thing is that this is a valid decoration - https://compiler-explorer.com/z/fKoozKb3f

For instance currently to check lambda implicit object parameter, used opposite to explicit object member function with NULL validation

https://github.com/llvm/llvm-project/blob/f87484d5910c1c708bfd93ef588d6ff8307e2477/clang/include/clang/AST/ASTLambda.h#L43-L51



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


More information about the cfe-commits mailing list