aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index fc3aabf..086dd8b 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8492,12 +8492,11 @@ 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)) {
- // Fields are not shadowed by variables in C++ static methods.
- if (MD->isStatic())
- return;
-
- if (!MD->getParent()->isLambda() && MD->isExplicitObjectMemberFunction())
+ 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.
+ if (MD->isStatic() || MD->isExplicitObjectMemberFunction())
return;
}
// Fields shadowed by constructor parameters are a special case. Usually