[clang] [clang] Avoid -Wshadow warning when init-capture named same as class field (PR #74512)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 9 09:38:54 PST 2024
================
@@ -8328,35 +8328,47 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl,
unsigned WarningDiag = diag::warn_decl_shadow;
SourceLocation CaptureLoc;
- if (isa<VarDecl>(D) && isa<VarDecl>(ShadowedDecl) && NewDC &&
- isa<CXXMethodDecl>(NewDC)) {
+ if (isa<VarDecl>(D) && NewDC && isa<CXXMethodDecl>(NewDC)) {
if (const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->getParent())) {
if (RD->isLambda() && OldDC->Encloses(NewDC->getLexicalParent())) {
- if (RD->getLambdaCaptureDefault() == LCD_None) {
- // Try to avoid warnings for lambdas with an explicit capture list.
+ if (const auto *VD = dyn_cast<VarDecl>(ShadowedDecl)) {
----------------
cor3ntin wrote:
We currently warn on that actually
https://compiler-explorer.com/z/d4W37n9Mn
Can you test that we still do?
The rest of the changes LGTM
https://github.com/llvm/llvm-project/pull/74512
More information about the cfe-commits
mailing list