[clang] [LifetimeSafety] Analyze synthesized constructors for dangling NSDMIs (PR #206375)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 29 02:25:46 PDT 2026
================
@@ -3005,6 +3010,51 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(
LifetimeSafetyTUAnalysis(S, TU, LSStats);
}
+void clang::sema::AnalysisBasedWarnings::
+ IssueLifetimeSafetyWarningsForImplicitFunction(const Decl *D) {
+ if (!D || !D->getBody())
+ return;
+ // TU-end analysis reaches such definitions via its own call-graph walk; only
+ // handle the per-function mode here. The remaining guards mirror
+ // IssueWarnings.
+ if (S.getLangOpts().EnableLifetimeSafetyTUAnalysis ||
+ !S.getLangOpts().CPlusPlus || !lifetimes::IsLifetimeSafetyEnabled(S, D))
+ return;
+
+ DiagnosticsEngine &Diags = S.getDiagnostics();
+ if (Diags.getIgnoreAllWarnings() ||
+ (Diags.getSuppressSystemWarnings() &&
+ S.SourceMgr.isInSystemHeader(D->getLocation())))
+ return;
+ if (cast<DeclContext>(D)->isDependentContext())
+ return;
+ if (S.hasUncompilableErrorOccurred())
+ return;
+
----------------
usx95 wrote:
I think this is also done in `AnalysisBasedWarnings::IssueWarnings`; consider refactoring to a common function.
https://github.com/llvm/llvm-project/pull/206375
More information about the cfe-commits
mailing list