[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;
----------------
usx95 wrote:
I think `lifetimes::IsLifetimeSafetyEnabled` alone should be able to handle this. E.g. if `EnableLifetimeSafetyTUAnalysis` is true, it returns true only for TUDecls. Also takes care of language enablement.
https://github.com/llvm/llvm-project/pull/206375
More information about the cfe-commits
mailing list