[clang] [Clang] suppress deprecated field warnings in implicit special-member functions (PR #147400)
Shashi Shankar via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 22 05:05:17 PDT 2025
================
@@ -547,6 +547,15 @@ static void DoEmitAvailabilityWarning(Sema &S, AvailabilityResult K,
return;
}
case AR_Deprecated:
+ // Suppress -Wdeprecated-declarations in purely implicit special-member functions.
+ if (auto *MD = dyn_cast_if_present<CXXMethodDecl>(S.getCurFunctionDecl());
+ MD && MD->isImplicit() && MD->isDefaulted() &&
+ (isa<CXXConstructorDecl, CXXDestructorDecl>(MD) ||
+ MD->isCopyAssignmentOperator() ||
+ MD->isMoveAssignmentOperator())) {
+ return;
+ }
+
----------------
shashforge wrote:
@zwuis – just to clarify:
* @cor3ntin review comment has already been addressed**: the early-exit now lives in Sema::ShouldWarnAboutDeprecatedDecl`, exactly as suggested.
* This was pushed **before** I re-requested review.
* Relevant code, now on `HEAD`:
```cpp
if (const auto *FD = dyn_cast_or_null<FunctionDecl>(S.getCurFunctionDecl());
FD && FD->isImplicit())
return;
}
```
`ninja check-clang` is green.
Let me know if I missed anything—happy to tweak further!
https://github.com/llvm/llvm-project/pull/147400
More information about the cfe-commits
mailing list