[clang] [LifetimeSafety] Support C Language in LifetimeSafety (PR #203270)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 12 06:55:29 PDT 2026


================
@@ -3164,7 +3164,8 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(
 
   // TODO: Enable lifetime safety analysis for other languages once it is
   // stable.
-  if (EnableLifetimeSafetyAnalysis && S.getLangOpts().CPlusPlus) {
+  if (EnableLifetimeSafetyAnalysis &&
+      (S.getLangOpts().CPlusPlus || !S.getLangOpts().ObjC)) {
----------------
usx95 wrote:

We should also do this for end of TU analysis.
```cpp
  if (S.getLangOpts().CPlusPlus &&
      S.getLangOpts().EnableLifetimeSafetyTUAnalysis)
    LifetimeSafetyTUAnalysis(S, TU, LSStats);
```
Maybe refactor to do this directly in `lifetimes::IsLifetimeSafetyEnabled` as it already has the `Sema` and make TU analysis use that method as well.

https://github.com/llvm/llvm-project/pull/203270


More information about the cfe-commits mailing list