[clang] [clang][Sema] Fix false-positive -Wshadow for friend functions (PR #221249)
ahmed mohamed kamel via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 15 04:54:34 PDT 2026
================
@@ -8627,12 +8627,12 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
DeclContext *NewDC = D->getDeclContext();
if (FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
- if (const auto *MD =
- dyn_cast<CXXMethodDecl>(getFunctionLevelDeclContext())) {
- // Fields aren't shadowed in C++ static members or in member functions
- // with an explicit object parameter.
+ DeclContext *FnDC = getFunctionLevelDeclContext();
+ if (const auto *MD = dyn_cast<CXXMethodDecl>(FnDC)) {
if (MD->isStatic() || MD->isExplicitObjectMemberFunction())
----------------
AhmedKamel10 wrote:
Restored the original comment.
https://github.com/llvm/llvm-project/pull/221249
More information about the cfe-commits
mailing list